public static (IActorRef, ActorSystem) CreatePluginSystem(string actorSystemName, ILoggerFactory loggerFactory) { var logger = loggerFactory.GetLogger(); Log.Logger = logger; var system = ActorSystem.Create(actorSystemName, CommonConfigs.BasicConfig()); var registry = system.ActorOf <PluginRegistry>("plugin-registry"); return(registry, system); }
public static PluginSystem NewPluginSystem(string systemName) { var config = CommonConfigs.BasicConfig(); return(NewPluginSystem(systemName, config)); }
static void Main(string[] args) { var numArgs = 2; if (args.Length < numArgs) { Log.Fatal("Cluster Bootstrapper does not have the correct number of arguments. Expected at least {ExpectedArguments} but received {NumberOfArguments}", numArgs, args.Length); var count = 1; foreach (var arg in args) { Log.Information("Arg[{ArgumentIndex}]:{Argument}", count, arg); Log.CloseAndFlush(); } return; } var loggerFactory = new ElasticSearchLoggerFactory(new Uri("http://*****:*****@{hostname}:4053"; // Create the system and actors var cfg = CommonConfigs.BasicConfig() // Supress JSON warning .WithFallback(ClusterNodeConstants.DefaultConfig()) // With default actor props factory .WithFallback( ClusterConfigs.CreateClusterConfig( new DefaultClusterConfig( hostname, 0, seedNodes: new[] { seedNode }, roles: roles.Select(x => (Key: x, Value: 0)).ToDictionary(x => x.Key, x => x.Value) ) ) ) .WithFallback(CommonConfigs.CreateLoggingConfig(new SerilogConfig())); // Serilog logging var system = ActorSystem.Create(systemName, cfg); var configurator = system.ActorOf(Props.Create(() => new NodeConfigurator()), "configurator"); Console.CancelKeyPress += async(sender, eventArgs) => { Console.WriteLine("Stopping Cluster Worker..."); await CoordinatedShutdown.Get(system).Run(); }; // Waits until service is terminated and then exits the program system.WhenTerminated.Wait(); logger.Information("Cluster Worker stopped"); Log.CloseAndFlush(); }
public void BasicConfigTest() { var cfg = CommonConfigs.BasicConfig(); cfg.GetBoolean("akka.suppress-json-serializer-warning").Should().Be(true); }
static void Main() { var loggerFactory = new ElasticSearchLoggerFactory(new Uri("http://*****:*****@{hostname}:{port}"; // Create the system and actors var cfg = CommonConfigs.BasicConfig() // Supress JSON warning .WithFallback(ClusterNodeConstants.DefaultConfig()) // With default actor props factory .WithFallback( ClusterConfigs.CreateClusterConfig( new DefaultClusterConfig( hostname, port, // hostname and any port seedNodes: new [] { selfSeedNode }, // Seed nodes roles: roles ) ) ) .WithFallback(CommonConfigs.CreateLoggingConfig(new SerilogConfig())); // Serilog logging var system = ActorSystem.Create(systemName, cfg); // // Create configurations var workerNodeConfig = new SystemConfiguration( new RandomLoggerActorConfiguration("LoggerOne", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs"), new RandomLoggerActorConfiguration("LoggerTwo", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs"), new RandomLoggerActorConfiguration("LoggerThree", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs"), new RandomLoggerActorConfiguration("LoggerFour", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs"), new RandomLoggerActorConfiguration("LoggerFive", TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(3), "Logs") ); var listenerNodeConfig = new SystemConfiguration(new LogConfirmationActorConfiguration("ListenerPlugin", "Logs")); var targetNode = $"akka.tcp://{ClusterNodeConstants.DefaultSystemName}@{hostname}:4053"; var clientSettings = ClusterClientSettings.Create(system) .WithInitialContacts( new[] { ActorPath.Parse(targetNode + "/system/receptionist") }.ToImmutableHashSet() ); var clusterClient = system.ActorOf(ClusterClient.Props(clientSettings), "cluster-client"); // Publishes to given topic clusterClient.Tell(new ClusterClient.Publish("client-messages", new ConfigureRoles(workerNodeConfig, "worker"))); clusterClient.Tell(new ClusterClient.Publish("client-messages", new ConfigureRoles(listenerNodeConfig, "listener"))); // // Sends direct to known singleton proxy // clusterClient.Tell(new ClusterClient.Send("/user/manager", new ConfigureRoles(workerNodeConfig, "worker"))); // clusterClient.Tell(new ClusterClient.Send("/user/manager", new ConfigureRoles(listenerNodeConfig, "listener"))); Console.CancelKeyPress += async(sender, eventArgs) => { Console.WriteLine("Stopping Cluster Bootstrapper..."); await CoordinatedShutdown.Get(system).Run(); }; // Waits until service is terminated and then exits the program system.WhenTerminated.Wait(); logger.Information("Cluster Bootstrapper stopped"); Log.CloseAndFlush(); }
private static void Run() { Log.Logger = LoggerFactory.Logger; Console.WriteLine("AkkaLibrary Test Harness."); var exitEvent = new ManualResetEvent(false); Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = true; exitEvent.Set(); }; var pluginSystem = PluginSystemFactory.NewPluginSystem("TestActorSystem", CommonConfigs.BasicConfig()); var registry = pluginSystem.PluginRegistryRef; var system = pluginSystem.System; //=================================================== var config = new TestPluginConfiguration { Name = "test-plugin" }; var testPlugin = pluginSystem.CreatePlugin(config); //=================================================== Console.WriteLine("Press Ctrl+C to terminate."); exitEvent.WaitOne(); var terminateTask = system.Terminate(); var success = terminateTask.Wait(TimeSpan.FromSeconds(5)); Log.Information($"Actor system terminated {(success ? "successfully" : "unsuccessfully")}."); Log.CloseAndFlush(); }