public abstract class AbstractLeader extends AbstractRaftActorBehavior
Leaders:
context, log| Modifier | Constructor and Description |
|---|---|
protected |
AbstractLeader(RaftActorContext context,
RaftState state) |
protected |
AbstractLeader(RaftActorContext context,
RaftState state,
AbstractLeader initializeFromLeader) |
| Modifier and Type | Method and Description |
|---|---|
void |
addFollower(String followerId) |
protected void |
beforeSendHeartbeat() |
void |
close() |
int |
followerLogSize() |
FollowerLogInformation |
getFollower(String followerId) |
Collection<String> |
getFollowerIds()
Return an immutable collection of follower identifiers.
|
String |
getLeaderId()
Returns the id of the leader.
|
short |
getLeaderPayloadVersion()
Returns the leader's payload data version.
|
protected int |
getMinIsolatedLeaderPeerCount() |
protected RaftActorBehavior |
handleAppendEntries(akka.actor.ActorRef sender,
AppendEntries appendEntries)
Derived classes should not directly handle AppendEntries messages it
should let the base class handle it first.
|
protected RaftActorBehavior |
handleAppendEntriesReply(akka.actor.ActorRef sender,
AppendEntriesReply appendEntriesReply)
Derived classes should not directly handle AppendEntriesReply messages it
should let the base class handle it first.
|
RaftActorBehavior |
handleMessage(akka.actor.ActorRef sender,
Object message)
Handle a message.
|
protected RaftActorBehavior |
handleRequestVoteReply(akka.actor.ActorRef sender,
RequestVoteReply requestVoteReply)
Derived classes should not directly handle RequestVoteReply messages it
should let the base class handle it first.
|
boolean |
initiateCaptureSnapshot(String followerId)
Initiates a snapshot capture to install on a follower.
|
protected boolean |
isLeaderIsolated() |
String |
printFollowerStates() |
protected ClientRequestTracker |
removeClientRequestTracker(long logIndex)
Removes and returns the ClientRequestTracker for the specified log index.
|
void |
removeFollower(String followerId) |
protected void |
sendAppendEntries(long timeSinceLastActivityIntervalNanos,
boolean isHeartbeat) |
void |
updateMinReplicaCount() |
actor, appendEntries, applyLogToStateMachine, canGrantVote, canStartElection, createBehavior, currentTerm, electionDuration, getId, getLogEntryIndex, getLogEntryOrSnapshotTerm, getLogEntryTerm, getMajorityVoteCount, getReplicatedToAllIndex, internalSwitchBehavior, internalSwitchBehavior, lastIndex, lastTerm, logName, performSnapshotWithoutCapture, requestVote, scheduleElection, setReplicatedToAllIndex, state, stopElection, switchBehavior, votedForprotected AbstractLeader(RaftActorContext context, RaftState state, @Nullable AbstractLeader initializeFromLeader)
protected AbstractLeader(RaftActorContext context, RaftState state)
public final Collection<String> getFollowerIds()
public void addFollower(String followerId)
public void removeFollower(String followerId)
public void updateMinReplicaCount()
protected int getMinIsolatedLeaderPeerCount()
protected RaftActorBehavior handleAppendEntries(akka.actor.ActorRef sender, AppendEntries appendEntries)
AbstractRaftActorBehaviorhandleAppendEntries in class AbstractRaftActorBehaviorsender - The actor that sent this messageappendEntries - The AppendEntries messageprotected RaftActorBehavior handleAppendEntriesReply(akka.actor.ActorRef sender, AppendEntriesReply appendEntriesReply)
AbstractRaftActorBehaviorhandleAppendEntriesReply in class AbstractRaftActorBehaviorsender - The actor that sent this messageappendEntriesReply - The AppendEntriesReply messageprotected ClientRequestTracker removeClientRequestTracker(long logIndex)
AbstractRaftActorBehaviorremoveClientRequestTracker in class AbstractRaftActorBehaviorlogIndex - the log indexprotected RaftActorBehavior handleRequestVoteReply(akka.actor.ActorRef sender, RequestVoteReply requestVoteReply)
AbstractRaftActorBehaviorhandleRequestVoteReply in class AbstractRaftActorBehaviorsender - The actor that sent this messagerequestVoteReply - The RequestVoteReply messageprotected void beforeSendHeartbeat()
public RaftActorBehavior handleMessage(akka.actor.ActorRef sender, Object message)
RaftActorBehaviorhandleMessage in interface RaftActorBehaviorhandleMessage in class AbstractRaftActorBehaviorsender - The sender of the messagemessage - A message that needs to be processedprotected void sendAppendEntries(long timeSinceLastActivityIntervalNanos,
boolean isHeartbeat)
public boolean initiateCaptureSnapshot(String followerId)
Install Snapshot works as follows 1. Leader initiates the capture snapshot by calling createSnapshot on the RaftActor. 2. On receipt of the CaptureSnapshotReply message, the RaftActor persists the snapshot and makes a call to the Leader's handleMessage with a SendInstallSnapshot message. 3. The Leader obtains and stores the Snapshot from the SendInstallSnapshot message and sends it in chunks to the Follower via InstallSnapshot messages. 4. For each chunk, the Follower sends back an InstallSnapshotReply. 5. On receipt of the InstallSnapshotReply for the last chunk, the Leader marks the install complete for that follower. 6. If another follower requires a snapshot and a snapshot has been collected (via SendInstallSnapshot) then send the existing snapshot in chunks to the follower.
followerId - the id of the follower.public void close()
public final String getLeaderId()
RaftActorBehaviorpublic final short getLeaderPayloadVersion()
RaftActorBehaviorprotected boolean isLeaderIsolated()
public String printFollowerStates()
public FollowerLogInformation getFollower(String followerId)
public int followerLogSize()
Copyright © 2019 OpenDaylight. All rights reserved.