LOG.debug("{}: handleAppendEntries: {}", logName(), appendEntries);
}
+ // Some other candidate for the same term became a leader and sent us an append entry
+ if(currentTerm() == appendEntries.getTerm()){
+ LOG.debug("{}: New Leader sent an append entry to Candidate for term {} will switch to Follower",
+ logName(), currentTerm());
+
+ return switchBehavior(new Follower(context));
+ }
+
return this;
}
}
if (voteCount >= votesRequired) {
- return switchBehavior(new Leader(context));
+ return internalSwitchBehavior(RaftState.Leader);
}
return this;
if (rpc.getTerm() > context.getTermInformation().getCurrentTerm()) {
context.getTermInformation().updateAndPersist(rpc.getTerm(), null);
- return switchBehavior(new Follower(context));
+ return internalSwitchBehavior(RaftState.Follower);
}
}
// who we do not know about (as a peer)
// to send a message to the candidate
- return switchBehavior(new Leader(context));
+ return internalSwitchBehavior(RaftState.Leader);
}
startNewTerm();
scheduleElection(electionDuration());