Class Follower
- java.lang.Object
-
- org.opendaylight.controller.cluster.raft.behaviors.AbstractRaftActorBehavior
-
- org.opendaylight.controller.cluster.raft.behaviors.Follower
-
- All Implemented Interfaces:
AutoCloseable
,RaftActorBehavior
public class Follower extends AbstractRaftActorBehavior
The behavior of a RaftActor in the Follower raft state.- Respond to RPCs from candidates and leaders
- If election timeout elapses without receiving AppendEntries RPC from current leader or granting vote to candidate: convert to candidate
-
-
Field Summary
-
Fields inherited from class org.opendaylight.controller.cluster.raft.behaviors.AbstractRaftActorBehavior
context, log
-
-
Constructor Summary
Constructors Constructor Description Follower(RaftActorContext context)
Follower(RaftActorContext context, String initialLeaderId, short initialLeaderPayloadVersion)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
String
getLeaderId()
Returns the id of the leader.short
getLeaderPayloadVersion()
Returns the leader's payload data version.protected RaftActorBehavior
handleAppendEntries(ActorRef sender, AppendEntries appendEntries)
Derived classes should not directly handle AppendEntries messages it should let the base class handle it first.protected RaftActorBehavior
handleAppendEntriesReply(ActorRef sender, AppendEntriesReply appendEntriesReply)
Derived classes should not directly handle AppendEntriesReply messages it should let the base class handle it first.RaftActorBehavior
handleMessage(ActorRef sender, Object message)
Handle a message.protected RaftActorBehavior
handleRequestVoteReply(ActorRef sender, RequestVoteReply requestVoteReply)
Derived classes should not directly handle RequestVoteReply messages it should let the base class handle it first.protected void
setLeaderId(@Nullable String leaderId)
protected void
setLeaderPayloadVersion(short leaderPayloadVersion)
-
Methods inherited from class org.opendaylight.controller.cluster.raft.behaviors.AbstractRaftActorBehavior
actor, appendEntries, applyLogToStateMachine, canGrantVote, canStartElection, createBehavior, currentTerm, electionDuration, getId, getLogEntryIndex, getLogEntryOrSnapshotTerm, getLogEntryTerm, getMajorityVoteCount, getReplicatedToAllIndex, internalSwitchBehavior, internalSwitchBehavior, lastIndex, lastTerm, logName, performSnapshotWithoutCapture, requestVote, scheduleElection, setReplicatedToAllIndex, shouldUpdateTerm, state, stopElection, switchBehavior, votedFor
-
-
-
-
Constructor Detail
-
Follower
public Follower(RaftActorContext context)
-
Follower
public Follower(RaftActorContext context, String initialLeaderId, short initialLeaderPayloadVersion)
-
-
Method Detail
-
getLeaderId
public final String getLeaderId()
Description copied from interface:RaftActorBehavior
Returns the id of the leader.- Returns:
- the id of the leader or null if not known
-
setLeaderId
protected final void setLeaderId(@Nullable String leaderId)
-
getLeaderPayloadVersion
public short getLeaderPayloadVersion()
Description copied from interface:RaftActorBehavior
Returns the leader's payload data version.- Returns:
- a short representing the version
-
setLeaderPayloadVersion
protected final void setLeaderPayloadVersion(short leaderPayloadVersion)
-
handleAppendEntries
protected RaftActorBehavior handleAppendEntries(ActorRef sender, AppendEntries appendEntries)
Description copied from class:AbstractRaftActorBehavior
Derived classes should not directly handle AppendEntries messages it should let the base class handle it first. Once the base class handles the AppendEntries message and does the common actions that are applicable in all RaftState's it will delegate the handling of the AppendEntries message to the derived class to do more state specific handling by calling this method- Specified by:
handleAppendEntries
in classAbstractRaftActorBehavior
- Parameters:
sender
- The actor that sent this messageappendEntries
- The AppendEntries message- Returns:
- a new behavior if it was changed or the current behavior
-
handleAppendEntriesReply
protected RaftActorBehavior handleAppendEntriesReply(ActorRef sender, AppendEntriesReply appendEntriesReply)
Description copied from class:AbstractRaftActorBehavior
Derived classes should not directly handle AppendEntriesReply messages it should let the base class handle it first. Once the base class handles the AppendEntriesReply message and does the common actions that are applicable in all RaftState's it will delegate the handling of the AppendEntriesReply message to the derived class to do more state specific handling by calling this method- Specified by:
handleAppendEntriesReply
in classAbstractRaftActorBehavior
- Parameters:
sender
- The actor that sent this messageappendEntriesReply
- The AppendEntriesReply message- Returns:
- a new behavior if it was changed or the current behavior
-
handleRequestVoteReply
protected RaftActorBehavior handleRequestVoteReply(ActorRef sender, RequestVoteReply requestVoteReply)
Description copied from class:AbstractRaftActorBehavior
Derived classes should not directly handle RequestVoteReply messages it should let the base class handle it first. Once the base class handles the RequestVoteReply message and does the common actions that are applicable in all RaftState's it will delegate the handling of the RequestVoteReply message to the derived class to do more state specific handling by calling this method- Specified by:
handleRequestVoteReply
in classAbstractRaftActorBehavior
- Parameters:
sender
- The actor that sent this messagerequestVoteReply
- The RequestVoteReply message- Returns:
- a new behavior if it was changed or the current behavior
-
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 interfaceRaftActorBehavior
- Overrides:
handleMessage
in classAbstractRaftActorBehavior
- Parameters:
sender
- The sender of the messagemessage
- 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()
-
-