GetTimeSpan() публичный Метод

Retrieves a TimeSpan value from the specified path in the configuration.
public GetTimeSpan ( string path, System.TimeSpan @default = null, bool allowInfinite = true ) : System.TimeSpan
path string The path that contains the value to retrieve.
@default System.TimeSpan
allowInfinite bool true if infinite timespans are allowed; otherwise false.
Результат System.TimeSpan
        /// <summary>
        /// Creates cluster publish subscribe settings from provided configuration with the same layout as `akka.cluster.pub-sub`.
        /// </summary>
        public static DistributedPubSubSettings Create(Config config)
        {
            RoutingLogic routingLogic = null;
            var routingLogicName = config.GetString("routing-logic");
            switch (routingLogicName)
            {
                case "random":
                    routingLogic = new RandomLogic();
                    break;
                case "round-robin":
                    routingLogic = new RoundRobinRoutingLogic();
                    break;
                case "broadcast":
                    routingLogic = new BroadcastRoutingLogic();
                    break;
                case "consistent-hashing":
                    throw new ArgumentException("Consistent hashing routing logic cannot be used by the pub-sub mediator");
                default:
                    throw new ArgumentException("Unknown routing logic is tried to be applied to the pub-sub mediator: " +
                                                routingLogicName);
            }

            return new DistributedPubSubSettings(
                config.GetString("role"),
                routingLogic,
                config.GetTimeSpan("gossip-interval"),
                config.GetTimeSpan("removed-time-to-live"),
                config.GetInt("max-delta-elements"));
        }
 /// <summary>
 /// Constructor that reads parameters from config.
 /// Expecting config properties named 'threshold', 'max-sample-size',
 /// 'min-std-deviation', 'acceptable-heartbeat-pause', and 'heartbeat-interval'.
 /// </summary>
 public PhiAccrualFailureDetector(Config config, EventStream ev)
     : this(DefaultClock)
 {
     _threshold = config.GetDouble("threshold");
     _maxSampleSize = config.GetInt("max-sample-size");
     _minStdDeviation = config.GetTimeSpan("min-std-deviation");
     _acceptableHeartbeatPause = config.GetTimeSpan("acceptable-heartbeat-pause");
     _firstHeartbeatEstimate = config.GetTimeSpan("heartbeat-interval");
     state = new State(FirstHeartBeat, null);
 }
Пример #3
0
        public TestKitSettings(Config config)
        {
            _defaultTimeout = config.GetTimeSpan("akka.test.default-timeout", allowInfinite:false);
            _singleExpectDefault = config.GetTimeSpan("akka.test.single-expect-default", allowInfinite: false);
            _testEventFilterLeeway = config.GetTimeSpan("akka.test.filter-leeway", allowInfinite: false);
            _timefactor = config.GetDouble("akka.test.timefactor");
            _logTestKitCalls = config.GetBoolean("akka.test.testkit.debug");

            if(_timefactor <= 0)
                throw new ConfigurationException(@"Expected a positive value for ""akka.test.timefactor"" but found " + _timefactor);
        }
