internal void DemoteCandidateToFollower() { Candidate candidate = (CurrentNode as Candidate); if (candidate != null) { Follower follower = new Follower(candidate.GetNodeId(), candidate.GetIP()); follower.UpdateTerm(candidate.GetPreviousTerm()); this.CurrentNode = follower; //candidate.Dispose(); follower.StartHeartbeatTimouts(); Logger.Log(string.Format("INFO (CTF) :: {0} demoted to Follower {1} .", candidate, follower)); } else { Logger.Log("WARNING ! WRONG CALL TO DEMOTE CANDIDATE TO FOLLOWER. CANDIDATE ALREADY DEMOTED."); } }
internal void DemoteLeaderToFollower() { Leader leader = (CurrentNode as Leader); if (leader != null) { Follower follower = new Follower(leader.GetNodeId(), leader.GetIP()); follower.UpdateTerm(leader.GetPreviousTerm()); this.CurrentNode = follower; //leader.Dispose(); follower.StartHeartbeatTimouts(); Logger.Log(string.Format("INFO (LTF) :: {0} demoted to Follower {1} .", leader, follower)); } else { Logger.Log("WARNING ! WRONG CALL TO DEMOTE LEADER TO FOLLOWER. LEADER ALREADY DEMOTED."); } }
public void PromoteFollowerToCandidate(Follower follower) { Candidate candidate = new Candidate(follower.GetNodeId(), follower.GetIP()); if (candidate != null) { candidate.IP = follower.IP; candidate.UpdateTerm(follower.CurrentStateData.Term); candidate.IncrementTerm(); this.CurrentNode = candidate; //follower.Dispose(); Logger.Log(string.Format("INFO (FTC) :: {0} promoted to Candidate {1} .", follower, candidate)); candidate.SendRequestVotesToFollowers(); } else { Logger.Log("WARNING ! FOLLOWER IS ALREADY PROMOTED TO CANDIDATE. NODE IS NOT A FOLLOWER."); } }
public void RegisterFollower(Follower follower) { Followers.Add(follower); }