public IResponse VisitStartViewChange(StartViewChange startViewChange)
 {
     if (this.replicaState.HandlerStateChanged.WaitOne(Timeout.TIMEOUT_VIEW_CHANGE) &&
         this.replicaState.State is ViewChangeMessageProcessor)
     {
         return(startViewChange.Accept(this.replicaState.State));
     }
     return(null);
 }
 public IResponse VisitStartViewChange(StartViewChange startViewChange)
 {
     if (startViewChange.ViewNumber <= this.replicaState.ViewNumber)
     {
         return(null);
     }
     if (startViewChange.ViewNumber == this.viewNumber &&
         ConfigurationUtils.CompareConfigurations(startViewChange.Configuration, this.configuration))
     {
         return(new StartViewChangeOk(this.replicaState.ServerId, this.viewNumber, this.configuration));
     }
     Log.Debug("Received Start View Change that don't match.");
     return(null);
 }
        private void MulticastStartViewChange()
        {
            IMessage message = new StartViewChange(this.replicaState.ServerId, this.viewNumber, this.configuration);

            Uri[] currentConfiguration = this.replicaState.ReplicasUrl.ToArray();

            IResponses responses = this.messageServiceClient.RequestMulticast(
                message,
                currentConfiguration,
                this.replicaState.Configuration.Count / 2,
                (int)(Timeout.TIMEOUT_VIEW_CHANGE),
                true);

            IResponse[] responsesVector = responses.ToArray();

            // There was no quorum to accept the view change
            if (responsesVector.Length < this.numberToWait)
            {
                Log.Debug($"There was no quorum for view change. " +
                          $"Just received {responsesVector.Length} from at least {this.numberToWait}");
                this.replicaState.ChangeToNormalState();
                return;
            }

            // In case I'm the leader, wait for f DoViewChange
            if (this.imTheLeader)
            {
                this.CheckNumberAndSetNewConfiguration();
            }
            else
            {
                // Else, send DoViewChange to leader
                Uri      leader        = this.configuration.Values.ToArray()[0];
                IMessage doViewMessage = new DoViewChange(
                    this.replicaState.ServerId,
                    this.viewNumber,
                    this.replicaState.ViewNumber,
                    this.configuration,
                    this.replicaState.Logger,
                    this.replicaState.OpNumber,
                    this.replicaState.CommitNumber);

                this.messageServiceClient.Request(doViewMessage, leader, -1);
            }
        }
Пример #4
0
 public IResponse VisitStartViewChange(StartViewChange startViewChange)
 {
     return(this.WaitNormalState(startViewChange));
 }