Пример #4
0
        public ClusterSettings(Config config, string systemName)
        {
            //TODO: Requiring!
            var cc = config.GetConfig("akka.cluster");
            LogInfo = cc.GetBoolean("log-info");
            _failureDetectorConfig = cc.GetConfig("failure-detector");
            FailureDetectorImplementationClass = _failureDetectorConfig.GetString("implementation-class");
            HeartbeatInterval = _failureDetectorConfig.GetTimeSpan("heartbeat-interval");
            HeartbeatExpectedResponseAfter = _failureDetectorConfig.GetTimeSpan("expected-response-after");
            MonitoredByNrOfMembers = _failureDetectorConfig.GetInt("monitored-by-nr-of-members");

            SeedNodes = cc.GetStringList("seed-nodes").Select(Address.Parse).ToImmutableList();
            SeedNodeTimeout = cc.GetTimeSpan("seed-node-timeout");
            RetryUnsuccessfulJoinAfter = cc.GetTimeSpanWithOffSwitch("retry-unsuccessful-join-after");
            PeriodicTasksInitialDelay = cc.GetTimeSpan("periodic-tasks-initial-delay");
            GossipInterval = cc.GetTimeSpan("gossip-interval");
            GossipTimeToLive = cc.GetTimeSpan("gossip-time-to-live");
            LeaderActionsInterval = cc.GetTimeSpan("leader-actions-interval");
            UnreachableNodesReaperInterval = cc.GetTimeSpan("unreachable-nodes-reaper-interval");
            PublishStatsInterval = cc.GetTimeSpanWithOffSwitch("publish-stats-interval");

            var key = "down-removal-margin";
            DownRemovalMargin = cc.GetString(key).ToLowerInvariant().Equals("off") 
                ? TimeSpan.Zero
                : cc.GetTimeSpan("down-removal-margin");

            AutoDownUnreachableAfter = cc.GetTimeSpanWithOffSwitch("auto-down-unreachable-after");

            Roles = cc.GetStringList("roles").ToImmutableHashSet();
            MinNrOfMembers = cc.GetInt("min-nr-of-members");
            //TODO:
            //_minNrOfMembersOfRole = cc.GetConfig("role").Root.GetArray().ToImmutableDictionary(o => o. )
            _useDispatcher = cc.GetString("use-dispatcher");
            if (String.IsNullOrEmpty(_useDispatcher)) _useDispatcher = Dispatchers.DefaultDispatcherId;
            GossipDifferentViewProbability = cc.GetDouble("gossip-different-view-probability");
            ReduceGossipDifferentViewProbability = cc.GetInt("reduce-gossip-different-view-probability");
            SchedulerTickDuration = cc.GetTimeSpan("scheduler.tick-duration");
            SchedulerTicksPerWheel = cc.GetInt("scheduler.ticks-per-wheel");

            MinNrOfMembersOfRole = cc.GetConfig("role").Root.GetObject().Items
                .ToImmutableDictionary(kv => kv.Key, kv => kv.Value.GetObject().GetKey("min-nr-of-members").GetInt());

            VerboseHeartbeatLogging = cc.GetBoolean("debug.verbose-heartbeat-logging");

            var downingProviderClassName = cc.GetString("downing-provider-class");
            if (!string.IsNullOrEmpty(downingProviderClassName))
                DowningProviderType = Type.GetType(downingProviderClassName, true);
            else if (AutoDownUnreachableAfter.HasValue)
                DowningProviderType = typeof(AutoDowning);
            else
                DowningProviderType = typeof(NoDowning);
        }
        /// <summary>
        /// Create settings from a configuration with the same layout as the default configuration "akka.cluster.client.receptionist".
        /// </summary>
        public static ClusterReceptionistSettings Create(Config config)
        {
            var role = config.GetString("role");
            if (string.IsNullOrEmpty(role)) role = null;

            return new ClusterReceptionistSettings(
                role,
                config.GetInt("number-of-contacts"),
                config.GetTimeSpan("response-tunnel-receive-timeout"),
                config.GetTimeSpan("heartbeat-interval"),
                config.GetTimeSpan("acceptable-heartbeat-pause"),
                config.GetTimeSpan("failure-detection-interval"));
        }
Пример #6
0
        /// <summary>
        /// Java API: Create settings from a configuration with the same layout as the default configuration 'akka.cluster.client'.
        /// </summary>
        public static ClusterClientSettings Create(Config config)
        {
            var initialContacts = config.GetStringList("initial-contacts").Select(ActorPath.Parse).ToImmutableSortedSet();

            TimeSpan? reconnectTimeout = config.GetString("reconnect-timeout").Equals("off")
                ? 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);
        }
Пример #7
0
 internal static TimeSpan? GetSafeDeadlockTimeout(Config cfg)
 {
     var timespan = cfg.GetTimeSpan("deadlock-timeout", TimeSpan.FromSeconds(-1));
     if (timespan.TotalSeconds < 0)
         return null;
     return timespan;
 }
