public void Send(ElectionMessage.ViewChangeProof message, IPEndPoint endPoint)
        {
            Ensure.NotNull(message, "message");
            Ensure.NotNull(endPoint, "endPoint");

            _client.Post(endPoint.ToHttpUrl("/elections/viewchangeproof"),
                         Codec.Json.To(new ElectionMessageDto.ViewChangeProofDto(message)),
                         Codec.Json.ContentType,
                         r => { /*ignore*/ },
                         e => { /*Log.ErrorException(e, "Error occured while writing request (elections/viewchangeproof)")*/ });
        }
 public void SendViewChangeProof(ElectionMessage.ViewChangeProof msg, EndPoint destinationEndpoint,
                                 DateTime deadline)
 {
     SendViewChangeProofAsync(msg.ServerId, msg.ServerHttpEndPoint, msg.InstalledView, deadline).ContinueWith(
         r => {
         if (r.Exception != null)
         {
             Log.Information(r.Exception, "View Change Proof Send Failed to {Server}",
                             destinationEndpoint);
         }
     });
 }
Exemple #3
0
        public void Handle(ElectionMessage.ViewChangeProof message)
        {
            if (_state == ElectionsState.Shutdown)
            {
                return;
            }
            if (_state == ElectionsState.Idle)
            {
                return;
            }
            if (message.InstalledView <= _lastInstalledView)
            {
                return;
            }

            _lastAttemptedView = message.InstalledView;

            _publisher.Publish(TimerMessage.Schedule.Create(LeaderElectionProgressTimeout,
                                                            _publisherEnvelope,
                                                            new ElectionMessage.ElectionsTimedOut(_lastAttemptedView)));

            if (AmILeaderOf(_lastAttemptedView))
            {
                Log.Debug(
                    "ELECTIONS: (IV={installedView}) VIEWCHANGEPROOF FROM [{serverInternalHttp}, {serverId:B}]. JUMPING TO LEADER STATE.",
                    message.InstalledView, message.ServerInternalHttp, message.ServerId);

                ShiftToPreparePhase();
            }
            else
            {
                Log.Debug(
                    "ELECTIONS: (IV={installedView}) VIEWCHANGEPROOF FROM [{serverInternalHttp}, {serverId:B}]. JUMPING TO NON-LEADER STATE.",
                    message.InstalledView, message.ServerInternalHttp, message.ServerId);

                ShiftToRegNonLeader();
            }
        }