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_AppendEntries_Request req) throws java.io.IOException
            public override Outcome Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_AppendEntries_Request req)
            {
                if (req.LeaderTerm() < Ctx.term())
                {
                    Org.Neo4j.causalclustering.core.consensus.RaftMessages_AppendEntries_Response appendResponse = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_AppendEntries_Response(Ctx.myself(), Ctx.term(), false, -1, Ctx.entryLog().appendIndex());

                    Outcome.addOutgoingMessage(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(req.From(), appendResponse));
                    return(Outcome);
                }
                else if (req.LeaderTerm() == Ctx.term())
                {
                    throw new System.InvalidOperationException("Two leaders in the same term.");
                }
                else
                {
                    // There is a new leader in a later term, we should revert to follower. (ยง5.1)
                    StepDownToFollower(Outcome, Ctx);
                    Log.info("Moving to FOLLOWER state after receiving append request at term %d (my term is " + "%d) from %s", req.LeaderTerm(), Ctx.term(), req.From());
                    Appending.HandleAppendEntriesRequest(Ctx, Outcome, req, Log);
                    return(Outcome);
                }
            }