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