Example #1
0
 private void judge_Timeout()
 {
     if (ServerHandler_.role == NodeRole.Candidate)
     {
         lock (this)
         {
             StopThread();
             SwitchThread();
             StartThread();
             ServerHandler_.ToBeRunning();
         }
     }
     else
     {
         ServerHandler_.LOG(String.Format("get Timeout state"));
     }
 }
Example #2
0
 private void judge_FindLeader()
 {
     if (ServerHandler_.role == NodeRole.Follower)
     {
         lock (this)
         {
             StopThread();
             SwitchThread();
             StartThread();
             ServerHandler_.ToBeRunning();
         }
     }
     else
     {
         ServerHandler_.LOG(String.Format("get FindLeader state"));
     }
 }
Example #3
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();
         }
     }
 }