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); }
//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); }
public override Outcome Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Response response) { return(Outcome); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, java.util.List<Object> list) throws Exception public override void Decode(ChannelHandlerContext ctx, ByteBuf buffer, IList <object> list) { ReadableChannel channel = new NetworkReadableClosableChannelNetty4(buffer); ClusterId clusterId = ClusterId.Marshal.INSTANCE.unmarshal(channel); int messageTypeWire = channel.Int; Org.Neo4j.causalclustering.core.consensus.RaftMessages_Type[] values = Enum.GetValues(typeof(Org.Neo4j.causalclustering.core.consensus.RaftMessages_Type)); Org.Neo4j.causalclustering.core.consensus.RaftMessages_Type messageType = values[messageTypeWire]; MemberId from = RetrieveMember(channel); Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage result; if (messageType.Equals(VOTE_REQUEST)) { MemberId candidate = RetrieveMember(channel); long term = channel.Long; long lastLogIndex = channel.Long; long lastLogTerm = channel.Long; result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Vote_Request(from, term, candidate, lastLogIndex, lastLogTerm); } else if (messageType.Equals(VOTE_RESPONSE)) { long term = channel.Long; bool voteGranted = channel.Get() == 1; result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Vote_Response(from, term, voteGranted); } else if (messageType.Equals(PRE_VOTE_REQUEST)) { MemberId candidate = RetrieveMember(channel); long term = channel.Long; long lastLogIndex = channel.Long; long lastLogTerm = channel.Long; result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Request(from, term, candidate, lastLogIndex, lastLogTerm); } else if (messageType.Equals(PRE_VOTE_RESPONSE)) { long term = channel.Long; bool voteGranted = channel.Get() == 1; result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Response(from, term, voteGranted); } else if (messageType.Equals(APPEND_ENTRIES_REQUEST)) { // how many long term = channel.Long; long prevLogIndex = channel.Long; long prevLogTerm = channel.Long; long leaderCommit = channel.Long; long count = channel.Long; RaftLogEntry[] entries = new RaftLogEntry[( int )count]; for (int i = 0; i < count; i++) { long entryTerm = channel.Long; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.causalclustering.core.replication.ReplicatedContent content = marshal.unmarshal(channel); ReplicatedContent content = _marshal.unmarshal(channel); entries[i] = new RaftLogEntry(entryTerm, content); } result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_AppendEntries_Request(from, term, prevLogIndex, prevLogTerm, entries, leaderCommit); } else if (messageType.Equals(APPEND_ENTRIES_RESPONSE)) { long term = channel.Long; bool success = channel.Get() == 1; long matchIndex = channel.Long; long appendIndex = channel.Long; result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_AppendEntries_Response(from, term, success, matchIndex, appendIndex); } else if (messageType.Equals(NEW_ENTRY_REQUEST)) { ReplicatedContent content = _marshal.unmarshal(channel); result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request(from, content); } else if (messageType.Equals(HEARTBEAT)) { long leaderTerm = channel.Long; long commitIndexTerm = channel.Long; long commitIndex = channel.Long; result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat(from, leaderTerm, commitIndex, commitIndexTerm); } else if (messageType.Equals(HEARTBEAT_RESPONSE)) { result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_HeartbeatResponse(from); } else if (messageType.Equals(LOG_COMPACTION_INFO)) { long leaderTerm = channel.Long; long prevIndex = channel.Long; result = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_LogCompactionInfo(from, leaderTerm, prevIndex); } else { throw new System.ArgumentException("Unknown message type"); } list.Add(Org.Neo4j.causalclustering.core.consensus.RaftMessages_ReceivedInstantClusterIdAwareMessage.of(_clock.instant(), clusterId, result)); }
public override Outcome Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Response response, Outcome outcome, ReadableRaftState ctx, Log log) { return(outcome); }
//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 response) throws java.io.IOException public override Outcome Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Response response) { return(PreVoteResponseHandler.handle(response, Outcome, Ctx, Log)); }