private static ActorSystem CreateClient(Config commonConfig) { var config = commonConfig.WithFallback("akka.remote.helios.tcp.port = 9002"); var system = ActorSystem.Create("Client", config); DeadRequestProcessingActor.Install(system); return system; }
public SqliteJournal(Config journalConfig) : base(journalConfig.WithFallback(Extension.DefaultJournalConfig)) { var config = journalConfig.WithFallback(Extension.DefaultJournalConfig); QueryExecutor = new SqliteQueryExecutor(new QueryConfiguration( schemaName: null, journalEventsTableName: config.GetString("table-name"), metaTableName: config.GetString("metadata-table-name"), persistenceIdColumnName: "persistence_id", sequenceNrColumnName: "sequence_nr", payloadColumnName: "payload", manifestColumnName: "manifest", timestampColumnName: "timestamp", isDeletedColumnName: "is_deleted", tagsColumnName: "tags", orderingColumnName: "ordering", timeout: config.GetTimeSpan("connection-timeout")), Context.System.Serialization, GetTimestampProvider(config.GetString("timestamp-provider"))); }
public virtual Deploy ParseConfig(string key, Config config) { var deployment = config.WithFallback(_default); var routerType = deployment.GetString("router"); var router = CreateRouterConfig(routerType, deployment); var dispatcher = deployment.GetString("dispatcher"); var mailbox = deployment.GetString("mailbox"); var deploy = new Deploy(key, deployment, router, Deploy.NoScopeGiven, dispatcher, mailbox); return deploy; }
public SqliteSnapshotStore(Config snapshotConfig) : base(snapshotConfig) { var config = snapshotConfig.WithFallback(Extension.DefaultSnapshotConfig); QueryExecutor = new SqliteSnapshotQueryExecutor(new QueryConfiguration( schemaName: null, snapshotTableName: "snapshot", persistenceIdColumnName: "persistence_id", sequenceNrColumnName: "sequence_nr", payloadColumnName: "payload", manifestColumnName: "manifest", timestampColumnName: "created_at", timeout: config.GetTimeSpan("connection-timeout")), Context.System.Serialization); }
/// <summary> /// Initializes a new instance of the <see cref="Settings" /> class. /// </summary> /// <param name="system">The system.</param> /// <param name="config">The configuration.</param> public Settings(ActorSystem system, Config config) { Config fallback = ConfigurationFactory.Default(); Config merged = config == null ? fallback : config.WithFallback(fallback); System = system; Config = merged; ConfigVersion = Config.GetString("akka.version"); ProviderClass = Config.GetString("akka.actor.provider"); var providerType = Type.GetType(ProviderClass); if (providerType == null) throw new ConfigurationException(string.Format("'akka.actor.provider' is not a valid type name : '{0}'", ProviderClass)); if (!typeof(ActorRefProvider).IsAssignableFrom(providerType)) throw new ConfigurationException(string.Format("'akka.actor.provider' is not a valid actor ref provider: '{0}'", ProviderClass)); SupervisorStrategyClass = Config.GetString("akka.actor.guardian-supervisor-strategy"); CreationTimeout = Config.GetMillisDuration("akka.actor.creation-timeout"); UnstartedPushTimeout = Config.GetMillisDuration("akka.actor.unstarted-push-timeout"); SerializeAllMessages = Config.GetBoolean("akka.actor.serialize-messages"); SerializeAllCreators = Config.GetBoolean("akka.actor.serialize-creators"); LogLevel = Config.GetString("akka.loglevel"); StdoutLogLevel = Config.GetString("akka.stdout-loglevel"); Loggers = Config.GetStringList("akka.loggers"); LoggerStartTimeout = Config.GetMillisDuration("akka.logger-startup-timeout"); //handled LogConfigOnStart = Config.GetBoolean("akka.log-config-on-start"); LogDeadLetters = 0; switch (Config.GetString("akka.log-dead-letters")) { case "on": case "true": LogDeadLetters = int.MaxValue; break; case "off": case "false": LogDeadLetters = 0; break; default: LogDeadLetters = Config.GetInt("akka.log-dead-letters"); break; } LogDeadLettersDuringShutdown = Config.GetBoolean("akka.log-dead-letters-during-shutdown"); AddLoggingReceive = Config.GetBoolean("akka.actor.debug.receive"); DebugAutoReceive = Config.GetBoolean("akka.actor.debug.autoreceive"); DebugLifecycle = Config.GetBoolean("akka.actor.debug.lifecycle"); DebugEventStream = Config.GetBoolean("akka.actor.debug.event-stream"); DebugUnhandledMessage = Config.GetBoolean("akka.actor.debug.unhandled"); DebugRouterMisConfiguration = Config.GetBoolean("akka.actor.debug.router-misconfiguration"); Home = Config.GetString("akka.home") ?? ""; //TODO: dunno.. we dont have FiniteStateMachines, dont know what the rest is /* final val FsmDebugEvent: Boolean = getBoolean("akka.actor.debug.fsm") final val SchedulerClass: String = getString("akka.scheduler.implementation") final val Daemonicity: Boolean = getBoolean("akka.daemonic") final val DefaultVirtualNodesFactor: Int = getInt("akka.actor.deployment.default.virtual-nodes-factor") */ }
protected ClusterSpecBase(Config config) : base(config.WithFallback(BaseConfig)) { }
public static Config operator +(string configHocon, Config fallbackConfig) { Config config = ConfigurationFactory.ParseString(configHocon); return(config.WithFallback(fallbackConfig)); }
public static Config SafeWithFallback(this Config config, Config fallback) { return(config == null ? fallback : ReferenceEquals(config, fallback) ? config : config.WithFallback(fallback)); }
private static AkkaConfig LoadConfig(string environment, string configFile, IConfiguration configuration) { string akkaip = configuration.GetSection("akkaip").Value ?? "127.0.0.1"; string akkaport = configuration.GetSection("akkaport").Value ?? "5100"; string akkaseed = configuration.GetSection("akkaseed").Value ?? "127.0.0.1:5100"; string roles = configuration.GetSection("roles").Value ?? "akkanet"; var configFilePath = string.Format(configFile, environment.ToLower() != "production" ? string.Concat(".", environment) : ""); if (File.Exists(configFilePath)) { string akkaseed_array; if (akkaseed.Split(",").Length > 1) { akkaseed_array = akkaseed.Split(",").Aggregate("[", (current, seed) => current + @"""" + seed + @""", "); akkaseed_array += "]"; } else { akkaseed_array = "[\"" + akkaseed + "\"]"; } string roles_array; if (roles.Split(",").Length > 1) { roles_array = roles.Split(",").Aggregate("[", (current, role) => current + @"""" + role + @""", "); roles_array += "]"; } else { roles_array = "[\"" + roles + "\"]"; } string customConfig = @" akka { remote { log-remote-lifecycle-events = debug dot-netty.tcp { port = $akkaport hostname = $akkaip } } cluster { seed-nodes = $akkaseed roles = $roles } } ".Replace("$akkaport", akkaport) .Replace("$akkaip", akkaip) .Replace("$akkaseed", akkaseed_array) .Replace("$roles", roles_array); AkkaConfig injectedClusterConfigString = customConfig; string configText = File.ReadAllText(configFilePath); var akkaConfig = ConfigurationFactory.ParseString(configText); var finalConfig = injectedClusterConfigString.WithFallback(akkaConfig); Console.WriteLine($"=== AkkaConfig:{configFilePath}\r\n{finalConfig}\r\n==="); return(finalConfig); } return(ConfigurationFactory.Empty); }
private static void CreateClusterNode(Config commonConfig, int port, params string[] roles) { var config = commonConfig .WithFallback("akka.remote.helios.tcp.port = " + port) .WithFallback("akka.cluster.roles = " + "[" + string.Join(",", roles) + "]"); var system = ActorSystem.Create("BasicCluster", config); var cluster = Cluster.Get(system); var clusterNode = new ClusterNode { Context = new ClusterNodeContext { System = system, ClusterActorDiscovery = system.ActorOf(Props.Create(() => new ClusterActorDiscovery(cluster)), "cluster_actor_discovery") }, Roles = roles }; InitClusterNode(clusterNode); _clusterNodes.Add(clusterNode); }
public static ActorSystem LaunchLighthouse(string ipAddress = null, int?specifiedPort = null, string systemName = null) { systemName = systemName ?? Environment.GetEnvironmentVariable("ACTORSYSTEM")?.Trim(); // Set environment variables for use inside Akka.Bootstrap.Docker // If overrides were provided to this method. //if (!string.IsNullOrEmpty(ipAddress)) Environment.SetEnvironmentVariable("CLUSTER_IP", ipAddress); //if (specifiedPort != null) // Environment.SetEnvironmentVariable("CLUSTER_PORT", specifiedPort.Value.ToString()); var useDocker = !(IsNullOrEmpty(Environment.GetEnvironmentVariable("CLUSTER_IP")?.Trim()) || IsNullOrEmpty(Environment.GetEnvironmentVariable("CLUSTER_SEEDS")?.Trim())); var clusterConfig = ConfigurationFactory.ParseString(File.ReadAllText("akka.hocon")); if (useDocker) { clusterConfig = clusterConfig.BootstrapFromDocker(); } var lighthouseConfig = clusterConfig.GetConfig("lighthouse"); if (lighthouseConfig != null && IsNullOrEmpty(systemName)) { systemName = lighthouseConfig.GetString("actorsystem", systemName); } ipAddress = clusterConfig.GetString("akka.remote.dot-netty.tcp.public-hostname", "127.0.0.1"); var port = clusterConfig.GetInt("akka.remote.dot-netty.tcp.port"); var sslEnabled = clusterConfig.GetBoolean("akka.remote.dot-netty.tcp.enable-ssl"); var selfAddress = sslEnabled ? new Address("akka.ssl.tcp", systemName, ipAddress.Trim(), port).ToString() : new Address("akka.tcp", systemName, ipAddress.Trim(), port).ToString(); /* * Sanity check */ Console.WriteLine($"[Lighthouse] ActorSystem: {systemName}; IP: {ipAddress}; PORT: {port}"); Console.WriteLine("[Lighthouse] Performing pre-boot sanity check. Should be able to parse address [{0}]", selfAddress); Console.WriteLine("[Lighthouse] Parse successful."); var seeds = clusterConfig.GetStringList("akka.cluster.seed-nodes").ToList(); AkkaConfig injectedClusterConfigString = null; if (!seeds.Contains(selfAddress)) { seeds.Add(selfAddress); if (seeds.Count > 1) { injectedClusterConfigString = seeds.Aggregate("akka.cluster.seed-nodes = [", (current, seed) => current + @"""" + seed + @""", "); injectedClusterConfigString += "]"; } else { injectedClusterConfigString = "akka.cluster.seed-nodes = [\"" + selfAddress + "\"]"; } } var finalConfig = injectedClusterConfigString != null ? injectedClusterConfigString .WithFallback(clusterConfig) : clusterConfig; return(ActorSystem.Create(systemName, finalConfig)); }
public override Deploy ParseConfig(string key, Config config) { Config config2 = config; if (config.HasPath("cluster.enabled") && config.GetBoolean("cluster.enabled") && !config.HasPath("nr-of-instances")) { var maxTotalNrOfInstances = config .WithFallback(Default) .GetInt("cluster.max-total-nr-of-instances"); config2 = ConfigurationFactory.ParseString("nr-of-instances=" + maxTotalNrOfInstances) .WithFallback(config); } var deploy = base.ParseConfig(key, config2); if (deploy != null) { if (deploy.Config.GetBoolean("cluster.enabled")) { if (deploy.Scope != Deploy.NoScopeGiven) throw new ConfigurationException(string.Format("Cluster deployment can't be combined with scope [{0}]", deploy.Scope)); if (deploy.RouterConfig is RemoteRouterConfig) throw new ConfigurationException(string.Format("Cluster deployment can't be combined with [{0}]", deploy.Config)); if (deploy.RouterConfig is Pool) { return deploy.WithScope(scope: ClusterScope.Instance) .WithRouterConfig(new ClusterRouterPool(deploy.RouterConfig as Pool, ClusterRouterPoolSettings.FromConfig(deploy.Config))); } else if (deploy.RouterConfig is Group) { return deploy.WithScope(scope: ClusterScope.Instance) .WithRouterConfig(new ClusterRouterGroup(deploy.RouterConfig as Group, ClusterRouterGroupSettings.FromConfig(deploy.Config))); } else { throw new ArgumentException(string.Format("Cluster-aware router can only wrap Pool or Group, got [{0}]", deploy.RouterConfig.GetType())); } } else { return deploy; } } else { return null; } }