- @Override protected RaftActorBehavior handleAppendEntries(ActorRef sender,
- AppendEntries appendEntries) {
+ @Override
+ protected RaftActorBehavior handleAppendEntries(ActorRef sender, AppendEntries appendEntries) {
+
+ 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.info("{}: New Leader {} sent an AppendEntries to Candidate for term {} - will switch to Follower",
+ logName(), appendEntries.getLeaderId(), currentTerm());