public RoundBasedRegister(IIntercomMessageHub intercomMessageHub, IBallotGenerator ballotGenerator, ISynodConfiguration synodConfig, LeaseConfiguration leaseConfig, ILogger logger) { this.logger = logger; this.synodConfig = synodConfig; this.leaseConfig = leaseConfig; this.intercomMessageHub = intercomMessageHub; intercomMessageHub.Start(); readBallot = ballotGenerator.Null(); writeBallot = ballotGenerator.Null(); listener = intercomMessageHub.Subscribe(); listener.Where(m => Unsafe.Equals(m.Identity, LeaseReadMessage.MessageIdentity)) .Subscribe(OnReadReceived); listener.Where(m => Unsafe.Equals(m.Identity, LeaseWriteMessage.MessageIdentity)) .Subscribe(OnWriteReceived); ackReadStream = listener.Where(m => Unsafe.Equals(m.Identity, LeaseAckReadMessage.MessageIdentity)); nackReadStream = listener.Where(m => Unsafe.Equals(m.Identity, LeaseNackReadMessage.MessageIdentity)); ackWriteStream = listener.Where(m => Unsafe.Equals(m.Identity, LeaseAckWriteMessage.MessageIdentity)); nackWriteStream = listener.Where(m => Unsafe.Equals(m.Identity, LeaseNackWriteMessage.MessageIdentity)); }
public RoundBasedRegister(IIntercomMessageHub intercomMessageHub, IBallotGenerator ballotGenerator, ISynodConfigurationProvider synodConfigProvider, LeaseConfiguration leaseConfig, ILogger logger) { this.logger = logger; this.synodConfigProvider = synodConfigProvider; this.leaseConfig = leaseConfig; this.intercomMessageHub = intercomMessageHub; readBallot = ballotGenerator.Null(); writeBallot = ballotGenerator.Null(); listener = intercomMessageHub.Subscribe(); listener.Where(m => m.Equals(ConsensusMessages.LeaseRead)).Subscribe(OnReadReceived); listener.Where(m => m.Equals(ConsensusMessages.LeaseWrite)).Subscribe(OnWriteReceived); ackReadStream = listener.Where(m => m.Equals(ConsensusMessages.LeaseAckRead)); nackReadStream = listener.Where(m => m.Equals(ConsensusMessages.LeaseNackRead)); ackWriteStream = listener.Where(m => m.Equals(ConsensusMessages.LeaseAckWrite)); nackWriteStream = listener.Where(m => m.Equals(ConsensusMessages.LeaseNackWrite)); WaitBeforeNextLeaseIssued(leaseConfig); }
public InstanceRoundBasedRegister(Instance instance, IIntercomMessageHub intercomMessageHub, IBallotGenerator ballotGenerator, ISynodConfigurationProvider synodConfigProvider, InstanceLeaseProviderConfiguration leaseConfig, ILogger logger) { this.instance = instance; this.logger = logger; this.synodConfigProvider = synodConfigProvider; this.leaseConfig = leaseConfig; this.intercomMessageHub = intercomMessageHub; readBallot = ballotGenerator.Null(); writeBallot = ballotGenerator.Null(); lastIntercomeMessageTimestamp = DateTime.UtcNow.Ticks; listener = intercomMessageHub.Subscribe(); listener.Where(IsLeaseRead) .Subscribe(OnReadReceived); listener.Where(IsWriteLease) .Subscribe(OnWriteReceived); ackReadStream = listener.Where(IsLeaseAckReadMessage); nackReadStream = listener.Where(IsLeaseNackReadMessage); ackWriteStream = listener.Where(IsLeaseAckWriteMessage); nackWriteStream = listener.Where(IsLeaseNackWriteMessage); logger.Info($"{instance.Identity.GetAnyString()}-InstanceRoundBasedRegister created"); }
public DelayedInstanceWrap(Instance instance, IIntercomMessageHub intercomMessageHub, IBallotGenerator ballotGenerator, ISynodConfigurationProvider synodConfigProvider, InstanceLeaseProviderConfiguration leaseConfig, ILogger logger) { this.intercomMessageHub = intercomMessageHub; this.ballotGenerator = ballotGenerator; this.synodConfigProvider = synodConfigProvider; this.leaseConfig = leaseConfig; this.logger = logger; Task.Delay(leaseConfig.ClockDrift).ContinueWith(_ => CreateInstanceLeaseProvider(instance)); }
public LeaseProvider(IIntercomMessageHub intercomMessageHub, IBallotGenerator ballotGenerator, ISynodConfigurationProvider synodConfigProvider, InstanceLeaseProviderConfiguration leaseConfiguration, LeaseProviderConfiguration leaseProviderConfiguration, IMessageHub messageHub, ILogger logger) { ValidateConfiguration(leaseConfiguration); this.intercomMessageHub = intercomMessageHub; this.ballotGenerator = ballotGenerator; this.synodConfigProvider = synodConfigProvider; this.leaseConfiguration = leaseConfiguration; this.messageHub = messageHub; this.logger = logger; clusterName = leaseProviderConfiguration.ClusterName.GetBytes(); staleInstancesCleanupPeriod = leaseProviderConfiguration.StaleInstancesCleanupPeriod; leaseProviders = new ConcurrentDictionary <Instance, DelayedInstanceWrap>(); }