public class LeaderRole extends Role
Modifier and Type | Method and Description |
---|---|
List<Follower> |
getFollowers()
Get this leader's known followers.
|
Timestamp |
getLeaseTimeout()
Get this leader's "lease timeout".
|
void |
stepDown()
Force this leader to step down.
|
String |
toString() |
getKVDatabase, isLeaderLeaseActiveAt, isLeaderLeaseActiveNow
public List<Follower> getFollowers()
The returned list is a copy; changes have no effect on this instance.
public Timestamp getLeaseTimeout()
This is the earliest possible time at which some other, new leader could be elected in a new term. Consequently, it is the earliest possible time at which any entry that this leader is unaware of could be appended to the Raft log, under the assumption that all nodes are configured with the same election timeout value.
Normally, if followers are responding to AppendRequest
s properly, this will be a value
in the (near) future. This allows the leader to make the assumption, up until that point in time,
that its log is fully up-to-date.
Until it hears from a majority of followers, a leader will not have a lease timeout established yet. This value is also not used or meaningful when this node is the only node in the cluster. In either case, this method returns null.
This method may also return null if a previous lease timeout has gotten very stale and in danger of rolling over (e.g., isolated leader).
public void stepDown()
IllegalStateException
- if this role is no longer active or election timer is not runningCopyright © 2022. All rights reserved.