Exemplo n.º 1
0
        private void judge_Election()
        {
            StopThread();
            switch (ServerHandler_.election_state_)
            {
            case ElectionState.ElectionFailed:
                ServerHandler_.ToBeFollower();
                break;

            case ElectionState.ElectionSuccess:
                ServerHandler_.ToBeLeader();
                ServerHandler_.reInitLeader();
                break;

            case ElectionState.HigherTerm:
                ServerHandler_.ToBeFollower();
                break;

            case ElectionState.Stop:
                ServerHandler_.ToBeFollower();
                break;
            }
            SwitchThread();
            StartThread();
            ServerHandler_.is_election_done_ = false;
        }
Exemplo n.º 2
0
 private void judge_HigherTerm()
 {
     // 引发higher term的时候就已经把role改为了follower
     if (ServerHandler_.role != NodeRole.Follower)
     {
         // do nothing
     }
     else
     {
         lock (this)
         {
             StopThread();
             ServerHandler_.ToBeFollower();
             SwitchThread();
             StartThread();
             ServerHandler_.ToBeRunning();
         }
     }
 }