Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.causalclustering.core.consensus.outcome.Outcome handle(org.neo4j.causalclustering.core.consensus.RaftMessages_Vote_Response res) throws java.io.IOException
            public override Outcome Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_Vote_Response res)
            {
                if (res.Term() > Ctx.term())
                {
                    Outcome.NextTerm = res.Term();
                    Outcome.NextRole = FOLLOWER;
                    Log.info("Moving to FOLLOWER state after receiving vote response from %s at term %d (I am at %d)", res.From(), res.Term(), Ctx.term());
                    return(Outcome);
                }
                else if (res.Term() < Ctx.term() || !res.VoteGranted())
                {
                    return(Outcome);
                }

                if (!res.From().Equals(Ctx.myself()))
                {
                    Outcome.addVoteForMe(res.From());
                }

                if (isQuorum(Ctx.votingMembers(), Outcome.VotesForMe))
                {
                    Outcome.Leader = Ctx.myself();
                    Appending.AppendNewEntry(Ctx, Outcome, new NewLeaderBarrier());
                    Leader.SendHeartbeats(Ctx, Outcome);

                    Outcome.LastLogIndexBeforeWeBecameLeader = Ctx.entryLog().appendIndex();
                    Outcome.electedLeader();
                    Outcome.renewElectionTimeout();
                    Outcome.NextRole = LEADER;
                    Log.info("Moving to LEADER state at term %d (I am %s), voted for by %s", Ctx.term(), Ctx.myself(), Outcome.VotesForMe);
                }
                return(Outcome);
            }
Example #2
0
            public override Void Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_Vote_Response voteResponse)
            {
                Channel.putLong(voteResponse.Term());
                Channel.put(( sbyte )(voteResponse.VoteGranted() ? 1 : 0));

                return(null);
            }