Пример #8
0
        public RemoteSettings(Config config)
        {
            Config = config;
            LogReceive = config.GetBoolean("akka.remote.log-received-messages");
            LogSend = config.GetBoolean("akka.remote.log-sent-messages");

            var bufferSizeLogKey = "akka.remote.log-buffer-size-exceeding";
            if (config.GetString(bufferSizeLogKey).ToLowerInvariant().Equals("off") ||
                config.GetString(bufferSizeLogKey).ToLowerInvariant().Equals("false"))
            {
                LogBufferSizeExceeding = Int32.MaxValue;
            }
            else
            {
                LogBufferSizeExceeding = config.GetInt(bufferSizeLogKey);
            }

            UntrustedMode = config.GetBoolean("akka.remote.untrusted-mode");
            TrustedSelectionPaths = new HashSet<string>(config.GetStringList("akka.remote.trusted-selection-paths"));
            RemoteLifecycleEventsLogLevel = config.GetString("akka.remote.log-remote-lifecycle-events") ?? "DEBUG";
            Dispatcher = config.GetString("akka.remote.use-dispatcher");
            if (RemoteLifecycleEventsLogLevel.Equals("on")) RemoteLifecycleEventsLogLevel = "DEBUG";
            FlushWait = config.GetTimeSpan("akka.remote.flush-wait-on-shutdown");
            ShutdownTimeout = config.GetTimeSpan("akka.remote.shutdown-timeout");
            TransportNames = config.GetStringList("akka.remote.enabled-transports");
            Transports = (from transportName in TransportNames
                let transportConfig = TransportConfigFor(transportName)
                select new TransportSettings(transportConfig)).ToArray();
            Adapters = ConfigToMap(config.GetConfig("akka.remote.adapters"));
            BackoffPeriod = config.GetTimeSpan("akka.remote.backoff-interval");
            RetryGateClosedFor = config.GetTimeSpan("akka.remote.retry-gate-closed-for", TimeSpan.Zero);
            UsePassiveConnections = config.GetBoolean("akka.remote.use-passive-connections");
            SysMsgBufferSize = config.GetInt("akka.remote.system-message-buffer-size");
            SysResendTimeout = config.GetTimeSpan("akka.remote.resend-interval");
            InitialSysMsgDeliveryTimeout = config.GetTimeSpan("akka.remote.initial-system-message-delivery-timeout");
            SysMsgAckTimeout = config.GetTimeSpan("akka.remote.system-message-ack-piggyback-timeout");
            QuarantineDuration = config.GetTimeSpan("akka.remote.prune-quarantine-marker-after");
            StartupTimeout = config.GetTimeSpan("akka.remote.startup-timeout");
            CommandAckTimeout = config.GetTimeSpan("akka.remote.command-ack-timeout");

            WatchFailureDetectorConfig = config.GetConfig("akka.remote.watch-failure-detector");
            WatchFailureDetectorImplementationClass = WatchFailureDetectorConfig.GetString("implementation-class");
            WatchHeartBeatInterval = WatchFailureDetectorConfig.GetTimeSpan("heartbeat-interval");
            WatchUnreachableReaperInterval = WatchFailureDetectorConfig.GetTimeSpan("unreachable-nodes-reaper-interval");
            WatchHeartbeatExpectedResponseAfter = WatchFailureDetectorConfig.GetTimeSpan("expected-response-after");
        }
 public static ClusterSingletonManagerSettings Create(Config config)
 {
     return new ClusterSingletonManagerSettings(
         singletonName: config.GetString("singleton-name"),
         role: RoleOption(config.GetString("role")),
         removalMargin: TimeSpan.Zero, // defaults to ClusterSettins.DownRemovalMargin
         handOverRetryInterval: config.GetTimeSpan("hand-over-retry-interval"));
 }
