Example #1
0
        public Shard(
            string typeName,
            string shardId,
            Func <string, Props> entityProps,
            ClusterShardingSettings settings,
            ExtractEntityId extractEntityId,
            ExtractShardId extractShardId,
            object handOffStopMessage)
        {
            TypeName           = typeName;
            ShardId            = shardId;
            EntityProps        = entityProps;
            Settings           = settings;
            ExtractEntityId    = extractEntityId;
            ExtractShardId     = extractShardId;
            HandOffStopMessage = handOffStopMessage;
            RememberedEntitiesRecoveryStrategy = Settings.TunningParameters.EntityRecoveryStrategy == "constant"
                ? EntityRecoveryStrategy.ConstantStrategy(
                Context.System,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyFrequency,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyNumberOfEntities)
                : EntityRecoveryStrategy.AllStrategy;

            var idleInterval = TimeSpan.FromTicks(Settings.PassivateIdleEntityAfter.Ticks / 2);

            PassivateIdleTask = Settings.PassivateIdleEntityAfter > TimeSpan.Zero && !Settings.RememberEntities
                ? Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(idleInterval, idleInterval, Self, PassivateIdleTick.Instance, Self)
                : null;

            this.Initialized();
        }
Example #2
0
        public DDataShard(
            string typeName,
            ShardId shardId,
            Props entityProps,
            ClusterShardingSettings settings,
            ExtractEntityId extractEntityId,
            ExtractShardId extractShardId,
            object handOffStopMessage,
            IActorRef replicator,
            int majorityCap)
        {
            TypeName           = typeName;
            ShardId            = shardId;
            EntityProps        = entityProps;
            Settings           = settings;
            ExtractEntityId    = extractEntityId;
            ExtractShardId     = extractShardId;
            HandOffStopMessage = handOffStopMessage;
            Replicator         = replicator;
            MajorityCap        = majorityCap;

            RememberedEntitiesRecoveryStrategy = Settings.TunningParameters.EntityRecoveryStrategy == "constant"
                ? EntityRecoveryStrategy.ConstantStrategy(
                Context.System,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyFrequency,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyNumberOfEntities)
                : EntityRecoveryStrategy.AllStrategy;

            _readConsistency  = new ReadMajority(settings.TunningParameters.WaitingForStateTimeout, majorityCap);
            _writeConsistency = new WriteMajority(settings.TunningParameters.UpdatingStateTimeout, majorityCap);
            _stateKeys        = Enumerable.Range(0, NrOfKeys).Select(i => new ORSetKey <EntryId>($"shard-{typeName}-{shardId}-{i}")).ToImmutableArray();

            GetState();
        }
Example #3
0
        public PersistentShard(
            string typeName,
            string shardId,
            Func <string, Props> entityProps,
            ClusterShardingSettings settings,
            ExtractEntityId extractEntityId,
            ExtractShardId extractShardId,
            object handOffStopMessage)
        {
            TypeName           = typeName;
            ShardId            = shardId;
            EntityProps        = entityProps;
            Settings           = settings;
            ExtractEntityId    = extractEntityId;
            ExtractShardId     = extractShardId;
            HandOffStopMessage = handOffStopMessage;

            PersistenceId    = "/sharding/" + TypeName + "Shard/" + ShardId;
            JournalPluginId  = settings.JournalPluginId;
            SnapshotPluginId = settings.SnapshotPluginId;
            RememberedEntitiesRecoveryStrategy = Settings.TunningParameters.EntityRecoveryStrategy == "constant"
                ? EntityRecoveryStrategy.ConstantStrategy(
                Context.System,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyFrequency,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyNumberOfEntities)
                : EntityRecoveryStrategy.AllStrategy;
        }
