コード例 #1
0
        public ClusterSingletonManagerLeaseSpecConfig()
        {
            Controller = Role("controller");
            First      = Role("first");
            Second     = Role("second");
            Third      = Role("third");
            Fourth     = Role("fourth");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.loglevel = DEBUG
                akka.actor.provider = ""cluster""
                akka.remote.log-remote-lifecycle-events = off
                #akka.cluster.auto-down-unreachable-after = off
                #akka.cluster.downing-provider-class = akka.cluster.testkit.AutoDowning
                akka.cluster.auto-down-unreachable-after = 0s
                akka.cluster.testkit.auto-down-unreachable-after = 0s
                test-lease {
                    lease-class = ""Akka.Cluster.Tools.Tests.MultiNode.TestLeaseActorClient, Akka.Cluster.Tools.Tests.MultiNode""
                    heartbeat-interval = 1s
                    heartbeat-timeout = 120s
                    lease-operation-timeout = 3s
                }
                akka.cluster.singleton {
                    use-lease = ""test-lease""
                }
            ")
                           .WithFallback(ClusterSingletonManager.DefaultConfig())
                           .WithFallback(ClusterSingletonProxy.DefaultConfig())
                           .WithFallback(MultiNodeClusterSpec.ClusterConfig());

            NodeConfig(new[] { First, Second, Third, Fourth }, new[] { ConfigurationFactory.ParseString(@"
                akka.cluster.roles = [worker]
            ") });
        }
コード例 #2
0
 public static Config GetConfig()
 {
     return(ConfigurationFactory.ParseString(@"akka.actor.provider = cluster
         akka.remote.dot-netty.tcp.port = 0")
            .WithFallback(ClusterSharding.DefaultConfig())
            .WithFallback(ClusterSingletonManager.DefaultConfig()));
 }
コード例 #3
0
        public static Config GetConfig()
        {
            return(ConfigurationFactory.ParseString("akka.actor.provider = cluster")

                   .WithFallback(Sharding.ClusterSharding.DefaultConfig())
                   .WithFallback(DistributedData.DistributedData.DefaultConfig())
                   .WithFallback(ClusterSingletonManager.DefaultConfig()));
        }
コード例 #4
0
 static CoordinatedShutdownShardingSpec()
 {
     SpecConfig = ConfigurationFactory.ParseString(@"
         akka.loglevel = DEBUG
         akka.actor.provider = cluster
         akka.remote.dot-netty.tcp.port = 0")
                  .WithFallback(ClusterSingletonManager.DefaultConfig()
                                .WithFallback(ClusterSharding.DefaultConfig()));
 }
コード例 #5
0
        /// <summary>
        /// Create settings from the default configuration `akka.cluster.sharding`.
        /// </summary>
        public static ClusterShardingSettings Create(ActorSystem system)
        {
            system.Settings.InjectTopLevelFallback(ClusterSingletonManager.DefaultConfig());

            var config = system.Settings.Config.GetConfig("akka.cluster.sharding");
            var coordinatorSingletonPath = config.GetString("coordinator-singleton");

            return(Create(config, system.Settings.Config.GetConfig(coordinatorSingletonPath)));
        }
コード例 #6
0
 static PersistentShardSpec()
 {
     SpecConfig = ConfigurationFactory.ParseString(@"
         akka.loglevel = DEBUG
         akka.actor.provider = cluster
         akka.persistence.journal.plugin = ""akka.persistence.journal.inmem""
         akka.remote.dot-netty.tcp.port = 0")
                  .WithFallback(ClusterSingletonManager.DefaultConfig()
                                .WithFallback(ClusterSharding.DefaultConfig()));
 }
コード例 #7
0
        static void Main()
        {
            var config = ConfigurationFactory.ParseString(configString).WithFallback(ClusterSingletonManager.DefaultConfig());
            var system = ActorSystem.Create("cluster-system", config);
            var server = system.ActorOf(ClusterSingletonManager.Props(
                                            singletonProps: Props.Create <Server>(),
                                            terminationMessage: PoisonPill.Instance,
                                            settings: ClusterSingletonManagerSettings.Create(system).WithRole("worker")),
                                        name: "consumer");

            Console.ReadKey();
        }
コード例 #8
0
        public ClusterSingletonManagerStartupConfig()
        {
            var first  = Role("first");
            var second = Role("second");
            var third  = Role("third");

            CommonConfig = ConfigurationFactory.ParseString(@"
            akka.loglevel = DEBUG
            akka.actor.provider = ""Akka.Aluster.ClusterActorRefProvider, Akka.Cluster""
            akka.remote.log-remote-lifecycle-events = off
            akka.cluster.auto-down-unreachable-after = 0s")
                           .WithFallback(ClusterSingletonManager.DefaultConfig())
                           .WithFallback(MultiNodeClusterSpec.ClusterConfig());
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: Arkatufus/Akka.Net.Samples
        static async Task Main(string[] args)
        {
            var config = ConfigurationFactory.ParseString(await File.ReadAllTextAsync("app.conf"))
                         .WithFallback(ClusterSingletonManager.DefaultConfig());

            using (var system = ActorSystem.Create("sharded-cluster-system", config))
            {
                var cluster     = Cluster.Get(system);
                var persistence = SqlitePersistence.Get(system);
                await RunExample(system);

                Console.ReadLine();
            }
        }
コード例 #10
0
        static void Main()
        {
            var config = ConfigurationFactory.ParseString(configString).WithFallback(ClusterSingletonManager.DefaultConfig());
            var system = ActorSystem.Create("cluster-system", config);
            var server = system.ActorOf(ClusterSingletonManager.Props(
                                            singletonProps: Props.Create <Server>(),
                                            terminationMessage: PoisonPill.Instance,
                                            settings: ClusterSingletonManagerSettings.Create(system).WithRole("worker")),
                                        name: "consumer");

            Thread.Sleep(10000);
            var s = Address.Parse("akka.tcp://cluster-system@localhost:5001/");

            Cluster.Get(system).Leave(s);
            Console.ReadKey();
        }
コード例 #11
0
ファイル: ShardSpec.cs プロジェクト: jarlrasm/akka.net
        static ShardSpec()
        {
            SpecConfig = ConfigurationFactory.ParseString(@"

                akka.loglevel = INFO
                akka.actor.provider = ""cluster""
                akka.remote.dot-netty.tcp.port = 0
                test-lease {
                    lease-class = ""Akka.Coordination.Tests.TestLease, Akka.Coordination.Tests""
                    heartbeat-interval = 1s
                    heartbeat-timeout = 120s
                    lease-operation-timeout = 3s
                }")
                         .WithFallback(ClusterSingletonManager.DefaultConfig()
                                       .WithFallback(ClusterSharding.DefaultConfig()));
        }
コード例 #12
0
        public ClusterSingletonManagerStartupConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.loglevel = INFO
                akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                akka.remote.retry-gate-closed-for = 1s #fast restart
                akka.remote.log-remote-lifecycle-events = off
                akka.cluster.auto-down-unreachable-after = 0s")
                           .WithFallback(ClusterSingletonManager.DefaultConfig())
                           .WithFallback(ClusterSingletonProxy.DefaultConfig())
                           .WithFallback(MultiNodeClusterSpec.ClusterConfig());
        }
コード例 #13
0
        public void Start()
        {
            Logger.Info("Starting shard");

            var system = ActorSystem.Create(Constants.ActorSystemName, ConfigurationFactory.Load()
                                            .WithFallback(config)
                                            .WithFallback(ClusterSingletonManager.DefaultConfig()));
            var sharding = ClusterSharding.Get(system);

            shardRegion = sharding.Start(
                typeName: nameof(MyActor),
                entityProps: Props.Create(() => new MyActor(nodeId)),
                settings: ClusterShardingSettings.Create(system),
                messageExtractor: new MessageExtractor(Constants.MaxNumberOfNodes * 10)
                );
            ClusterClientReceptionist.Get(system).RegisterService(shardRegion);
        }
コード例 #14
0
        public ClusterSingletonManagerChaos2Config()
        {
            Controller = Role("controller");
            First      = Role("_config.First");
            Second     = Role("second");
            Third      = Role("third");
            Fourth     = Role("fourth");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.loglevel = DEBUG
                akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                akka.remote.log-remote-lifecycle-events = off
                akka.cluster.auto-down-unreachable-after = 0s
            ")
                           .WithFallback(ClusterSingletonManager.DefaultConfig())
                           .WithFallback(ClusterSingletonProxy.DefaultConfig())
                           .WithFallback(MultiNodeClusterSpec.ClusterConfig());
        }
コード例 #15
0
        public ClusterSingletonManagerLeave2SpecConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");
            Fourth = Role("fourth");
            Fifth  = Role("fifth");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.loglevel = INFO
                akka.actor.provider = ""cluster""
                akka.remote.log-remote-lifecycle-events = off
                akka.cluster.auto-down-unreachable-after = off
            ")
                           .WithFallback(ClusterSingletonManager.DefaultConfig())
                           .WithFallback(ClusterSingletonProxy.DefaultConfig())
                           .WithFallback(MultiNodeClusterSpec.ClusterConfig());
        }
コード例 #16
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="system">TBD</param>
        public ClusterSharding(ExtendedActorSystem system)
        {
            _system = system;
            _system.Settings.InjectTopLevelFallback(DefaultConfig());
            _system.Settings.InjectTopLevelFallback(ClusterSingletonManager.DefaultConfig());
            _cluster = Cluster.Get(_system);
            Settings = ClusterShardingSettings.Create(system);

            _guardian = new Lazy <IActorRef>(() =>
            {
                var guardianName = system.Settings.Config.GetString("akka.cluster.sharding.guardian-name");
                var dispatcher   = system.Settings.Config.GetString("akka.cluster.sharding.use-dispatcher");
                if (string.IsNullOrEmpty(dispatcher))
                {
                    dispatcher = Dispatchers.DefaultDispatcherId;
                }
                return(system.SystemActorOf(Props.Create(() => new ClusterShardingGuardian()).WithDispatcher(dispatcher), guardianName));
            });
        }
コード例 #17
0
        static void Main(string[] args)
        {
            var config = ConfigurationFactory.ParseString(configString).WithFallback(ClusterSingletonManager.DefaultConfig());
            var system = ActorSystem.Create("cluster-system", config);

            var client =
                system
                .ActorOf(
                    ClusterSingletonProxy.Props("/user/consumer",
                                                ClusterSingletonProxySettings.Create(system).WithRole("worker")));

            while (true)
            {
                Thread.Sleep(1000);
                client.Tell(DateTime.Now.ToLongTimeString());
            }

            Console.ReadKey();
        }
コード例 #18
0
 public static Config GetConfig()
 {
     return(ConfigurationFactory.ParseString(@"
         akka.loglevel = DEBUG
         #akka.loggers = [""akka.testkit.SilenceAllTestEventListener""]
         akka.loggers = [Akka.Event.DefaultLogger]
         akka.actor.provider = ""cluster""
         akka.remote.dot-netty.tcp.port = 0
         akka.cluster.sharding {
             use-lease = ""test-lease""
             lease-retry-interval = 200ms
             distributed-data.durable {
                 keys = []
             }
         }
         ")
            .WithFallback(ClusterSharding.DefaultConfig())
            .WithFallback(ClusterSingletonManager.DefaultConfig())
            .WithFallback(TestLease.Configuration));
 }
コード例 #19
0
ファイル: Program.cs プロジェクト: eaba/akka.net
        public static async Task Main(string[] args)
        {
            #region Console shutdown setup

            var exitEvent = new ManualResetEvent(false);
            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                eventArgs.Cancel = true;
                exitEvent.Set();
            };
            AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) =>
            {
                exitEvent.Set();
            };

            #endregion

            var config = ConfigurationFactory.ParseString(await File.ReadAllTextAsync("app.conf"))
                         .BootstrapFromDocker()
                         .WithFallback(ClusterSingletonManager.DefaultConfig())
                         .WithFallback(SqlitePersistence.DefaultConfiguration());

            var system = ActorSystem.Create("sharded-cluster-system", config);

            var sharding    = ClusterSharding.Get(system);
            var shardRegion = await sharding.StartAsync(
                typeName : "customer",
                entityPropsFactory : e => Props.Create(() => new Customer(e)),
                settings : ClusterShardingSettings.Create(system),
                messageExtractor : new MessageExtractor(10));

            var cluster = Cluster.Get(system);
            cluster.RegisterOnMemberUp(() =>
            {
                ProduceMessages(system, shardRegion);
            });

            exitEvent.WaitOne();
            await system.Terminate();
        }
コード例 #20
0
        public ClusterSingletonManagerSpecConfig()
        {
            Controller = Role("controller");
            Observer   = Role("observer");
            First      = Role("first");
            Second     = Role("second");
            Third      = Role("third");
            Fourth     = Role("fourth");
            Fifth      = Role("fifth");
            Sixth      = Role("sixth");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.loglevel = DEBUG
                akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                akka.remote.log-remote-lifecycle-events = off
                akka.cluster.auto-down-unreachable-after = 0s
            ")
                           .WithFallback(ClusterSingletonManager.DefaultConfig())
                           .WithFallback(MultiNodeClusterSpec.ClusterConfig());

            NodeConfig(new[] { First, Second, Third, Fourth, Fifth, Sixth }, new[] { ConfigurationFactory.ParseString(@"akka.cluster.roles =[worker]") });
        }
コード例 #21
0
        public ShardedDaemonProcessSpecConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            CommonConfig = DebugConfig(false)
                           .WithFallback(ConfigurationFactory.ParseString(@"
                    akka.loglevel = INFO
                    akka.cluster.sharded-daemon-process {{
                      sharding {{
                        # First is likely to be ignored as shard coordinator not ready
                        retry-interval = 0.2s
                      }}
                      # quick ping to make test swift
                      keep-alive-interval = 1s
                    }}
                "))
                           .WithFallback(ClusterSharding.DefaultConfig())
                           .WithFallback(ClusterSingletonManager.DefaultConfig())
                           .WithFallback(MultiNodeClusterSpec.ClusterConfig());
        }
コード例 #22
0
        static void Main(string[] args)
        {
            Config config = @"
            akka {
              actor {
                provider = cluster
                serializers {
                  hyperion = ""Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion""
                }
                serialization-bindings {
                  ""System.Object"" = hyperion
                }
              }
              remote {
                dot-netty.tcp {
                  public-hostname = ""localhost""
                  hostname = ""localhost""
                  port = 0
                }
              }
              cluster {
                auto-down-unreachable-after = 5s
                sharding {
                  least-shard-allocation-strategy.rebalance-threshold = 3
                }
              }
              persistence {
                journal {
                  plugin = ""akka.persistence.journal.sqlite""
                  sqlite {
                    connection-string = ""Datasource=store.db""
                    auto-initialize = true
                  }
                }
                snapshot-store {
                  plugin = ""akka.persistence.snapshot-store.sqlite""
                  sqlite {
                    connection-string = ""Datasource=store.db""
                    auto-initialize = true
                  }
                }
              }
            }";

            using (var system = ActorSystem.Create("sharded-cluster-system", config.WithFallback(ClusterSingletonManager.DefaultConfig())))
            {
                var automaticCluster = new AutomaticCluster(system);
                try
                {
                    automaticCluster.Join();

                    RunExample(system);

                    Console.ReadLine();
                }
                finally
                {
                    //WARNING: you may need to remove SQLite database file from bin/Debug or bin/Release in case when unexpected crash happened
                    automaticCluster.Leave();
                }
            }
        }
コード例 #23
0
        static void Main(string[] args)
        {
            using (var system = ActorSystem.Create("sharded-cluster-system", Cch2.Cfg.WithFallback(ClusterSingletonManager.DefaultConfig())))
            {
                var automaticCluster = new AutomaticCluster(system);
                try
                {
                    automaticCluster.Join();
                    CounterHelper.CounterActor = system.ActorOf(Props.Create(() => new CounterActor()));


                    RunExample(system);

                    Console.WriteLine("## Is started");
                    Console.ReadLine();
                }
                finally
                {
                    //WARNING: you may need to remove SQLite database file from bin/Debug or bin/Release in case when unexpected crash happened
                    automaticCluster.Leave();
                }
            }
        }
コード例 #24
0
 static ClusterShardingMessageSerializerSpec()
 {
     SpecConfig = ClusterSingletonManager.DefaultConfig().WithFallback(ClusterSharding.DefaultConfig());
 }
コード例 #25
0
ファイル: Actor.cs プロジェクト: CoFlows/CoFlows-CE
        public static ActorSystem getSystem()
        {
            if (_system == null)
            {
                // var port = 5000;
                // var host = "localhost";
                // var config = ConfigurationFactory.ParseString(@"
                //     akka {
                //         loggers                 = [""Akka.Logger.NLog.NLogLogger, Akka.Logger.NLog""]
                //         loglevel                = info
                //         log-config-on-start     = on
                //         actor {
                //             provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                //             serializers {
                //                 hyperion = ""Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion""
                //             }
                //             serialization-bindings {
                //                 ""System.Object"" = hyperion
                //             }

                //             debug{
                //                 receive         = on  # log any received message
                //                 autoreceive     = on  # log automatically received messages, e.g. PoisonPill
                //                 lifecycle       = on  # log actor lifecycle changes
                //                 event-stream    = on  # log subscription changes for Akka.NET event stream
                //                 unhandled       = on  # log unhandled messages sent to actors
                //             }
                //         }
                //         remote {
                //             helios.tcp {
                //             public-hostname = """ + host + @"""
                //             hostname = """ + host + @"""
                //             port = """ + port.ToString() + @"""
                //             }
                //         }
                //         cluster {
                //             auto-down-unreachable-after = 5s
                //             seed-nodes = [""akka.tcp://cluster-system@""" + host + ":" + port.ToString() + @"/""]
                //         }
                //     }
                //     ");

                // var port = 5000;
                // var host = "localhost";
                var config = ConfigurationFactory.ParseString(@"
                    akka {
                        loggers                 = [""Akka.Logger.NLog.NLogLogger, Akka.Logger.NLog""]
                        loglevel                = info
                        log-config-on-start     = on
                        actor {
                            serializers {
                                hyperion = ""Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion""
                            }
                            serialization-bindings {
                                ""System.Object"" = hyperion
                            }

                            debug{
                                receive         = on  # log any received message
                                autoreceive     = on  # log automatically received messages, e.g. PoisonPill
                                lifecycle       = on  # log actor lifecycle changes
                                event-stream    = on  # log subscription changes for Akka.NET event stream
                                unhandled       = on  # log unhandled messages sent to actors
                            }
                        }
                    }
                    ");

                config.WithFallback(ClusterSingletonManager.DefaultConfig());

                _system = ActorSystem.Create("cluster-system", config);
            }

            return(_system);
        }
コード例 #26
0
 public ClusterSingletonMessageSerializerSpec()
     : base(ConfigurationFactory.ParseString(@"akka.actor.provider = cluster
                                               akka.remote.dot-netty.tcp.port = 0").WithFallback(ClusterSingletonManager.DefaultConfig()))
 {
 }
コード例 #27
0
        static void Main(string[] args)
        {
            using (var system = ActorSystem.Create("sharded-cluster-system", ConfigurationFactory.Load().WithFallback(ClusterSingletonManager.DefaultConfig())))
            {
                var automaticCluster = new AutomaticCluster(system);
                try
                {
                    automaticCluster.Join();

                    RunExample(system);

                    Console.ReadLine();
                }
                finally
                {
                    //WARNING: you may need to remove SQLite database file from bin/Debug or bin/Release in case when unexpected crash happened
                    automaticCluster.Leave();
                }
            }
        }
コード例 #28
0
        public ClusterShardingSpecConfig(/*string entityRecoveryStrategy*/)
        {
            Controller = Role("controller");
            First      = Role("first");
            Second     = Role("second");
            Third      = Role("third");
            Fourth     = Role("fourth");
            Fifth      = Role("fifth");
            Sixth      = Role("sixth");

            CommonConfig = DebugConfig(false)
                           .WithFallback(ConfigurationFactory.ParseString(@"
                    akka.actor {
                        serializers {
                            hyperion = ""Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion""
                        }
                        serialization-bindings {
                            ""System.Object"" = hyperion
                        }
                    }

                    akka.cluster.auto-down-unreachable-after = 0s
                    akka.cluster.roles = [""backend""]
                    akka.cluster.sharding {
                        retry-interval = 1 s
                        handoff-timeout = 10 s
                        shard-start-timeout = 5s
                        entity-restart-backoff = 1s
                        rebalance-interval = 2 s
                        entity-recovery-strategy = ""all""
                        entity-recovery-constant-rate-strategy {
                            frequency = 1 ms
                            number-of-entities = 1
                        }
                        least-shard-allocation-strategy {
                            rebalance-threshold = 2
                            max-simultaneous-rebalance = 1
                        }
                    }

                    akka.testconductor.barrier-timeout = 70s


                    akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.inmem""
                    akka.persistence.journal.plugin = ""akka.persistence.journal.memory-journal-shared""

                    akka.persistence.journal.MemoryJournal {
                        class = ""Akka.Persistence.Journal.MemoryJournal, Akka.Persistence""
                        plugin-dispatcher = ""akka.actor.default-dispatcher""
                    }

                    akka.persistence.journal.memory-journal-shared {
                        class = ""Akka.Cluster.Sharding.Tests.MemoryJournalShared, Akka.Cluster.Sharding.Tests.MultiNode""
                        plugin-dispatcher = ""akka.actor.default-dispatcher""
                        timeout = 5s
                    }
                "))
                           .WithFallback(Sharding.ClusterSharding.DefaultConfig())
                           .WithFallback(ClusterSingletonManager.DefaultConfig())
                           .WithFallback(MultiNodeClusterSpec.ClusterConfig());

            NodeConfig(new[] { Sixth }, new[] { ConfigurationFactory.ParseString(@"akka.cluster.roles = [""frontend""]") });
        }
コード例 #29
0
 public ClusterSingletonMessageSerializerSpec() : base(ClusterSingletonManager.DefaultConfig())
 {
     serializer = new ClusterSingletonMessageSerializer((ExtendedActorSystem)Sys);
 }
コード例 #30
0
        internal static Config GetConfig(int port, string role)
        {
            var systemConfigString = SystemConfigString.Replace("PORT", port.ToString()).Replace("ROLE", role);

            return(ConfigurationFactory.ParseString(systemConfigString).WithFallback(ClusterSingletonManager.DefaultConfig()));
        }