Пример #10
0
        public ClusterSettings(Config config, string systemName)
        {
            //TODO: Requiring!
            var cc = config.GetConfig("akka.cluster");
            _logInfo = cc.GetBoolean("log-info");
            _failureDetectorConfig = cc.GetConfig("failure-detector");
            _failureDetectorImplementationClass = _failureDetectorConfig.GetString("implementation-class");
            _heartbeatInterval = _failureDetectorConfig.GetTimeSpan("heartbeat-interval");
            _heartbeatExpectedResponseAfter = _failureDetectorConfig.GetTimeSpan("expected-response-after");
            _monitoredByNrOfMembers = _failureDetectorConfig.GetInt("monitored-by-nr-of-members");

            _seedNodes = cc.GetStringList("seed-nodes").Select(Address.Parse).ToImmutableList();
            _seedNodeTimeout = cc.GetTimeSpan("seed-node-timeout");
            _retryUnsuccessfulJoinAfter = cc.GetTimeSpanWithOffSwitch("retry-unsuccessful-join-after");
            _periodicTasksInitialDelay = cc.GetTimeSpan("periodic-tasks-initial-delay");
            _gossipInterval = cc.GetTimeSpan("gossip-interval");
            _gossipTimeToLive = cc.GetTimeSpan("gossip-time-to-live");
            _leaderActionsInterval = cc.GetTimeSpan("leader-actions-interval");
            _unreachableNodesReaperInterval = cc.GetTimeSpan("unreachable-nodes-reaper-interval");
            _publishStatsInterval = cc.GetTimeSpanWithOffSwitch("publish-stats-interval");
            _downRemovalMargin = cc.GetTimeSpan("down-removal-margin");

            _autoDownUnreachableAfter = cc.GetTimeSpanWithOffSwitch("auto-down-unreachable-after");

            _roles = cc.GetStringList("roles").ToImmutableHashSet();
            _minNrOfMembers = cc.GetInt("min-nr-of-members");
            //TODO:
            //_minNrOfMembersOfRole = cc.GetConfig("role").Root.GetArray().ToImmutableDictionary(o => o. )
            //TODO: Ignored jmx
            _useDispatcher = cc.GetString("use-dispatcher");
            if (String.IsNullOrEmpty(_useDispatcher)) _useDispatcher = Dispatchers.DefaultDispatcherId;
            _gossipDifferentViewProbability = cc.GetDouble("gossip-different-view-probability");
            _reduceGossipDifferentViewProbability = cc.GetInt("reduce-gossip-different-view-probability");
            _schedulerTickDuration = cc.GetTimeSpan("scheduler.tick-duration");
            _schedulerTicksPerWheel = cc.GetInt("scheduler.ticks-per-wheel");
            _metricsEnabled = cc.GetBoolean("metrics.enabled");
            _metricsCollectorClass = cc.GetString("metrics.collector-class");
            _metricsInterval = cc.GetTimeSpan("metrics.collect-interval");
            _metricsGossipInterval = cc.GetTimeSpan("metrics.gossip-interval");
            _metricsMovingAverageHalfLife = cc.GetTimeSpan("metrics.moving-average-half-life");

            _minNrOfMembersOfRole = cc.GetConfig("role").Root.GetObject().Items
                .ToImmutableDictionary(kv => kv.Key, kv => kv.Value.GetObject().GetKey("min-nr-of-members").GetInt());

            _verboseHeartbeatLogging = cc.GetBoolean("debug.verbose-heartbeat-logging");
        }
Пример #11
0
        public SnapshotStoreSettings(Config config)
        {
            if (config == null) throw new ArgumentNullException("config", "SqlServer snapshot store settings cannot be initialized, because required HOCON section couldn't been found");

            ConnectionString = config.GetString("connection-string");
            ConnectionTimeout = config.GetTimeSpan("connection-timeout");
            SchemaName = config.GetString("schema-name");
            TableName = config.GetString("table-name");
        }
 public static ClusterSingletonManagerSettings Create(Config config)
 {
     var role = config.GetString("role");
     if (role == string.Empty) role = null;
     return new ClusterSingletonManagerSettings(
         singletonName: config.GetString("singleton-name"),
         role: role,
         removalMargin: TimeSpan.MinValue,
         handOverRetryInterval: config.GetTimeSpan("hand-over-retry-interval"));
 }
Пример #13
0
        public JournalSettings(Config config)
        {
            if (config == null) throw new ArgumentNullException("config", "SqlServer journal settings cannot be initialized, because required HOCON section couldn't been found");

            ConnectionString = config.GetString("connection-string");
            ConnectionStringName = config.GetString("connection-string-name");
            ConnectionTimeout = config.GetTimeSpan("connection-timeout");
            SchemaName = config.GetString("schema-name");
            TableName = config.GetString("table-name");
            TimestampProvider = config.GetString("timestamp-provider");
        }
        public static ClusterSingletonProxySettings Create(Config config)
        {
            var role = config.GetString("role");
            if (role == string.Empty) role = null;

            return new ClusterSingletonProxySettings(
                singletonName: config.GetString("singleton-name"),
                role: role,
                singletonIdentificationInterval: config.GetTimeSpan("singleton-identification-interval"),
                bufferSize: config.GetInt("buffer-size"));
        }
