Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void respondToPreVoteRequest(org.neo4j.causalclustering.core.consensus.state.ReadableRaftState state, org.neo4j.causalclustering.core.consensus.outcome.Outcome outcome, org.neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Request voteRequest, org.neo4j.function.ThrowingBooleanSupplier<java.io.IOException> willVoteFor) throws java.io.IOException
        private static void RespondToPreVoteRequest(ReadableRaftState state, Outcome outcome, Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Request voteRequest, ThrowingBooleanSupplier <IOException> willVoteFor)
        {
            if (voteRequest.Term() > state.Term())
            {
                outcome.NextTerm = voteRequest.Term();
            }

            outcome.AddOutgoingMessage(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(voteRequest.From(), new Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Response(state.Myself(), outcome.Term, willVoteFor.AsBoolean)));
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static void handleVoteRequest(org.neo4j.causalclustering.core.consensus.state.ReadableRaftState state, org.neo4j.causalclustering.core.consensus.outcome.Outcome outcome, org.neo4j.causalclustering.core.consensus.RaftMessages_Vote_Request voteRequest, org.neo4j.logging.Log log) throws java.io.IOException
        internal static void HandleVoteRequest(ReadableRaftState state, Outcome outcome, Org.Neo4j.causalclustering.core.consensus.RaftMessages_Vote_Request voteRequest, Log log)
        {
            if (voteRequest.Term() > state.Term())
            {
                outcome.NextTerm = voteRequest.Term();
                outcome.VotedFor = null;
            }

            bool votedForAnother      = outcome.VotedFor != null && !outcome.VotedFor.Equals(voteRequest.Candidate());
            bool willVoteForCandidate = ShouldVoteFor(state, outcome, voteRequest, votedForAnother, log);

            if (willVoteForCandidate)
            {
                outcome.VotedFor = voteRequest.From();
                outcome.RenewElectionTimeout();
            }

            outcome.AddOutgoingMessage(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(voteRequest.From(), new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Vote_Response(state.Myself(), outcome.Term, willVoteForCandidate)));
        }
Beispiel #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static void beat(org.neo4j.causalclustering.core.consensus.state.ReadableRaftState state, org.neo4j.causalclustering.core.consensus.outcome.Outcome outcome, org.neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat request, org.neo4j.logging.Log log) throws java.io.IOException
        internal static void Beat(ReadableRaftState state, Outcome outcome, Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat request, Log log)
        {
            if (request.LeaderTerm() < state.Term())
            {
                return;
            }

            outcome.PreElection  = false;
            outcome.NextTerm     = request.LeaderTerm();
            outcome.Leader       = request.From();
            outcome.LeaderCommit = request.CommitIndex();
            outcome.AddOutgoingMessage(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(request.From(), new Org.Neo4j.causalclustering.core.consensus.RaftMessages_HeartbeatResponse(state.Myself())));

            if (!Follower.LogHistoryMatches(state, request.CommitIndex(), request.CommitIndexTerm()))
            {
                return;
            }

            Follower.CommitToLogOnUpdate(state, request.CommitIndex(), request.CommitIndex(), outcome);
        }