Example #1
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));
        }
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="tunningParameters">TBD</param>
        /// <exception cref="ArgumentNullException">
        /// This exception is thrown when the specified <paramref name="tunningParameters"/> is undefined.
        /// </exception>
        /// <returns>TBD</returns>
        public ClusterShardingSettings WithTuningParameters(TunningParameters tunningParameters)
        {
            if (tunningParameters == null)
                throw new ArgumentNullException(nameof(tunningParameters), $"ClusterShardingSettings requires {nameof(tunningParameters)} to be provided");

            return Copy(tunningParameters: tunningParameters);
        }
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="config">TBD</param>
        /// <param name="singletonConfig">TBD</param>
        /// <returns>TBD</returns>
        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"),
                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");
            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"),
                stateStoreMode: (StateStoreMode)Enum.Parse(typeof(StateStoreMode), config.GetString("state-store-mode"), ignoreCase: true),
                tunningParameters: tuningParameters,
                coordinatorSingletonSettings: coordinatorSingletonSettings);
        }
Example #4
0
        public ClusterShardingSettings WithTuningParameters(TunningParameters tunningParameters)
        {
            if (tunningParameters == null)
            {
                throw new ArgumentNullException("tunningParameters");
            }

            return(Copy(tunningParameters: tunningParameters));
        }
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="role">TBD</param>
 /// <param name="rememberEntities">TBD</param>
 /// <param name="journalPluginId">TBD</param>
 /// <param name="snapshotPluginId">TBD</param>
 /// <param name="passivateIdleEntityAfter">TBD</param>
 /// <param name="stateStoreMode">TBD</param>
 /// <param name="tunningParameters">TBD</param>
 /// <param name="coordinatorSingletonSettings">TBD</param>
 public ClusterShardingSettings(
     string role,
     bool rememberEntities,
     string journalPluginId,
     string snapshotPluginId,
     TimeSpan passivateIdleEntityAfter,
     StateStoreMode stateStoreMode,
     TunningParameters tunningParameters,
     ClusterSingletonManagerSettings coordinatorSingletonSettings)
     : this(role, rememberEntities, journalPluginId, snapshotPluginId, passivateIdleEntityAfter, stateStoreMode, tunningParameters, coordinatorSingletonSettings, null)
 {
 }
Example #6
0
 public ClusterShardingSettings(
     string role,
     bool rememberEntities,
     string journalPluginId,
     string snapshotPluginId,
     TunningParameters tunningParameters,
     ClusterSingletonManagerSettings coordinatorSingletonSettings)
 {
     Role                         = role;
     RememberEntities             = rememberEntities;
     JournalPluginId              = journalPluginId;
     SnapshotPluginId             = snapshotPluginId;
     TunningParameters            = tunningParameters;
     CoordinatorSingletonSettings = coordinatorSingletonSettings;
 }
Example #7
0
 private ClusterShardingSettings Copy(
     string role                         = null,
     bool?rememberEntities               = null,
     string journalPluginId              = null,
     string snapshotPluginId             = null,
     TunningParameters tunningParameters = null,
     ClusterSingletonManagerSettings coordinatorSingletonSettings = null)
 {
     return(new ClusterShardingSettings(
                role: role ?? Role,
                rememberEntities: rememberEntities ?? RememberEntities,
                journalPluginId: journalPluginId ?? JournalPluginId,
                snapshotPluginId: snapshotPluginId ?? SnapshotPluginId,
                tunningParameters: tunningParameters ?? TunningParameters,
                coordinatorSingletonSettings: coordinatorSingletonSettings ?? CoordinatorSingletonSettings));
 }
Example #8
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="role">TBD</param>
 /// <param name="rememberEntities">TBD</param>
 /// <param name="journalPluginId">TBD</param>
 /// <param name="snapshotPluginId">TBD</param>
 /// <param name="passivateIdleEntityAfter">TBD</param>
 /// <param name="stateStoreMode">TBD</param>
 /// <param name="tunningParameters">TBD</param>
 /// <param name="coordinatorSingletonSettings">TBD</param>
 public ClusterShardingSettings(
     string role,
     bool rememberEntities,
     string journalPluginId,
     string snapshotPluginId,
     TimeSpan passivateIdleEntityAfter,
     StateStoreMode stateStoreMode,
     TunningParameters tunningParameters,
     ClusterSingletonManagerSettings coordinatorSingletonSettings)
 {
     Role                         = role;
     RememberEntities             = rememberEntities;
     JournalPluginId              = journalPluginId;
     SnapshotPluginId             = snapshotPluginId;
     PassivateIdleEntityAfter     = passivateIdleEntityAfter;
     StateStoreMode               = stateStoreMode;
     TunningParameters            = tunningParameters;
     CoordinatorSingletonSettings = coordinatorSingletonSettings;
 }
