Interface RaftActorBehavior

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
AbstractLeader, AbstractRaftActorBehavior, Candidate, Follower, IsolatedLeader, Leader, PreLeader

public interface RaftActorBehavior extends AutoCloseable
The interface for a class that implements a specific behavior of a RaftActor. The types of behaviors are enumerated by RaftState. Each handles the same Raft messages differently.
  • Method Details

    • handleMessage

      @Nullable RaftActorBehavior handleMessage(akka.actor.ActorRef sender, Object message)
      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.
      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.
    • state

      RaftState state()
      Returns the state associated with this behavior.
      Returns:
      the RaftState
    • getLeaderId

      @Nullable String getLeaderId()
      Returns the id of the leader.
      Returns:
      the id of the leader or null if not known
    • setReplicatedToAllIndex

      void setReplicatedToAllIndex(long replicatedToAllIndex)
      Sets the index of the last log entry that has been replicated to all peers.
      Parameters:
      replicatedToAllIndex - the index
    • getReplicatedToAllIndex

      long getReplicatedToAllIndex()
      Returns the index of the last log entry that has been replicated to all peers.
      Returns:
      the index or -1 if not known
    • getLeaderPayloadVersion

      short getLeaderPayloadVersion()
      Returns the leader's payload data version.
      Returns:
      a short representing the version
    • switchBehavior

      RaftActorBehavior switchBehavior(RaftActorBehavior behavior)
      Closes the current behavior and switches to the specified behavior, if possible.
      Parameters:
      behavior - the new behavior to switch to
      Returns:
      the new behavior
    • close

      void close()
      Specified by:
      close in interface AutoCloseable