Пример #15
0
        private void CreateNotifier(Akka.Configuration.Config config)
        {
            var uiNotificationWidth    = config.GetInt("ui.notification.width");
            var uiNotificationLifetime = config.GetTimeSpan("ui.notification.lifetime");
            var uiNotificationMax      = config.GetInt("ui.notification.maximum-count");

            Notifier = new Notifier(cfg =>
            {
                cfg.DisplayOptions.Width = uiNotificationWidth;

                cfg.PositionProvider = new PrimaryScreenPositionProvider(Corner.BottomRight, 0, 0);

                cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(
                    notificationLifetime: uiNotificationLifetime,
                    maximumNotificationCount: MaximumNotificationCount.FromCount(uiNotificationMax));

                cfg.Dispatcher = Application.Current.Dispatcher;
            });
        }
Пример #16
0
        /// <summary>
        /// Used to configure and produce <see cref="Dispatcher"/> instances for use with actors.
        /// </summary>
        /// <param name="config">The configuration for this dispatcher.</param>
        /// <param name="prerequisites">System pre-reqs needed to run this dispatcher.</param>
        public DispatcherConfigurator(Config config, IDispatcherPrerequisites prerequisites)
            : base(config, prerequisites)
        {
            // Need to see if a non-zero value is available for this setting
            TimeSpan deadlineTime = config.GetTimeSpan("throughput-deadline-time");
            long? deadlineTimeTicks = null;
            if (deadlineTime.Ticks > 0)
                deadlineTimeTicks = deadlineTime.Ticks;

            _instance = new Dispatcher(this, config.GetString("id"), 
                config.GetInt("throughput"),
                deadlineTimeTicks,
                ConfigureExecutor(),
                config.GetTimeSpan("shutdown-timeout"));
        }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TailChoppingPool"/> class.
 /// <note>
 /// 'nr-of-instances', 'within', and 'tail-chopping-router.interval'
 /// must be defined in the provided configuration.
 /// </note>
 /// </summary>
 /// <param name="config">The configuration used to configure the pool.</param>
 public TailChoppingPool(Config config)
     : this(
           config.GetInt("nr-of-instances"),
           Resizer.FromConfig(config),
           Pool.DefaultSupervisorStrategy,
           Dispatchers.DefaultDispatcherId,
           config.GetTimeSpan("within"), config.GetTimeSpan("tail-chopping-router.interval"), config.HasPath("pool-dispatcher"))
 {
 }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TailChoppingGroup"/> class.
 /// </summary>
 /// <param name="config">
 /// The configuration to use to lookup paths used by the group router.
 /// <note>
 /// If 'routees.path' is defined in the provided configuration then those paths will be used by the router.
 /// If 'within' is defined in the provided configuration then that will be used as the timeout.
 /// If 'tail-chopping-router.interval' is defined in the provided configuration then that will be used as the interval.
 /// </note>
 /// </param>
 public TailChoppingGroup(Config config)
     : this(
           config.GetStringList("routees.paths"),
           config.GetTimeSpan("within"),
           config.GetTimeSpan("tail-chopping-router.interval"),
           Dispatchers.DefaultDispatcherId)
 {
 }