Example #4
0
        public Shard(
            string typeName,
            string shardId,
            Func <string, Props> entityProps,
            ClusterShardingSettings settings,
            ExtractEntityId extractEntityId,
            ExtractShardId extractShardId,
            object handOffStopMessage)
        {
            TypeName           = typeName;
            ShardId            = shardId;
            EntityProps        = entityProps;
            Settings           = settings;
            ExtractEntityId    = extractEntityId;
            ExtractShardId     = extractShardId;
            HandOffStopMessage = handOffStopMessage;
            RememberedEntitiesRecoveryStrategy = Settings.TunningParameters.EntityRecoveryStrategy == "constant"
                ? EntityRecoveryStrategy.ConstantStrategy(
                Context.System,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyFrequency,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyNumberOfEntities)
                : EntityRecoveryStrategy.AllStrategy;

            this.Initialized();
        }
Example #5
0
        public PersistentShard(
            string typeName,
            string shardId,
            Func <string, Props> entityProps,
            ClusterShardingSettings settings,
            ExtractEntityId extractEntityId,
            ExtractShardId extractShardId,
            object handOffStopMessage)
        {
            TypeName           = typeName;
            ShardId            = shardId;
            EntityProps        = entityProps;
            Settings           = settings;
            ExtractEntityId    = extractEntityId;
            ExtractShardId     = extractShardId;
            HandOffStopMessage = handOffStopMessage;

            PersistenceId    = "/sharding/" + TypeName + "Shard/" + ShardId;
            JournalPluginId  = settings.JournalPluginId;
            SnapshotPluginId = settings.SnapshotPluginId;
            RememberedEntitiesRecoveryStrategy = Settings.TunningParameters.EntityRecoveryStrategy == "constant"
                ? EntityRecoveryStrategy.ConstantStrategy(
                Context.System,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyFrequency,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyNumberOfEntities)
                : EntityRecoveryStrategy.AllStrategy;

            var idleInterval = TimeSpan.FromTicks(Settings.PassivateIdleEntityAfter.Ticks / 2);

            PassivateIdleTask = Settings.ShouldPassivateIdleEntities
                ? Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(idleInterval, idleInterval, Self, Shard.PassivateIdleTick.Instance, Self)
                : null;
        }
Example #6
0
        public DDataShard(
            string typeName,
            ShardId shardId,
            Func <string, Props> entityProps,
            ClusterShardingSettings settings,
            ExtractEntityId extractEntityId,
            ExtractShardId extractShardId,
            object handOffStopMessage,
            IActorRef replicator,
            int majorityCap)
        {
            TypeName           = typeName;
            ShardId            = shardId;
            EntityProps        = entityProps;
            Settings           = settings;
            ExtractEntityId    = extractEntityId;
            ExtractShardId     = extractShardId;
            HandOffStopMessage = handOffStopMessage;
            Replicator         = replicator;
            MajorityCap        = majorityCap;

            RememberedEntitiesRecoveryStrategy = Settings.TunningParameters.EntityRecoveryStrategy == "constant"
                ? EntityRecoveryStrategy.ConstantStrategy(
                Context.System,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyFrequency,
                Settings.TunningParameters.EntityRecoveryConstantRateStrategyNumberOfEntities)
                : EntityRecoveryStrategy.AllStrategy;

            var idleInterval = TimeSpan.FromTicks(Settings.PassivateIdleEntityAfter.Ticks / 2);

            PassivateIdleTask = Settings.ShouldPassivateIdleEntities
                ? Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(idleInterval, idleInterval, Self, Shard.PassivateIdleTick.Instance, Self)
                : null;

            _readConsistency  = new ReadMajority(settings.TunningParameters.WaitingForStateTimeout, majorityCap);
            _writeConsistency = new WriteMajority(settings.TunningParameters.UpdatingStateTimeout, majorityCap);
            _stateKeys        = Enumerable.Range(0, NrOfKeys).Select(i => new ORSetKey <EntryId>($"shard-{typeName}-{shardId}-{i}")).ToImmutableArray();

            GetState();
        }