Class PreLeader

  • All Implemented Interfaces:
    AutoCloseable, RaftActorBehavior

    public class PreLeader
    extends AbstractLeader
    The behavior of a RaftActor when it is in the PreLeader state. This state performs all the duties of Leader with the added behavior of attempting to commit all uncommitted entries from the previous leader's term. Raft does not allow a leader to commit entries from a previous term by simply counting replicas - only entries from the leader's current term can be committed (§5.4.2). Rather then waiting for a client interaction to commit a new entry, the PreLeader state immediately appends a no-op entry (NoopPayload) to the log with the leader's current term. Once the no-op entry is committed, all prior entries are committed indirectly. Once all entries are committed, ie commitIndex matches the last log index, it switches to the normal Leader state.

    The use of a no-op entry in this manner is outlined in the last paragraph in §8 of the extended raft version.

    Author:
    Thomas Pantelis
    • Method Detail

      • handleMessage

        public RaftActorBehavior handleMessage​(ActorRef sender,
                                               Object message)
        Description copied from interface: RaftActorBehavior
        Handle a message. If the processing of the message warrants a state change then a new behavior should be returned otherwise this method should return the current behavior.
        Specified by:
        handleMessage in interface RaftActorBehavior
        Overrides:
        handleMessage in class AbstractLeader
        Parameters:
        sender - The sender of the message
        message - A message that needs to be processed
        Returns:
        The new behavior or current behavior, or null if the message was not handled.