Пример #19
0
        /// <summary>
        /// Creates cluster singleton proxy actor from config
        /// </summary>
        /// <param name="context">Current actor context (will create child actor)</param>
        /// <param name="actorConfig">Configuration to create from</param>
        /// <param name="currentPath">Parent (current) actor path</param>
        /// <param name="pathName">New actor's path name</param>
        protected virtual void CreateSingletonProxyActor(
            IActorContext context,
            Config actorConfig,
            string currentPath,
            string pathName)
        {
            var singletonName = actorConfig.GetString("singleton-name");
            if (string.IsNullOrEmpty(singletonName))
            {
                context.GetLogger()
                    .Error(
                        "{Type}: singleton-name was not defined for {NameSpaceName}/{PathString}",
                        typeof(NameSpaceActor).Name,
                        currentPath,
                        pathName);
                return;
            }

            var singletonManagerPath = actorConfig.GetString("singleton-path");
            if (string.IsNullOrEmpty(singletonName))
            {
                context.GetLogger()
                    .Error(
                        "{Type}: singleton-path was not defined for {NameSpaceName}/{PathString}",
                        typeof(NameSpaceActor).Name,
                        currentPath,
                        pathName);
                return;
            }

            var role = actorConfig.GetString("singleton-node-role");
            if (string.IsNullOrEmpty(role))
            {
                context.GetLogger()
                    .Error(
                        "{Type}: singleton-node-role was not defined for {NameSpaceName}/{PathString}",
                        typeof(NameSpaceActor).Name,
                        currentPath,
                        pathName);
                return;
            }

            context.GetLogger()
                .Info(
                    "{Type}: {NameSpaceName} initializing singleton proxy {SingletonManagerPath} / {SingletonName} for {PathString}",
                    typeof(NameSpaceActor).Name,
                    currentPath,
                    singletonManagerPath,
                    singletonName,
                    pathName);

            context.ActorOf(
                ClusterSingletonProxy.Props(
                    singletonManagerPath: singletonManagerPath,
                    settings:
                        new ClusterSingletonProxySettings(
                            singletonName,
                            role,
                            actorConfig.GetTimeSpan("singleton-identification-interval", TimeSpan.FromSeconds(1), false),
                            actorConfig.GetInt("buffer-size", 2048))),
                name: pathName);
        }
Пример #20
0
 /// <summary>
 /// Gets the default timeout from rest api to actor system
 /// </summary>
 /// <param name="config">The actor system configuration (assumed that this should be the root of configuration)</param>
 /// <returns>Default timeout</returns>
 public static TimeSpan GetRestTimeout(Config config)
 {
     return config.GetTimeSpan("ClusterKit.Core.RestTimeout", TimeSpan.FromSeconds(10), false);
 }
Пример #21
0
        public static ClusterShardingSettings Create(Config config, Config singletonConfig)
        {
            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"),
                leastShardAllocationRebalanceThreshold: config.GetInt("least-shard-allocation-strategy.rebalance-threshold"),
                leastShardAllocationMaxSimultaneousRebalance: config.GetInt("least-shard-allocation-strategy.max-simultaneous-rebalance"));

            var coordinatorSingletonSettings = ClusterSingletonManagerSettings.Create(singletonConfig);
            var role = config.GetString("role");
            if (role == string.Empty) role = null;

            return new ClusterShardingSettings(
                role: role,
                rememberEntities: config.GetBoolean("remember-entities"),
                journalPluginId: config.GetString("journal-plugin-id"),
                snapshotPluginId: config.GetString("snapshot-plugin-id"),
                tunningParameters: tuningParameters,
                coordinatorSingletonSettings: coordinatorSingletonSettings);
        }
Пример #22
0
        /// <summary>
        /// Creates cluster singleton actor from config
        /// </summary>
        /// <param name="context">Current actor context (will create child actor)</param>
        /// <param name="actorConfig">Configuration to create from</param>
        /// <param name="currentPath">Parent (current) actor path</param>
        /// <param name="pathName">New actor's path name</param>
        protected virtual void CreateSingletonActor(
            IActorContext context,
            Config actorConfig,
            string currentPath,
            string pathName)
        {
            var childTypeName = actorConfig.GetString("type");
            if (string.IsNullOrWhiteSpace(childTypeName))
            {
                return;
            }

            var type = Type.GetType(childTypeName);
            if (type == null)
            {
                context.GetLogger()
                    .Error(
                        "{Type}: {ClassTypeString} was not found for actor {NameSpaceName}/{PathString}",
                        typeof(NameSpaceActor).Name,
                        childTypeName,
                        currentPath,
                        pathName);
                return;
            }

            var singletonName = actorConfig.GetString("singleton-name");
            if (string.IsNullOrEmpty(singletonName))
            {
                context.GetLogger()
                    .Error(
                        "{Type}: singleton-name was not defined for{NameSpaceName}/ {PathString}",
                        typeof(NameSpaceActor).Name,
                        currentPath,
                        pathName);
                return;
            }

            var role = actorConfig.GetString("singleton-node-role");
            if (string.IsNullOrEmpty(role))
            {
                context.GetLogger()
                    .Error(
                        "{Type}: singleton-node-role was not defined for {NameSpaceName}/{PathString}",
                        typeof(NameSpaceActor).Name,
                        currentPath,
                        pathName);
                return;
            }

            context.GetLogger()
                .Info(
                    "{Type}: {NameSpaceName} initializing singleton {SingletonName} of type {ActorType} on {PathString}",
                    typeof(NameSpaceActor).Name,
                    currentPath,
                    singletonName,
                    type.Name,
                    pathName);

            context.ActorOf(
                ClusterSingletonManager.Props(
                    context.System.DI().Props(type),
                    new ClusterSingletonManagerSettings(
                        singletonName,
                        role,
                        actorConfig.GetTimeSpan("removal-margin", TimeSpan.FromSeconds(1), false),
                        actorConfig.GetTimeSpan("handover-retry-interval", TimeSpan.FromSeconds(5), false))),
                pathName);
        }
