/// <summary> /// Creates a new <see cref="TimeoutSettings"/> instance. /// </summary> /// <param name="config">Lease config</param> /// <returns>The requested settings.</returns> public static TimeoutSettings Create(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <TimeoutSettings>(); } var heartBeatTimeout = config.GetTimeSpan("heartbeat-timeout"); TimeSpan heartBeatInterval; var iv = config.GetValue("heartbeat-interval"); if (iv.IsString() && string.IsNullOrEmpty(iv.GetString())) { heartBeatInterval = TimeSpan.FromMilliseconds(Math.Max(heartBeatTimeout.TotalMilliseconds / 10, 5000)); } else { heartBeatInterval = iv.GetTimeSpan(); } if (heartBeatInterval.TotalMilliseconds >= (heartBeatTimeout.TotalMilliseconds / 2)) { throw new ArgumentException("heartbeat-interval must be less than half heartbeat-timeout"); } return(new TimeoutSettings(heartBeatInterval, heartBeatTimeout, config.GetTimeSpan("lease-operation-timeout"))); }
private IBufferPool CreateBufferPool(ExtendedActorSystem system, Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <IBufferPool>(); } var type = Type.GetType(config.GetString("class", null), true); if (!typeof(IBufferPool).IsAssignableFrom(type)) { throw new ArgumentException($"Buffer pool of type {type} doesn't implement {nameof(IBufferPool)} interface"); } try { // try to construct via `BufferPool(ExtendedActorSystem, Config)` ctor return((IBufferPool)Activator.CreateInstance(type, system, config)); } catch { // try to construct via `BufferPool(ExtendedActorSystem)` ctor return((IBufferPool)Activator.CreateInstance(type, system)); } }
/// <summary> /// Creates a new AkkaProtocolSettings instance. /// </summary> /// <param name="config">The HOCON configuration.</param> public AkkaProtocolSettings(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <AkkaProtocolSettings>(); } TransportFailureDetectorConfig = config.GetConfig("akka.remote.transport-failure-detector"); TransportFailureDetectorImplementationClass = TransportFailureDetectorConfig.GetString("implementation-class", null); TransportHeartBeatInterval = TransportFailureDetectorConfig.GetTimeSpan("heartbeat-interval", null); // backwards compatibility with the existing dot-netty.tcp.connection-timeout var enabledTransports = config.GetStringList("akka.remote.enabled-transports", new string[] { }); if (enabledTransports.Contains("akka.remote.dot-netty.tcp")) { HandshakeTimeout = config.GetTimeSpan("akka.remote.dot-netty.tcp.connection-timeout", null); } else if (enabledTransports.Contains("akka.remote.dot-netty.ssl")) { HandshakeTimeout = config.GetTimeSpan("akka.remote.dot-netty.ssl.connection-timeout", null); } else { HandshakeTimeout = config.GetTimeSpan("akka.remote.handshake-timeout", TimeSpan.FromSeconds(20), allowInfinite: false); } }
/// <summary> /// Create settings from a configuration with the same layout as the default configuration 'akka.cluster.client'. /// </summary> /// <param name="config">TBD</param> /// <returns>TBD</returns> public static ClusterClientSettings Create(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <ClusterClientSettings>(); } var initialContacts = config.GetStringList("initial-contacts", new string[] { }).Select(ActorPath.Parse).ToImmutableSortedSet(); var useReconnect = config.GetString("reconnect-timeout", "").ToLowerInvariant(); TimeSpan?reconnectTimeout = useReconnect.Equals("off") || useReconnect.Equals("false") || useReconnect.Equals("no") ? null : (TimeSpan?)config.GetTimeSpan("reconnect-timeout"); return(new ClusterClientSettings(initialContacts, config.GetTimeSpan("establishing-get-contacts-interval"), config.GetTimeSpan("refresh-contacts-interval"), config.GetTimeSpan("heartbeat-interval"), config.GetTimeSpan("acceptable-heartbeat-pause"), config.GetInt("buffer-size"), reconnectTimeout)); }
/// <summary> /// TBD /// </summary> /// <param name="config">TBD</param> /// <exception cref="ArgumentException">TBD</exception> /// <returns>TBD</returns> public static StreamSubscriptionTimeoutSettings Create(Config config) { // No need to check for Config.IsEmpty because this function expects empty Config. if (config == null) { throw ConfigurationException.NullOrEmptyConfig <StreamSubscriptionTimeoutSettings>(); } var c = config.GetConfig("subscription-timeout"); var configMode = c.GetString("mode", "cancel").ToLowerInvariant(); StreamSubscriptionTimeoutTerminationMode mode; switch (configMode) { case "no": case "off": case "false": case "noop": mode = StreamSubscriptionTimeoutTerminationMode.NoopTermination; break; case "warn": mode = StreamSubscriptionTimeoutTerminationMode.WarnTermination; break; case "cancel": mode = StreamSubscriptionTimeoutTerminationMode.CancelTermination; break; default: throw new ArgumentException("akka.stream.materializer.subscribtion-timeout.mode was not defined or has invalid value. Valid values are: no, off, false, noop, warn, cancel"); } return(new StreamSubscriptionTimeoutSettings( mode: mode, timeout: c.GetTimeSpan("timeout", TimeSpan.FromSeconds(5)))); }
/// <summary> /// Creates a new instance of <see cref="TcpSettings"/> class /// and fills it with values parsed from provided HOCON config. /// </summary> /// <param name="config">TBD</param> public static TcpSettings Create(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <TcpSettings>(); } return(new TcpSettings( bufferPoolConfigPath: config.GetString("buffer-pool", "akka.io.tcp.direct-buffer-pool"), initialSocketAsyncEventArgs: config.GetInt("nr-of-socket-async-event-args", 32), traceLogging: config.GetBoolean("trace-logging", false), batchAcceptLimit: config.GetInt("batch-accept-limit", 10), registerTimeout: config.GetTimeSpan("register-timeout", TimeSpan.FromSeconds(5)), receivedMessageSizeLimit: config.GetString("max-received-message-size", "unlimited") == "unlimited" ? int.MaxValue : config.GetInt("max-received-message-size", 0), managementDispatcher: config.GetString("management-dispatcher", "akka.actor.default-dispatcher"), fileIoDispatcher: config.GetString("file-io-dispatcher", "akka.actor.default-dispatcher"), transferToLimit: config.GetString("file-io-transferTo-limit", null) == "unlimited" ? int.MaxValue : config.GetInt("file-io-transferTo-limit", 512 * 1024), finishConnectRetries: config.GetInt("finish-connect-retries", 5), outgoingSocketForceIpv4: config.GetBoolean("outgoing-socket-force-ipv4", false), writeCommandsQueueMaxSize: config.GetInt("write-commands-queue-max-size", -1))); }
/// <summary> /// Builds <see cref="IMetricsSelector"/> defined in configuration /// </summary> /// <returns></returns> public static IMetricsSelector BuildFromConfig(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <IMetricsSelector>(); } var selectorTypeName = config.GetString("metrics-selector"); switch (selectorTypeName) { case "mix": return(MixMetricsSelector.Instance); case "memory": return(MemoryMetricsSelector.Instance); case "cpu": return(CpuMetricsSelector.Instance); default: return(DynamicAccess.CreateInstanceFor <IMetricsSelector>(selectorTypeName, config) .Recover(ex => throw new ArgumentException($"Cannot instantiate metrics-selector [{selectorTypeName}]," + $"make sure it extends [Akka.Cluster.Metrics.MetricsSelector] and " + $"has constructor with [Akka.Configuration.Config] parameter", ex)) .Get()); } }
/// <summary> /// Creates instance of <see cref="ClusterMetricsSettings"/> /// </summary> public ClusterMetricsSettings(Config config) { _config = config.GetConfig("akka.cluster.metrics"); if (_config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <ClusterMetricsSettings>("akka.cluster.metrics"); } MetricsDispatcher = _config.GetString("dispatcher"); PeriodicTasksInitialDelay = _config.GetTimeSpan("periodic-tasks-initial-delay"); SupervisorName = _config.GetString("supervisor.name"); SupervisorStrategyProvider = _config.GetString("supervisor.strategy.provider"); SupervisorStrategyConfiguration = _config.GetConfig("supervisor.strategy.configuration"); CollectorEnabled = _config.GetBoolean("collector.enabled"); CollectorProvider = _config.GetString("collector.provider"); CollectorFallback = _config.GetBoolean("collector.fallback"); CollectorSampleInterval = Requiring(_config.GetTimeSpan("collector.sample-interval", null), t => t > TimeSpan.Zero, "collector.sample-interval must be > 0"); CollectorGossipInterval = Requiring(_config.GetTimeSpan("collector.gossip-interval", null), t => t > TimeSpan.Zero, "collector.gossip-interval must be > 0"); CollectorMovingAverageHalfLife = Requiring(_config.GetTimeSpan("collector.moving-average-half-life", null), t => t > TimeSpan.Zero, "collector.moving-average-half-life must be > 0"); }
private readonly long _tickDuration; // a timespan expressed as ticks /// <summary> /// TBD /// </summary> /// <param name="scheduler">TBD</param> /// <param name="log">TBD</param> /// <exception cref="ArgumentOutOfRangeException">TBD</exception> public HashedWheelTimerScheduler(Config scheduler, ILoggingAdapter log) : base(scheduler, log) { if (SchedulerConfig.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <HashedWheelTimerScheduler>(); } var ticksPerWheel = SchedulerConfig.GetInt("akka.scheduler.ticks-per-wheel", 0); var tickDuration = SchedulerConfig.GetTimeSpan("akka.scheduler.tick-duration", null); if (tickDuration.TotalMilliseconds < 10.0d) { throw new ArgumentOutOfRangeException("minimum supported akka.scheduler.tick-duration on Windows is 10ms"); } // convert tick-duration to ticks _tickDuration = tickDuration.Ticks; // Normalize ticks per wheel to power of two and create the wheel _wheel = CreateWheel(ticksPerWheel, log); _mask = _wheel.Length - 1; // prevent overflow if (_tickDuration >= long.MaxValue / _wheel.Length) { throw new ArgumentOutOfRangeException("akka.scheduler.tick-duration", _tickDuration, $"akka.scheduler.tick-duration: {_tickDuration} (expected: 0 < tick-duration in ticks < {long.MaxValue / _wheel.Length}"); } _shutdownTimeout = SchedulerConfig.GetTimeSpan("akka.scheduler.shutdown-timeout", null); }
/// <summary> /// Initializes a new instance of the <see cref="Mailboxes" /> class. /// </summary> /// <param name="system">The system.</param> public Mailboxes(ActorSystem system) { _system = system; _deadLetterMailbox = new DeadLetterMailbox(system.DeadLetters); var mailboxConfig = system.Settings.Config.GetConfig("akka.actor.mailbox"); if (mailboxConfig.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <Mailboxes>("akka.actor.mailbox"); } var requirements = mailboxConfig.GetConfig("requirements").AsEnumerable().ToList(); _mailboxBindings = new Dictionary <Type, string>(); foreach (var kvp in requirements) { var type = Type.GetType(kvp.Key); if (type == null) { Warn($"Mailbox Requirement mapping [{kvp.Key}] is not an actual type"); continue; } _mailboxBindings.Add(type, kvp.Value.GetString()); } _defaultMailboxConfig = Settings.Config.GetConfig(DefaultMailboxId); }
public static DotNettyTransportSettings Create(ActorSystem system) { var config = system.Settings.Config.GetConfig("akka.remote.dot-netty.tcp"); if (config.IsNullOrEmpty()) throw ConfigurationException.NullOrEmptyConfig<DotNettyTransportSettings>("akka.remote.dot-netty.tcp"); return Create(config); }
private MessageDispatcherConfigurator ConfiguratorFrom(Config cfg) { if (cfg.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <MessageDispatcherConfigurator>(); } if (!cfg.HasPath("id")) { throw new ConfigurationException($"Missing dispatcher `id` property in config: {cfg.Root}"); } var id = cfg.GetString("id", null); var type = cfg.GetString("type", null); MessageDispatcherConfigurator dispatcher; /* * Fallbacks are added here in order to preserve backwards compatibility with versions of AKka.NET prior to 1.1, * before the ExecutorService system was implemented */ switch (type) { case "Dispatcher": dispatcher = new DispatcherConfigurator(cfg, Prerequisites); break; case "TaskDispatcher": dispatcher = new DispatcherConfigurator(TaskExecutorConfig.WithFallback(cfg), Prerequisites); break; case "PinnedDispatcher": dispatcher = new PinnedDispatcherConfigurator(cfg, Prerequisites); break; case "ForkJoinDispatcher": dispatcher = new DispatcherConfigurator(ForkJoinExecutorConfig.WithFallback(cfg), Prerequisites); break; case "SynchronizedDispatcher": dispatcher = new CurrentSynchronizationContextDispatcherConfigurator(cfg, Prerequisites); break; case null: throw new ConfigurationException($"Could not resolve dispatcher for path {id}. type is null"); default: Type dispatcherType = Type.GetType(type); if (dispatcherType == null) { throw new ConfigurationException($"Could not resolve dispatcher type {type} for path {id}"); } dispatcher = (MessageDispatcherConfigurator)Activator.CreateInstance(dispatcherType, cfg, Prerequisites); break; } return(dispatcher); }
public static DotNettyTransportSettings Create(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <DotNettyTransportSettings>(); } var transportMode = config.GetString("transport-protocol", "tcp").ToLower(); var host = config.GetString("hostname", null); if (string.IsNullOrEmpty(host)) { host = IPAddress.Any.ToString(); } var publicHost = config.GetString("public-hostname", null); var publicPort = config.GetInt("public-port", 0); var order = ByteOrder.LittleEndian; var byteOrderString = config.GetString("byte-order", "little-endian").ToLowerInvariant(); switch (byteOrderString) { case "little-endian": order = ByteOrder.LittleEndian; break; case "big-endian": order = ByteOrder.BigEndian; break; default: throw new ArgumentException($"Unknown byte-order option [{byteOrderString}]. Supported options are: big-endian, little-endian."); } var batchWriterSettings = new BatchWriterSettings(config.GetConfig("batching")); return(new DotNettyTransportSettings( transportMode: transportMode == "tcp" ? TransportMode.Tcp : TransportMode.Udp, enableSsl: config.GetBoolean("enable-ssl", false), connectTimeout: config.GetTimeSpan("connection-timeout", TimeSpan.FromSeconds(15)), hostname: host, publicHostname: !string.IsNullOrEmpty(publicHost) ? publicHost : host, port: config.GetInt("port", 2552), publicPort: publicPort > 0 ? publicPort : (int?)null, serverSocketWorkerPoolSize: ComputeWorkerPoolSize(config.GetConfig("server-socket-worker-pool")), clientSocketWorkerPoolSize: ComputeWorkerPoolSize(config.GetConfig("client-socket-worker-pool")), maxFrameSize: ToNullableInt(config.GetByteSize("maximum-frame-size", null)) ?? 128000, ssl: config.HasPath("ssl") ? SslSettings.Create(config.GetConfig("ssl")) : SslSettings.Empty, dnsUseIpv6: config.GetBoolean("dns-use-ipv6", false), tcpReuseAddr: ResolveTcpReuseAddrOption(config.GetString("tcp-reuse-addr", "off-for-windows")), tcpKeepAlive: config.GetBoolean("tcp-keepalive", true), tcpNoDelay: config.GetBoolean("tcp-nodelay", true), backlog: config.GetInt("backlog", 4096), enforceIpFamily: RuntimeDetector.IsMono || config.GetBoolean("enforce-ip-family", false), receiveBufferSize: ToNullableInt(config.GetByteSize("receive-buffer-size", null) ?? 256000), sendBufferSize: ToNullableInt(config.GetByteSize("send-buffer-size", null) ?? 256000), writeBufferHighWaterMark: ToNullableInt(config.GetByteSize("write-buffer-high-water-mark", null)), writeBufferLowWaterMark: ToNullableInt(config.GetByteSize("write-buffer-low-water-mark", null)), backwardsCompatibilityModeEnabled: config.GetBoolean("enable-backwards-compatibility", false), logTransport: config.HasPath("log-transport") && config.GetBoolean("log-transport", false), byteOrder: order, enableBufferPooling: config.GetBoolean("enable-pooling", true), batchWriterSettings: batchWriterSettings)); }
private RouterConfig CreateRouterConfig(string routerTypeAlias, Config deployment) { if (routerTypeAlias == "from-code") { return(NoRouter.Instance); } if (deployment.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <RouterConfig>(); } var path = string.Format("akka.actor.router.type-mapping.{0}", routerTypeAlias); var routerTypeName = _settings.Config.GetString(path, null); if (routerTypeName == null) { var message = $"Could not find type mapping for router alias [{routerTypeAlias}]."; if (routerTypeAlias == "cluster-metrics-adaptive-group" || routerTypeAlias == "cluster-metrics-adaptive-pool") { message += " Please install Akka.Cluster.Metrics extension nuget package."; } else { message += " Did you forgot to install a specific router extension?"; } throw new ConfigurationException(message); } Type routerType; try { routerType = Type.GetType(routerTypeName); } catch (ArgumentNullException e) { var message = $"Could not find extension Type [{routerTypeAlias}] for router alias [{routerTypeAlias}]."; if (routerTypeAlias == "cluster-metrics-adaptive-group" || routerTypeAlias == "cluster-metrics-adaptive-pool") { message += " Please install Akka.Cluster.Metrics extension nuget package."; } else { message += " Did you forgot to install a specific router extension?"; } throw new ConfigurationException(message, e); } Debug.Assert(routerType != null, "routerType != null"); var routerConfig = (RouterConfig)Activator.CreateInstance(routerType, deployment); return(routerConfig); }
/// <summary> /// Creates a new <see cref="LeaseSettings"/> instance. /// </summary> /// <param name="config">Lease config</param> /// <param name="leaseName">Lease name</param> /// <param name="ownerName">Lease owner</param> /// <returns>The requested settings.</returns> public static LeaseSettings Create(Config config, string leaseName, string ownerName) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <LeaseSettings>(); } return(new LeaseSettings(leaseName, ownerName, TimeoutSettings.Create(config), config)); }
/// <summary> /// Creates a new instance of <see cref="TcpSettings"/> class /// and fills it with values parsed from `akka.io.tcp` HOCON /// path found in actor system. /// </summary> public static TcpSettings Create(ActorSystem system) { var config = system.Settings.Config.GetConfig("akka.io.tcp"); if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <TcpSettings>("akka.io.tcp");//($"Failed to create {typeof(TcpSettings)}: akka.io.tcp configuration node not found"); } return(Create(config)); }
/// <summary> /// Create settings from the default configuration `akka.cluster.distributed-data`. /// </summary> /// <param name="system">TBD</param> /// <returns>TBD</returns> public static ReplicatorSettings Create(ActorSystem system) { var config = system.Settings.Config.GetConfig("akka.cluster.distributed-data"); if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <ReplicatorSettings>("akka.cluster.distributed-data"); } return(Create(config)); }
/// <summary> /// TBD /// </summary> /// <param name="config">TBD</param> public TransportSettings(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <TransportSettings>(); } TransportClass = config.GetString("transport-class", null); Adapters = config.GetStringList("applied-adapters", new string[] { }).Reverse().ToList(); Config = config; }
private static EventAdapters CreateAdapters(ExtendedActorSystem system, string configPath) { var pluginConfig = system.Settings.Config.GetConfig(configPath); if (pluginConfig.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <EventAdapters>(configPath); } return(EventAdapters.Create(system, pluginConfig)); }
/// <summary> /// Creates a new instance of <see cref="UdpSettings"/> class /// and fills it with values parsed from `akka.io.udp` HOCON /// path found in actor system. /// </summary> public static UdpSettings Create(ActorSystem system) { var config = system.Settings.Config.GetConfig("akka.io.udp"); if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <UdpSettings>("akka.io.udp"); } return(Create(config)); }
/// <summary> /// Create settings from the default configuration 'akka.cluster.client'. /// </summary> /// <param name="system">TBD</param> /// <exception cref="ArgumentException">TBD</exception> /// <returns>TBD</returns> public static ClusterClientSettings Create(ActorSystem system) { system.Settings.InjectTopLevelFallback(ClusterClientReceptionist.DefaultConfig()); var config = system.Settings.Config.GetConfig("akka.cluster.client"); if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <ClusterClientSettings>("akka.cluster.client");//($"Failed to create {nameof(ClusterClientSettings)}: Actor system [{system.Name}] doesn't have `akka.cluster.client` config set up"); } return(Create(config)); }
/// <summary> /// TBD /// </summary> /// <param name="system">TBD</param> /// <returns>TBD</returns> public static ActorMaterializerSettings Create(ActorSystem system) { var config = system.Settings.Config.GetConfig("akka.stream.materializer"); // No need to check for Config.IsEmpty because this function expects empty Config. if (config == null) { throw ConfigurationException.NullOrEmptyConfig <ActorMaterializerSettings>("akka.stream.materializer"); } return(Create(config)); }
/// <summary> /// TBD /// </summary> /// <param name="system">TBD</param> /// <exception cref="ConfigurationException">TBD</exception> /// <returns>TBD</returns> public static ClusterSingletonProxySettings Create(ActorSystem system) { system.Settings.InjectTopLevelFallback(ClusterSingletonManager.DefaultConfig()); var config = system.Settings.Config.GetConfig("akka.cluster.singleton-proxy"); if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <ClusterSingletonProxySettings>("akka.cluster.singleton-proxy"); } return(Create(config)); }
/// <summary> /// TBD /// </summary> /// <param name="config">TBD</param> public DnsSettings(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <DnsSettings>(); } Dispatcher = config.GetString("dispatcher", null); Resolver = config.GetString("resolver", null); ResolverConfig = config.GetConfig(Resolver); ProviderObjectName = ResolverConfig.GetString("provider-object", null); }
/// <summary> /// Creates a new instance of the <see cref="NewtonSoftJsonSerializerSettings"/> based on a provided <paramref name="config"/>. /// Config may define several key-values: /// <ul> /// <li>`encode-type-names` (boolean) mapped to <see cref="EncodeTypeNames"/></li> /// <li>`preserve-object-references` (boolean) mapped to <see cref="PreserveObjectReferences"/></li> /// <li>`converters` (type list) mapped to <see cref="Converters"/>. They must implement <see cref="JsonConverter"/> and define either default constructor or constructor taking <see cref="ExtendedActorSystem"/> as its only parameter.</li> /// </ul> /// </summary> /// <exception cref="ArgumentNullException">Raised when no <paramref name="config"/> was provided.</exception> /// <exception cref="ArgumentException">Raised when types defined in `converters` list didn't inherit <see cref="JsonConverter"/>.</exception> public static NewtonSoftJsonSerializerSettings Create(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <NewtonSoftJsonSerializerSettings>(); } return(new NewtonSoftJsonSerializerSettings( encodeTypeNames: config.GetBoolean("encode-type-names", true), preserveObjectReferences: config.GetBoolean("preserve-object-references", true), converters: GetConverterTypes(config))); }
/// <summary> /// TBD /// </summary> /// <param name="config">TBD</param> /// <param name="singletonConfig">TBD</param> /// <returns>TBD</returns> public static ClusterShardingSettings Create(Config config, Config singletonConfig) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <ClusterShardingSettings>(); } var tuningParameters = new TunningParameters( coordinatorFailureBackoff: config.GetTimeSpan("coordinator-failure-backoff"), retryInterval: config.GetTimeSpan("retry-interval"), bufferSize: config.GetInt("buffer-size"), handOffTimeout: config.GetTimeSpan("handoff-timeout"), shardStartTimeout: config.GetTimeSpan("shard-start-timeout"), shardFailureBackoff: config.GetTimeSpan("shard-failure-backoff"), entityRestartBackoff: config.GetTimeSpan("entity-restart-backoff"), rebalanceInterval: config.GetTimeSpan("rebalance-interval"), snapshotAfter: config.GetInt("snapshot-after"), keepNrOfBatches: config.GetInt("keep-nr-of-batches"), leastShardAllocationRebalanceThreshold: config.GetInt("least-shard-allocation-strategy.rebalance-threshold"), leastShardAllocationMaxSimultaneousRebalance: config.GetInt("least-shard-allocation-strategy.max-simultaneous-rebalance"), waitingForStateTimeout: config.GetTimeSpan("waiting-for-state-timeout"), updatingStateTimeout: config.GetTimeSpan("updating-state-timeout"), entityRecoveryStrategy: config.GetString("entity-recovery-strategy"), entityRecoveryConstantRateStrategyFrequency: config.GetTimeSpan("entity-recovery-constant-rate-strategy.frequency"), entityRecoveryConstantRateStrategyNumberOfEntities: config.GetInt("entity-recovery-constant-rate-strategy.number-of-entities")); var coordinatorSingletonSettings = ClusterSingletonManagerSettings.Create(singletonConfig); var role = config.GetString("role", null); if (role == string.Empty) { role = null; } var usePassivateIdle = config.GetString("passivate-idle-entity-after").ToLowerInvariant(); var passivateIdleAfter = usePassivateIdle.Equals("off") || usePassivateIdle.Equals("false") || usePassivateIdle.Equals("no") ? TimeSpan.Zero : config.GetTimeSpan("passivate-idle-entity-after"); return(new ClusterShardingSettings( role: role, rememberEntities: config.GetBoolean("remember-entities"), journalPluginId: config.GetString("journal-plugin-id"), snapshotPluginId: config.GetString("snapshot-plugin-id"), passivateIdleEntityAfter: passivateIdleAfter, stateStoreMode: (StateStoreMode)Enum.Parse(typeof(StateStoreMode), config.GetString("state-store-mode"), ignoreCase: true), tunningParameters: tuningParameters, coordinatorSingletonSettings: coordinatorSingletonSettings)); }
/// <summary> /// Create settings from the default configuration `akka.cluster.sharding`. /// </summary> /// <param name="system">TBD</param> /// <returns>TBD</returns> public static ClusterShardingSettings Create(ActorSystem system) { var config = system.Settings.Config.GetConfig("akka.cluster.sharding"); if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <ClusterShardingSettings>("akka.cluster.sharding"); } var coordinatorSingletonPath = config.GetString("coordinator-singleton"); return(Create(config, system.Settings.Config.GetConfig(coordinatorSingletonPath))); }
/// <summary> /// Creates a new <see cref="ClusterSingletonManagerSettings"/> instance. /// </summary> /// <param name="system">The <see cref="ActorSystem"/> to which this singleton manager belongs.</param> /// <exception cref="ConfigurationException">Thrown if no "akka.cluster.singleton" section is defined.</exception> /// <returns>The requested settings.</returns> public static ClusterSingletonManagerSettings Create(ActorSystem system) { system.Settings.InjectTopLevelFallback(ClusterSingletonManager.DefaultConfig()); var config = system.Settings.Config.GetConfig("akka.cluster.singleton"); if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <ClusterSingletonManagerSettings>("akka.cluster.singleton"); } return(Create(config).WithRemovalMargin(Cluster.Get(system).DowningProvider.DownRemovalMargin)); }
public SplitBrainResolver(ActorSystem system) { _clusterSettings = Cluster.Get(system).Settings; var config = system.Settings.Config.GetConfig("akka.cluster.split-brain-resolver"); if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <SplitBrainResolver>("akka.cluster.split-brain-resolver"); } StableAfter = config.GetTimeSpan("stable-after", null); Strategy = ResolveSplitBrainStrategy(config); }
/// <summary> /// TBD /// </summary> /// <returns>TBD</returns> public override MessageDispatcher Dispatcher() { if (Config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <MessageDispatcher>(); } return(new CurrentSynchronizationContextDispatcher(this, Config.GetString("id", null), Config.GetInt("throughput", 0), Config.GetTimeSpan("throughput-deadline-time", null).Ticks, _executorServiceConfigurator, Config.GetTimeSpan("shutdown-timeout", null))); }