Class PreLeader
- java.lang.Object
-
- org.opendaylight.controller.cluster.raft.behaviors.AbstractRaftActorBehavior
-
- org.opendaylight.controller.cluster.raft.behaviors.AbstractLeader
-
- org.opendaylight.controller.cluster.raft.behaviors.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
-
-
Field Summary
-
Fields inherited from class org.opendaylight.controller.cluster.raft.behaviors.AbstractRaftActorBehavior
context, log
-
-
Constructor Summary
Constructors Constructor Description PreLeader(RaftActorContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RaftActorBehavior
handleMessage(ActorRef sender, Object message)
Handle a message.-
Methods inherited from class org.opendaylight.controller.cluster.raft.behaviors.AbstractLeader
addFollower, beforeSendHeartbeat, close, followerLogSize, getFollower, getFollowerIds, getLeaderId, getLeaderPayloadVersion, getMinIsolatedLeaderPeerCount, handleAppendEntries, handleAppendEntriesReply, handleRequestVoteReply, initiateCaptureSnapshot, isLeaderIsolated, printFollowerStates, removeFollower, sendAppendEntries, updateMinReplicaCount
-
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
-
PreLeader
public PreLeader(RaftActorContext context)
-
-
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 interfaceRaftActorBehavior
- Overrides:
handleMessage
in classAbstractLeader
- 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.
-
-