예제 #1
0
        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);
        }
예제 #2
0
 private void InitializeInstanceFields()
 {
     _handler = new RaftMessageHandler(this);
 }