コード例 #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_PreVote_Response res, org.neo4j.causalclustering.core.consensus.outcome.Outcome outcome, org.neo4j.causalclustering.core.consensus.state.ReadableRaftState ctx, org.neo4j.logging.Log log) throws java.io.IOException
            public override Outcome Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Response res, Outcome outcome, ReadableRaftState ctx, Log log)
            {
                if (res.Term() > ctx.Term())
                {
                    outcome.NextTerm    = res.Term();
                    outcome.PreElection = false;
                    log.Info("Aborting pre-election after receiving pre-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.AddPreVoteForMe(res.From());
                }

                if (isQuorum(ctx.VotingMembers(), outcome.PreVotesForMe))
                {
                    outcome.RenewElectionTimeout();
                    outcome.PreElection = false;
                    if (Election.StartRealElection(ctx, outcome, log))
                    {
                        outcome.NextRole = CANDIDATE;
                        log.Info("Moving to CANDIDATE state after successful pre-election stage");
                    }
                }
                return(outcome);
            }
コード例 #2
0
            public override Void Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Response preVoteResponse)
            {
                Channel.putLong(preVoteResponse.Term());
                Channel.put(( sbyte )(preVoteResponse.VoteGranted() ? 1 : 0));

                return(null);
            }