Class ElectionSchedulerFactory


public class ElectionSchedulerFactory extends Object
It's provably impossible to guarantee that any leader election algorithm ever elects a leader, but they generally work (with probability that approaches 1 over time) as long as elections occur sufficiently infrequently, compared to the time it takes to send a message to another node and receive a response back. We do not know the round-trip latency here, but we can approximate it by attempting elections randomly at reasonably high frequency and backing off (linearly) until one of them succeeds. We also place an upper bound on the backoff so that if elections are failing due to a network partition that lasts for a long time then when the partition heals there is an election attempt reasonably quickly.
  • Field Details


      public static final Setting<TimeValue> ELECTION_INITIAL_TIMEOUT_SETTING

      public static final Setting<TimeValue> ELECTION_BACK_OFF_TIME_SETTING

      public static final Setting<TimeValue> ELECTION_MAX_TIMEOUT_SETTING

      public static final Setting<TimeValue> ELECTION_DURATION_SETTING
  • Constructor Details

  • Method Details

    • startElectionScheduler

      public Releasable startElectionScheduler(TimeValue gracePeriod, Runnable scheduledRunnable)
      Start the process to schedule repeated election attempts.
      gracePeriod - An initial period to wait before attempting the first election.
      scheduledRunnable - The action to run each time an election should be attempted.
    • toString

      public String toString()
      toString in class Object