java.lang.Object
org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior
org.opendaylight.controller.cluster.raft.behaviors.Candidate
All Implemented Interfaces:
AutoCloseable

public final class Candidate extends RaftActorBehavior
The behavior of a RaftActor when it is in the Candidate raft state.

Candidates (ยง5.2):

  • On conversion to candidate, start election:
    • Increment currentTerm
    • Vote for self
    • Reset election timer
    • Send RequestVote RPCs to all other servers
  • If votes received from majority of servers: become leader
  • If AppendEntries RPC received from new leader: convert to follower
  • If election timeout elapses: start new election
  • Method Details

    • getLeaderId

      public String getLeaderId()
      Description copied from class: RaftActorBehavior
      Returns the id of the leader.
      Specified by:
      getLeaderId in class RaftActorBehavior
      Returns:
      the id of the leader or null if not known
    • getLeaderPayloadVersion

      public short getLeaderPayloadVersion()
      Description copied from class: RaftActorBehavior
      Returns the leader's payload data version.
      Specified by:
      getLeaderPayloadVersion in class RaftActorBehavior
      Returns:
      a short representing the version
    • handleMessage

      public RaftActorBehavior handleMessage(org.apache.pekko.actor.ActorRef sender, Object message)
      Description copied from class: 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.
      Overrides:
      handleMessage in class RaftActorBehavior
      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.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in class RaftActorBehavior