triggerReplicateFutures(prevIndex + 1, prevIndex + entries.size());
replicate();
}
} else {
if (response.term() > state.currentTerm()) {
triggerReplicateFutures(prevIndex, prevIndex, new CopycatException("Not the leader"));
state.transition(FollowerController.class);
} else {
// If replication failed then use the last log index indicated by
// the replica in the response to generate a new nextIndex. This allows
// us to skip repeatedly replicating one entry at a time if it's not