Class RaftActorLeadershipTransferCohort


  • public class RaftActorLeadershipTransferCohort
    extends Object
    A raft actor support class that participates in leadership transfer. An instance is created upon initialization of leadership transfer.

    The transfer process is as follows:

    1. Send a LeaderStateChanged message with a null leader Id to the local RoleChangeNotifier to notify clients that we no longer have a working leader.
    2. Send a LeaderTransitioning message to each follower so each can send LeaderStateChanged messages to their local RoleChangeNotifiers.
    3. Call RaftActor.pauseLeader(java.lang.Runnable) passing this RaftActorLeadershipTransferCohort instance. This allows derived classes to perform work prior to transferring leadership.
    4. When the pause is complete, the run method is called which in turn calls Leader.transferLeadership(RaftActorLeadershipTransferCohort).
    5. The Leader calls transferComplete() on successful completion.
    6. Wait a short period of time for the new leader to be elected to give the derived class a chance to possibly complete work that was suspended while we were transferring.
    7. On notification of the new leader from the RaftActor or on time out, notify RaftActorLeadershipTransferCohort.OnComplete callbacks.

    NOTE: All methods on this class must be called on the actor's thread dispatcher as they may access/modify internal state.

    Author:
    Thomas Pantelis
    • Method Detail

      • abortTransfer

        public void abortTransfer()
        This method is invoked to abort leadership transfer on failure.
      • transferComplete

        public void transferComplete()
        This method is invoked when leadership transfer was carried out and complete.
      • getRequestedFollowerId

        public Optional<String> getRequestedFollowerId()