Class LeaderRole

java.lang.Object
io.permazen.kv.raft.Role
io.permazen.kv.raft.LeaderRole

public class LeaderRole extends Role
Raft leader role.
  • Method Details

    • getFollowers

      public List<Follower> getFollowers()
      Get this leader's known followers.

      The returned list is a copy; changes have no effect on this instance.

      Returns:
      this leader's followers
    • getLeaseTimeout

      public Timestamp getLeaseTimeout()
      Get this leader's "lease timeout".

      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 AppendRequests 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).

      Returns:
      this leader's lease timeout, or null if none is established yet
    • stepDown

      public void stepDown()
      Force this leader to step down.
      Throws:
      IllegalStateException - if this role is no longer active or election timer is not running
    • toString

      public String toString()
      Specified by:
      toString in class Role