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, votedFor
protected 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)
AbstractRaftActorBehavior
handleAppendEntries
in class AbstractRaftActorBehavior
sender
- The actor that sent this messageappendEntries
- The AppendEntries messageprotected RaftActorBehavior handleAppendEntriesReply(akka.actor.ActorRef sender, AppendEntriesReply appendEntriesReply)
AbstractRaftActorBehavior
handleAppendEntriesReply
in class AbstractRaftActorBehavior
sender
- The actor that sent this messageappendEntriesReply
- The AppendEntriesReply messageprotected ClientRequestTracker removeClientRequestTracker(long logIndex)
AbstractRaftActorBehavior
removeClientRequestTracker
in class AbstractRaftActorBehavior
logIndex
- the log indexprotected RaftActorBehavior handleRequestVoteReply(akka.actor.ActorRef sender, RequestVoteReply requestVoteReply)
AbstractRaftActorBehavior
handleRequestVoteReply
in class AbstractRaftActorBehavior
sender
- The actor that sent this messagerequestVoteReply
- The RequestVoteReply messageprotected void beforeSendHeartbeat()
public RaftActorBehavior handleMessage(akka.actor.ActorRef sender, Object message)
RaftActorBehavior
handleMessage
in interface RaftActorBehavior
handleMessage
in class AbstractRaftActorBehavior
sender
- 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()
RaftActorBehavior
public final short getLeaderPayloadVersion()
RaftActorBehavior
protected boolean isLeaderIsolated()
public String printFollowerStates()
public FollowerLogInformation getFollower(String followerId)
public int followerLogSize()
Copyright © 2019 OpenDaylight. All rights reserved.