+ if (context.getLastApplied() < context.getReplicatedLog().lastIndex()) {
+ log.info("{}: LastApplied index {} is behind last index {} - switching to PreLeader",
+ logName(), context.getLastApplied(), context.getReplicatedLog().lastIndex());
+ return internalSwitchBehavior(RaftState.PreLeader);
+ } else {
+ return internalSwitchBehavior(RaftState.Leader);
+ }