Class ElectionSchedulerFactory

java.lang.Object
org.elasticsearch.cluster.coordination.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

    • ELECTION_INITIAL_TIMEOUT_SETTING

      public static final Setting<org.elasticsearch.core.TimeValue> ELECTION_INITIAL_TIMEOUT_SETTING
    • ELECTION_BACK_OFF_TIME_SETTING

      public static final Setting<org.elasticsearch.core.TimeValue> ELECTION_BACK_OFF_TIME_SETTING
    • ELECTION_MAX_TIMEOUT_SETTING

      public static final Setting<org.elasticsearch.core.TimeValue> ELECTION_MAX_TIMEOUT_SETTING
    • ELECTION_DURATION_SETTING

      public static final Setting<org.elasticsearch.core.TimeValue> ELECTION_DURATION_SETTING
  • Constructor Details

  • Method Details

    • startElectionScheduler

      public org.elasticsearch.core.Releasable startElectionScheduler(org.elasticsearch.core.TimeValue gracePeriod, Runnable scheduledRunnable)
      Start the process to schedule repeated election attempts.
      Parameters:
      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()
      Overrides:
      toString in class Object