public class Leader extends AbstractLeader
Leaders:
context, log
Constructor and Description |
---|
Leader(RaftActorContext context) |
Modifier and Type | Method and Description |
---|---|
protected void |
beforeSendHeartbeat() |
void |
close() |
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 originalMessage)
Handle a message.
|
void |
transferLeadership(RaftActorLeadershipTransferCohort leadershipTransferCohort)
Attempts to transfer leadership to a follower as per the raft paper (§3.10) as follows:
Start a timer (Stopwatch).
Send an initial AppendEntries heartbeat to all followers.
On AppendEntriesReply, check if the follower's new match Index matches the leader's last index
If it matches,
Send an additional AppendEntries to ensure the follower has applied all its log entries to its state.
Send an ElectionTimeout to the follower to immediately start an election.
Notify
RaftActorLeadershipTransferCohort.transferComplete() .
Otherwise if the election time out period elapses, notify
RaftActorLeadershipTransferCohort.abortTransfer() .
|
addFollower, followerLogSize, getFollower, getFollowerIds, getLeaderId, getLeaderPayloadVersion, getMinIsolatedLeaderPeerCount, handleAppendEntries, handleRequestVoteReply, initiateCaptureSnapshot, isLeaderIsolated, printFollowerStates, removeClientRequestTracker, removeFollower, sendAppendEntries, 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
public Leader(RaftActorContext context)
public RaftActorBehavior handleMessage(akka.actor.ActorRef sender, Object originalMessage)
RaftActorBehavior
handleMessage
in interface RaftActorBehavior
handleMessage
in class AbstractLeader
sender
- The sender of the messageoriginalMessage
- A message that needs to be processedprotected void beforeSendHeartbeat()
beforeSendHeartbeat
in class AbstractLeader
protected RaftActorBehavior handleAppendEntriesReply(akka.actor.ActorRef sender, AppendEntriesReply appendEntriesReply)
AbstractRaftActorBehavior
handleAppendEntriesReply
in class AbstractLeader
sender
- The actor that sent this messageappendEntriesReply
- The AppendEntriesReply messagepublic void transferLeadership(@Nonnull RaftActorLeadershipTransferCohort leadershipTransferCohort)
RaftActorLeadershipTransferCohort.transferComplete()
.RaftActorLeadershipTransferCohort.abortTransfer()
.leadershipTransferCohort
- the cohort participating in the leadership transferpublic void close()
close
in interface AutoCloseable
close
in interface RaftActorBehavior
close
in class AbstractLeader
Copyright © 2019 OpenDaylight. All rights reserved.