public ViewChangeMessageProcessor(
            MessageServiceClient messageServiceClient,
            ReplicaState replicaState,
            StartChangeXL startChange)
        {
            this.messageServiceClient = messageServiceClient;
            this.replicaState         = replicaState;

            this.viewNumber    = startChange.ViewNumber;
            this.configuration = startChange.Configuration;

            this.imTheManager         = startChange.Configuration.Values.ToArray()[0].Equals(this.replicaState.MyUrl);
            this.numberToWait         = (startChange.Configuration.Count - 1) / 2;
            this.messagesDoViewChange = 0;

            this.bestDoViewChange = new DoViewChangeXL(
                this.replicaState.ServerId,
                this.viewNumber,
                this.replicaState.ViewNumber,
                this.configuration,
                this.replicaState.TupleSpace,
                this.replicaState.ClientTable,
                this.replicaState.CommitNumber);

            Log.Info("Changed to View Change State.");

            // Stay in this state for a timeout
            Task.Factory.StartNew(this.StartTimeout);
        }
        private void CheckNumberAndSetNewConfiguration()
        {
            if (this.messagesDoViewChange >= this.numberToWait)
            {
                // start change
                Uri[] replicasUrl = this.configuration.Values
                                    .Where(url => !url.Equals(this.replicaState.MyUrl))
                                    .ToArray();

                IMessage message = new StartChangeXL(
                    this.replicaState.ServerId,
                    this.viewNumber,
                    this.configuration,
                    this.bestDoViewChange.TupleSpace,
                    this.bestDoViewChange.ClientTable,
                    this.bestDoViewChange.CommitNumber);
                this.messageServiceClient.RequestMulticast(message, replicasUrl, replicasUrl.Length, -1, false);

                // Set new configuration
                this.replicaState.SetNewConfiguration(
                    this.bestDoViewChange.Configuration,
                    replicasUrl,
                    this.bestDoViewChange.ViewNumber,
                    this.bestDoViewChange.TupleSpace,
                    this.bestDoViewChange.ClientTable,
                    this.bestDoViewChange.CommitNumber);
            }
        }
Exemplo n.º 3
0
 public void ChangeToViewChange(StartChangeXL startChange)
 {
     lock (this.State) {
         if (!(this.State is ViewChangeMessageProcessor))
         {
             this.State = new ViewChangeMessageProcessor(this.MessageServiceClient, this, startChange);
             this.HandlerStateChanged.Set();
             this.HandlerStateChanged.Reset();
         }
     }
 }
Exemplo n.º 4
0
 public IResponse VisitStartChangeXL(StartChangeXL startChange)
 {
     if (startChange.ViewNumber <= this.replicaState.ViewNumber)
     {
         return(null);
     }
     lock (this.replicaState.State) {
         if (!(this.replicaState.State is ViewChangeMessageProcessor))
         {
             this.replicaState.ChangeToViewChange(startChange);
         }
     }
     return(startChange.Accept(this.replicaState.State));
 }
Exemplo n.º 5
0
 public IResponse VisitStartChangeXL(StartChangeXL startChange)
 {
     Log.Info($"Start Change issued from server {startChange.ServerId}");
     if (startChange.ViewNumber <= this.replicaState.ViewNumber)
     {
         return(null);
     }
     lock (this) {
         if (!(this.replicaState.State is ViewChangeMessageProcessor))
         {
             this.replicaState.ChangeToViewChange(startChange);
         }
     }
     return(startChange.Accept(this.replicaState.State));
 }
 public IResponse VisitStartChangeXL(StartChangeXL startChange)
 {
     if (startChange.ViewNumber <= this.replicaState.ViewNumber)
     {
         return(null);
     }
     // Set new configuration
     Uri[] replicasUrl = this.configuration.Values
                         .Where(url => !url.Equals(this.replicaState.MyUrl))
                         .ToArray();
     this.replicaState.SetNewConfiguration(
         startChange.Configuration,
         replicasUrl,
         startChange.ViewNumber,
         startChange.TupleSpace,
         startChange.ClientTable,
         startChange.CommitNumber);
     this.replicaState.ChangeToNormalState();
     return(null);
 }