Пример #23
0
 public BoundedMessageQueue(Settings settings, Config config) 
     : this(config.GetInt("mailbox-capacity"), config.GetTimeSpan("mailbox-push-timeout-time"))
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScatterGatherFirstCompletedPool"/> class.
 /// </summary>
 /// <param name="config">
 /// The configuration to use to lookup paths used by the group router.
 /// 
 /// <note>
 /// 'within' must be defined in the provided configuration.
 /// </note>
 /// </param>
 public ScatterGatherFirstCompletedPool(Config config)
     : this(
           nrOfInstances: config.GetInt("nr-of-instances"),
           resizer: Resizer.FromConfig(config),
           within: config.GetTimeSpan("within"),
           supervisorStrategy: Pool.DefaultSupervisorStrategy,
           routerDispatcher: Dispatchers.DefaultDispatcherId,
           usePoolDispatcher: config.HasPath("pool-dispatcher"))
 {
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ScatterGatherFirstCompletedGroup" /> class.
 /// </summary>
 /// <param name="config">The configuration.</param>
 public ScatterGatherFirstCompletedGroup(Config config)
     : base(config.GetStringList("routees.paths"))
 {
     Within = config.GetTimeSpan("within");
 }
Пример #26
0
 /// <summary>
 /// Constructor that reads parameters from an Akka <see cref="Config"/> section.
 /// Expects property 'acceptable-heartbeat-pause'.
 /// </summary>
 /// <param name="config"></param>
 /// <param name="ev"></param>
 public DeadlineFailureDetector(Config config, EventStream ev) : this(config.GetTimeSpan("acceptable-heartbeat-pause")) { }
 public ScatterGatherFirstCompletedPool(Config config) : base(config)
 {
     _within = config.GetTimeSpan("within");
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScatterGatherFirstCompletedGroup"/> class.
 /// </summary>
 /// <param name="config">
 /// The configuration to use to lookup paths used by the group router.
 /// 
 /// <note>
 /// If 'routees.path' is defined in the provided configuration then those paths will be used by the router.
 /// If 'within' is defined in the provided configuration then that will be used as the interval.
 /// </note>
 /// </param>
 public ScatterGatherFirstCompletedGroup(Config config)
     : this(
           config.GetStringList("routees.paths"),
           config.GetTimeSpan("within"),
           Dispatchers.DefaultDispatcherId)
 {
 }
Пример #29
0
 public SqlReadJournal(ExtendedActorSystem system, Config config)
 {
     _refershInterval = config.GetTimeSpan("refresh-interval");
     _writeJournalPluginId = config.GetString("write-plugin");
     _maxBufferSize = config.GetInt("max-buffer-size");
 }
 /// <summary>
 /// Creates an instance of the TailChoppingPool.
 /// </summary>
 /// <param name="config">The configuration to use with this instance.</param>
 public TailChoppingPool(Config config)
     : this(config.GetInt("nr-of-instances"),
         DefaultResizer.FromConfig(config),
         null,
         null,   //TODO: what are our defaults? null?
         config.GetTimeSpan("within"),
         config.GetTimeSpan("tail-chopping-router.interval"),
         config.HasPath("pool-dispatcher")
         )
 {
 }
 /// <summary>
 /// Creates an instance of the TailChoppingGroup.
 /// </summary>
 /// <param name="config">The configuration to use with this instance.</param>
 public TailChoppingGroup(Config config)
     : base(config.GetStringList("routees.paths").ToArray())
 {
     _within = config.GetTimeSpan("within");
     _interval = config.GetTimeSpan("tail-chopping-router.interval");
 }