public static bool MultipleLeadersInSameTerm(ClusterState state) { ISet <long> termThatHaveALeader = new HashSet <long>(); foreach (KeyValuePair <MemberId, Role> entry in state.Roles.SetOfKeyValuePairs()) { RaftMessageHandler role = entry.Value.handler; if (role is Leader) { long term = state.States[entry.Key].term(); if (termThatHaveALeader.Contains(term)) { return(true); } else { termThatHaveALeader.Add(term); } } } return(false); }
private void InitializeInstanceFields() { _handler = new RaftMessageHandler(this); }