Example #9
0
 private ClusterShardingSettings Copy(
     string role                         = null,
     bool?rememberEntities               = null,
     string journalPluginId              = null,
     string snapshotPluginId             = null,
     TimeSpan?passivateIdleAfter         = null,
     StateStoreMode?stateStoreMode       = null,
     TunningParameters tunningParameters = null,
     ClusterSingletonManagerSettings coordinatorSingletonSettings = null)
 {
     return(new ClusterShardingSettings(
                role: role ?? Role,
                rememberEntities: rememberEntities ?? RememberEntities,
                journalPluginId: journalPluginId ?? JournalPluginId,
                snapshotPluginId: snapshotPluginId ?? SnapshotPluginId,
                passivateIdleEntityAfter: passivateIdleAfter ?? PassivateIdleEntityAfter,
                stateStoreMode: stateStoreMode ?? StateStoreMode,
                tunningParameters: tunningParameters ?? TunningParameters,
                coordinatorSingletonSettings: coordinatorSingletonSettings ?? CoordinatorSingletonSettings));
 }
 private ClusterShardingSettings Copy(
     Option <string> role                = default,
     bool?rememberEntities               = null,
     string journalPluginId              = null,
     string snapshotPluginId             = null,
     TimeSpan?passivateIdleAfter         = null,
     StateStoreMode?stateStoreMode       = null,
     TunningParameters tunningParameters = null,
     ClusterSingletonManagerSettings coordinatorSingletonSettings = null,
     Option <LeaseUsageSettings> leaseSettings = default)
 {
     return(new ClusterShardingSettings(
                role: role.HasValue?role.Value: Role,
                rememberEntities: rememberEntities ?? RememberEntities,
                journalPluginId: journalPluginId ?? JournalPluginId,
                snapshotPluginId: snapshotPluginId ?? SnapshotPluginId,
                passivateIdleEntityAfter: passivateIdleAfter ?? PassivateIdleEntityAfter,
                stateStoreMode: stateStoreMode ?? StateStoreMode,
                tunningParameters: tunningParameters ?? TunningParameters,
                coordinatorSingletonSettings: coordinatorSingletonSettings ?? CoordinatorSingletonSettings,
                leaseSettings: leaseSettings.HasValue ? leaseSettings.Value : LeaseSettings));
 }
        /// <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");

            LeaseUsageSettings lease = null;
            var leaseConfigPath      = config.GetString("use-lease");

            if (!string.IsNullOrEmpty(leaseConfigPath))
            {
                lease = new LeaseUsageSettings(leaseConfigPath, config.GetTimeSpan("lease-retry-interval"));
            }

            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,
                       leaseSettings: lease));
        }
Example #12
0
 private ClusterShardingSettings Copy(
     string role = null,
     bool? rememberEntities = null,
     string journalPluginId = null,
     string snapshotPluginId = null,
     TunningParameters tunningParameters = null,
     ClusterSingletonManagerSettings coordinatorSingletonSettings = null)
 {
     return new ClusterShardingSettings(
         role: role ?? Role,
         rememberEntities: rememberEntities ?? RememberEntities,
         journalPluginId: journalPluginId ?? JournalPluginId,
         snapshotPluginId: snapshotPluginId ?? SnapshotPluginId,
         tunningParameters: tunningParameters ?? TunningParameters,
         coordinatorSingletonSettings: coordinatorSingletonSettings ?? CoordinatorSingletonSettings);
 }
Example #13
0
        public ClusterShardingSettings WithTuningParameters(TunningParameters tunningParameters)
        {
            if (tunningParameters == null)
                throw new ArgumentNullException("tunningParameters");

            return Copy(tunningParameters: tunningParameters);
        }
Example #14
0
 public ClusterShardingSettings(
     string role,
     bool rememberEntities,
     string journalPluginId,
     string snapshotPluginId,
     TunningParameters tunningParameters,
     ClusterSingletonManagerSettings coordinatorSingletonSettings)
 {
     Role = role;
     RememberEntities = rememberEntities;
     JournalPluginId = journalPluginId;
     SnapshotPluginId = snapshotPluginId;
     TunningParameters = tunningParameters;
     CoordinatorSingletonSettings = coordinatorSingletonSettings;
 }
Example #15
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);
        }