Class RandomizedElectionTimer

java.lang.Object
io.atomix.raft.impl.RandomizedElectionTimer
All Implemented Interfaces:
ElectionTimer

public class RandomizedElectionTimer extends Object implements ElectionTimer
An implementation of the default election in raft. It uses a randomized timeout to prevent multiple nodes from starting the election at the same time.
  • Constructor Details

    • RandomizedElectionTimer

      public RandomizedElectionTimer(Duration electionTimeout, ThreadContext threadContext, Random random, Runnable triggerElection, org.slf4j.Logger log)
  • Method Details

    • reset

      public void reset()
      Description copied from interface: ElectionTimer
      Reset the timer

      When `reset` is called, the previous timer is cancelled and a new timer will be started. After a specific duration, depending on the implementation, the election will be triggered.

      Specified by:
      reset in interface ElectionTimer
    • cancel

      public void cancel()
      Description copied from interface: ElectionTimer
      Cancel the timer
      Specified by:
      cancel in interface ElectionTimer