Esempio n. 1
0
        public StatsSampleSpecConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            // this configuration will be used for all nodes
            // note that no fixed host names and ports are used
            CommonConfig = ConfigurationFactory.ParseString(@"
                # Enable metrics extension in akka-cluster-metrics.
                akka.extensions=[""Akka.Cluster.Metrics.ClusterMetricsExtensionProvider, Akka.Cluster.Metrics""]

                akka.actor.provider = cluster
                akka.remote.classic.log-remote-lifecycle-events = off
                akka.cluster.roles = [compute]
                #//#router-lookup-config
                akka.actor.deployment {
                  /statsService/workerRouter {
                      router = consistent-hashing-group
                      routees.paths = [""/user/statsWorker""]
                        cluster {
                            enabled = on
                            allow-local-routees = on
                            use-roles = [""compute""]
                        }
                    }
                }
                #//#router-lookup-config
            ");
        }
Esempio n. 2
0
 static ReplicatorSpecs()
 {
     SpecConfig = ConfigurationFactory.ParseString(@"
         akka.loglevel = DEBUG
         akka.actor.provider = cluster
         akka.remote.dot-netty.tcp.port = 0")
                  .WithFallback(DistributedData.DefaultConfig());
 }
Esempio n. 3
0
        private Config Config(string id, Config appConfig)
        {
            var simpleName = id.Substring(id.LastIndexOf('.') + 1);

            return(IdConfig(id)
                   .WithFallback(appConfig)
                   .WithFallback(ConfigurationFactory.ParseString(string.Format("name: {0}", simpleName)))
                   .WithFallback(DefaultDispatcherConfig));
        }
Esempio n. 4
0
        public WeightedRouteesSpec()
            : base(ConfigurationFactory.ParseString(@"
                akka.actor.provider = ""cluster""
                akka.remote.classic.netty.tcp.port = 0
                akka.remote.artery.canonical.port = 0
            "))
        {
            _routeeA = new ActorSelectionRoutee(Sys.ActorSelection(new RootActorPath(_a1) / "user" / "a"));
            _routeeB = new ActorSelectionRoutee(Sys.ActorSelection(new RootActorPath(_b1) / "user" / "b"));
            _routeeC = new ActorSelectionRoutee(Sys.ActorSelection(new RootActorPath(_c1) / "user" / "c"));
            _routees = ImmutableArray.Create <Routee>(_routeeA, _routeeB, _routeeC);

            _testActorRoutee = new ActorRefRoutee(TestActor);
        }
Esempio n. 5
0
        [Fact] public void EventAdapters_should_fail_with_useful_message_when_binding_to_not_defined_adapter()
        {
            var badConfig      = ConfigurationFactory.ParseString(@"
akka.persistence.journal.inmem {
  event-adapter-bindings {
    ""System.Integer"" = undefined-adapter
  }
}");
            var combinedConfig = badConfig.GetConfig("akka.persistence.journal.inmem");

            var ex = Assert.Throws <ArgumentException>(() => EventAdapters.Create(_extendedActorSystem, combinedConfig));

            ex.Message.Contains("System.Integer was bound to undefined event-adapter: undefined-adapter").Should().BeTrue();
        }
Esempio n. 6
0
        public static Config Config()
        {
            var address = TestUtils.TemporaryServerAddress();

            return(ConfigurationFactory.ParseString($@"        
            akka {{
              loglevel = INFO
              actor {{
                provider = remote
                serialize-messages = off
              }}
              remote.dot-netty.tcp {{
                port = {address.Port}
                hostname = ""{address.Address}""
              }}
            }}")
                   .WithFallback(ConfigurationFactory.Default()));
        }
        public AdaptiveLoadBalancingRouterConfig()
        {
            Node1 = Role("node-1");
            Node2 = Role("node-2");
            Node3 = Role("node-3");

            CommonConfig = DebugConfig(on: false)
                           .WithFallback(ConfigurationFactory.ParseString(@"
                    # Enable metrics extension in akka-cluster-metrics.
                    akka.extensions=[""Akka.Cluster.Metrics.ClusterMetricsExtensionProvider, Akka.Cluster.Metrics""]

                    akka.cluster.failure-detector.acceptable-heartbeat-pause = 10s

                    # Use rapid metrics collection.
                    akka.cluster.metrics {
                        collector {
                            sample-interval = 1s
                            gossip-interval = 1s
                            moving-average-half-life = 2s
                        }
                    }

                    # Use metrics extension routing.
                    akka.actor.deployment {
                        /router3 = {
                            router = cluster-metrics-adaptive-pool
                            metrics-selector = cpu
                            nr-of-instances = 9
                        }
                        /router4 = {
                            router = cluster-metrics-adaptive-pool
                            metrics-selector = ""Akka.Cluster.Metrics.Tests.MultiNode.TestCustomMetricsSelector, Akka.Cluster.Metrics.Tests.MultiNode""
                            nr-of-instances = 10
                            cluster {
                                enabled = on
                                max-nr-of-instances-per-node = 2
                            }
                        }
                    }
                "))
                           .WithFallback(ClusterMetrics.DefaultConfig())
                           .WithFallback(MultiNodeClusterSpec.ClusterConfig());
        }
Esempio n. 8
0
        public static ActorSystem CreateActorSystem()
        {
            var address = TestUtils.TemporaryServerAddress();
            var config  = ConfigurationFactory.ParseString($@"        
            akka {{
              loglevel = INFO
              actor {{
                provider = remote
                serialize-messages = off
              }}
              remote.dot-netty.tcp {{
                port = {address.Port}
                hostname = ""{address.Address}""
              }}
            }}")
                          .WithFallback(ConfigurationFactory.Default());

            var system = ActorSystem.Create("remote-system-2", config);

            return(system);
        }
Esempio n. 9
0
        public void Should_be_able_to_parse_settings()
        {
            var config = Sys.Settings.Config.WithFallback(
                ConfigurationFactory.FromResource <ClusterMetricsSettings>("Akka.Cluster.Metrics.reference.conf"));
            var settings = new ClusterMetricsSettings(config);

            // Extension.
            settings.MetricsDispatcher.ShouldBe(Dispatchers.DefaultDispatcherId);
            settings.PeriodicTasksInitialDelay.Should().Be(1.Seconds());

            // Supervisor.
            settings.SupervisorName.Should().Be("cluster-metrics");
            settings.SupervisorStrategyProvider.Should().BeEquivalentTo(typeof(ClusterMetricsStrategy).TypeQualifiedName());
            settings.SupervisorStrategyConfiguration.ToString().ShouldBeEquivalentTo(
                ConfigurationFactory.ParseString("loggingEnabled=true,withinTimeRange=3s,maxNrOfRetries=3").ToString());

            // Collector.
            settings.CollectorEnabled.Should().BeTrue();
            settings.CollectorProvider.Should().BeEmpty();
            settings.CollectorSampleInterval.Should().Be(3.Seconds());
            settings.CollectorGossipInterval.Should().Be(3.Seconds());
            settings.CollectorMovingAverageHalfLife.Should().Be(12.Seconds());
        }
Esempio n. 10
0
        public MemoryEventAdaptersSpec()
        {
            var config = ConfigurationFactory.ParseString(@"
akka.persistence.journal {
  plugin = ""akka.persistence.journal.inmem""


  # adapters defined for all plugins
  common-event-adapter-bindings {
  }

  inmem {
    # showcases re-using and concating configuration of adapters

    event-adapters {
      example  = """ + typeof(ExampleEventAdapter).FullName + @", Akka.Persistence.Tests""
      marker   = """ + typeof(MarkerInterfaceAdapter).FullName + @", Akka.Persistence.Tests""
      precise  = """ + typeof(PreciseAdapter).FullName + @", Akka.Persistence.Tests""
      reader  = """ + typeof(ReaderAdapter).FullName + @", Akka.Persistence.Tests""
      writer  = """ + typeof(WriterAdapter).FullName + @", Akka.Persistence.Tests""
      another-reader  = """ + typeof(AnotherReaderAdapter).FullName + @", Akka.Persistence.Tests""
    }
    event-adapter-bindings = {
      """ + typeof(IEventMarkerInterface).FullName + @", Akka.Persistence.Tests"" = marker
      ""System.String"" = example
      """ + typeof(PreciseAdapterEvent).FullName + @", Akka.Persistence.Tests"" = precise
      """ + typeof(ReadMeEvent).FullName + @", Akka.Persistence.Tests"" = reader
      """ + typeof(WriteMeEvent).FullName + @", Akka.Persistence.Tests"" = writer
      """ + typeof(ReadMeTwiceEvent).FullName + @", Akka.Persistence.Tests"" = [reader, another-reader]
      """ + typeof(ReadWriteEvent).FullName + @", Akka.Persistence.Tests"" = [reader, another-reader, writer]
    }
  }
}").WithFallback(ConfigurationFactory.Default());

            _extendedActorSystem = (ExtendedActorSystem)Sys;
            _memoryConfig        = config.GetConfig("akka.persistence.journal.inmem");
        }
Esempio n. 11
0
 private Config IdConfig(string id)
 {
     return(ConfigurationFactory.ParseString(string.Format("id: {0}", id)));
 }
Esempio n. 12
0
        /// <summary>
        /// Adds the supplied configuration as a fallback to the supplied configuration string.
        /// </summary>
        /// <param name="configHocon">The configuration string used as the source.</param>
        /// <param name="fallbackConfig">The configuration used as the fallback.</param>
        /// <returns>A configuration configured with the supplied fallback.</returns>
        public static Config operator +(string configHocon, Config fallbackConfig)
        {
            Config config = ConfigurationFactory.ParseString(configHocon);

            return(config.WithFallback(fallbackConfig));
        }
Esempio n. 13
0
        /// <summary>
        /// Adds the supplied configuration string as a fallback to the supplied configuration.
        /// </summary>
        /// <param name="config">The configuration used as the source.</param>
        /// <param name="fallback">The string used as the fallback configuration.</param>
        /// <returns>The supplied configuration configured with the supplied fallback.</returns>
        public static Config operator +(Config config, string fallback)
        {
            Config fallbackConfig = ConfigurationFactory.ParseString(fallback);

            return(config.WithFallback(fallbackConfig));
        }
Esempio n. 14
0
 private static Config IdConfig(string id)
 {
     return(ConfigurationFactory.ParseString($"id: {id}"));
 }