public static async Task Main(string[] args) { //Get configuration file using Akkatecture's defaults as fallback var path = Environment.CurrentDirectory; var configPath = Path.Combine(path, "seed.conf"); var config = ConfigurationFactory.ParseString(File.ReadAllText(configPath)) .WithFallback(AkkatectureClusteringDefaultSettings.DefaultConfig()); var clustername = config.GetString("akka.cluster.name"); //Create actor system var actorSystem = ActorSystem.Create(clustername, config); Console.WriteLine("Akkatecture.Examples.Seed Running"); var quit = false; while (!quit) { Console.Write("\rPress Q to Quit. "); var key = Console.ReadLine(); quit = key?.ToUpper() == "Q"; } //Shut down the local actor system await actorSystem.Terminate(); Console.WriteLine("Akkatecture.Examples.Seed Exiting."); }
public void ClusteringDefaultSettings_IsNotEmpty() { var config = AkkatectureClusteringDefaultSettings.DefaultConfig(); var value = config.GetString("akka.cluster.name"); value.Should().Be("akkatecture"); }
public static async Task Main(string[] args) { //Get configuration file using Akkatecture's defaults as fallback var path = Environment.CurrentDirectory; var configPath = Path.Combine(path, "worker.conf"); var baseConfig = ConfigurationFactory.ParseString(File.ReadAllText(configPath)); //specified amount of workers running on their own thread var amountOfWorkers = 1; //Create several workers with each worker port will be 6001, 6002,... var actorSystems = new List <ActorSystem>(); foreach (var worker in Enumerable.Range(1, amountOfWorkers + 1)) { //Create worker with port 700X var config = ConfigurationFactory.ParseString($"akka.remote.dot-netty.tcp.port = 700{worker}"); config = config .WithFallback(baseConfig) .WithFallback(AkkatectureClusteringDefaultSettings.DefaultConfig()); var clustername = config.GetString("akka.cluster.name"); var actorSystem = ActorSystem.Create(clustername, config); actorSystems.Add(actorSystem); Cluster.Get(actorSystem).RegisterOnMemberUp(() => { //Start the aggregate cluster when the actorsystem is part of a cluster. //all requests being proxied to this cluster will be sent here to be processed. StartUserAccountCluster(actorSystem); }); } Console.WriteLine("Akkatecture.Examples.Workers Running"); var quit = false; while (!quit) { Console.Write("\rPress Q to Quit. "); var key = Console.ReadLine(); quit = key?.ToUpper() == "Q"; } //Shut down all the local actor systems foreach (var actorsystem in actorSystems) { await actorsystem.Terminate(); } Console.WriteLine("Akkatecture.Examples.Workers Exiting."); }
public static async Task Main(string[] args) { //Get configuration file using Akkatecture's defaults as fallback var path = Environment.CurrentDirectory; var configPath = Path.Combine(path, "client.conf"); var config = ConfigurationFactory.ParseString(File.ReadAllText(configPath)) .WithFallback(AkkatectureClusteringDefaultSettings.DefaultConfig()); //Create actor system var clustername = config.GetString("akka.cluster.name"); var shardProxyRoleName = config.GetString("akka.cluster.singleton-proxy.role"); var actorSystem = ActorSystem.Create(clustername, config); StartApplication(actorSystem, shardProxyRoleName); await actorSystem.WhenTerminated; Console.WriteLine("Akkatecture.Examples.ClusterClient Exiting."); }
public static void Main(string[] args) { //Get configuration file using Akkatecture's defaults as fallback var path = Environment.CurrentDirectory; var configPath = Path.Combine(path, "client.conf"); var config = ConfigurationFactory.ParseString(File.ReadAllText(configPath)) .WithFallback(AkkatectureClusteringDefaultSettings.DefaultConfig()); //Create actor system var clustername = config.GetString("akka.cluster.name"); var shardProxyRoleName = config.GetString("akka.cluster.singleton-proxy.role"); var actorSystem = ActorSystem.Create(clustername, config); //Instantiate an aggregate proxy reference to the worker node that hosts the //aggregates. This is the reference to proxy client commands to var aggregateProxy = StartUserAccountClusterProxy(actorSystem, shardProxyRoleName); Console.WriteLine("Press Enter To Create A Random User Account, or Q to quit."); var key = Console.ReadLine(); var quit = key?.ToUpper() == "Q"; while (!quit) { //Generate random, new UserAccount var aggregateId = UserAccountId.New; var randomUserAccountName = Guid.NewGuid().ToString(); var createUserAccountCommand = new CreateUserAccountCommand(aggregateId, randomUserAccountName); //Send the command aggregateProxy.Tell(createUserAccountCommand); Console.WriteLine($"CreateUsrAccountCommand: Id={createUserAccountCommand.AggregateId}; Name={createUserAccountCommand.Name} Sent."); Console.WriteLine("Press Enter To Create Another Random User Account, or Q to quit."); key = Console.ReadLine(); quit = key?.ToUpper() == "Q"; } //Shut down the local actor system actorSystem.Terminate().Wait(); Console.WriteLine("Akkatecture.Examples.ClusterClient Exiting."); }
public AggregateClusterTestConfig() { Seed = Role("seed"); Client = Role("client"); Worker = Role("worker"); CommonConfig = ConfigurationFactory.ParseString(@" akka.loglevel = INFO ") .WithFallback(MultiNodeLoggingConfig.LoggingConfig) .WithFallback(AkkatectureClusteringDefaultSettings.DefaultConfig()) .WithFallback(MultiNodeClusterSpec.ClusterConfig()); NodeConfig(new [] { Seed }, new [] { ConfigurationFactory.ParseString(@" akka.cluster.roles=[""seed""] akka.cluster.sharding.role = ""seed"" ") }); NodeConfig(new [] { Client }, new [] { ConfigurationFactory.ParseString(@" akka.cluster.roles=[""client""] akka.cluster.sharding.role = ""client"" ") }); NodeConfig(new [] { Worker }, new [] { ConfigurationFactory.ParseString(@" akka.cluster.roles=[""worker""] akka.cluster.sharding.role = ""worker"" ") }); }