Exemplo n.º 1
0
        private void ShiftToRegLeader()
        {
            Log.Debug("ELECTIONS: (V={lastAttemptedView}) SHIFT TO REG_LEADER.", _lastAttemptedView);

            _state = ElectionsState.Leader;
            SendProposal();
        }
Exemplo n.º 2
0
        private void ShiftToAcceptor()
        {
            Log.Information("ELECTIONS: (V={lastAttemptedView}) SHIFT TO REG_ACCEPTOR.", _lastAttemptedView);

            _state             = ElectionsState.Acceptor;
            _lastInstalledView = _lastAttemptedView;
        }
Exemplo n.º 3
0
        private void ShiftToRegNonLeader()
        {
            Log.Debug("ELECTIONS: (V={lastAttemptedView}) SHIFT TO REG_NONLEADER.", _lastAttemptedView);

            _state             = ElectionsState.NonLeader;
            _lastInstalledView = _lastAttemptedView;
        }
Exemplo n.º 4
0
 public void Handle(LeaderDiscoveryMessage.LeaderFound message)
 {
     if (_leader != null || _lastElectedLeader != null || _state != ElectionsState.Idle)
     {
         return;
     }
     Log.Information("ELECTIONS: Existing LEADER was discovered, updating information. M=[{leaderInternalHttp},{leaderId:B}])", message.Leader.InternalHttp, message.Leader.InstanceId);
     _leader            = message.Leader.InstanceId;
     _lastElectedLeader = message.Leader.InstanceId;
     _lastAttemptedView = 0;
     _lastInstalledView = 0;
     _state             = ElectionsState.Acceptor;
 }
Exemplo n.º 5
0
        private void ShiftToLeader()
        {
            if (_nodeInfo.IsReadOnlyReplica)
            {
                Log.Information("ELECTIONS: (V={lastAttemptedView}) NOT SHIFTING TO REG_LEADER AS I'M READONLY.",
                                _lastAttemptedView);
                return;
            }

            Log.Information("ELECTIONS: (V={lastAttemptedView}) SHIFT TO REG_LEADER.", _lastAttemptedView);

            _state = ElectionsState.Leader;
            SendProposal();
        }
Exemplo n.º 6
0
        public void Handle(LeaderDiscoveryMessage.LeaderFound message)
        {
            if (_leader != null || _lastElectedLeader != null || _state != ElectionsState.Idle)
            {
                return;
            }
            if (_nodeInfo.IsReadOnlyReplica)
            {
                Log.Verbose("ELECTIONS: THIS NODE IS A READ ONLY REPLICA.");
            }

            Log.Information("ELECTIONS: Existing LEADER was discovered, updating information. M=[{leaderInternalHttp},{leaderId:B}])", message.Leader.InternalHttp, message.Leader.InstanceId);
            _leader            = message.Leader.InstanceId;
            _lastElectedLeader = message.Leader.InstanceId;
            _lastAttemptedView = 0;
            _lastInstalledView = 0;
            _state             = ElectionsState.Acceptor;
        }
Exemplo n.º 7
0
        private void ShiftToLeaderElection(int view)
        {
            Log.Debug("ELECTIONS: (V={view}) SHIFT TO LEADER ELECTION.", view);

            _state = ElectionsState.ElectingLeader;
            _vcReceived.Clear();
            _prepareOkReceived.Clear();
            _lastAttemptedView = view;

            _masterProposal = null;
            _master         = null;
            _acceptsReceived.Clear();

            var viewChangeMsg = new ElectionMessage.ViewChange(_nodeInfo.InstanceId, _nodeInfo.InternalHttp, view);

            Handle(viewChangeMsg);
            SendToAllExceptMe(viewChangeMsg);
            _publisher.Publish(TimerMessage.Schedule.Create(LeaderElectionProgressTimeout,
                                                            _publisherEnvelope,
                                                            new ElectionMessage.ElectionsTimedOut(view)));
        }
Exemplo n.º 8
0
 public void Handle(SystemMessage.BecomeShuttingDown message)
 {
     _state = ElectionsState.Shutdown;
 }