Class ElectionSchedulerFactory
- java.lang.Object
-
- org.elasticsearch.cluster.coordination.ElectionSchedulerFactory
-
public class ElectionSchedulerFactory extends java.lang.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 Summary
Fields Modifier and Type Field Description static Setting<TimeValue>
ELECTION_BACK_OFF_TIME_SETTING
static Setting<TimeValue>
ELECTION_DURATION_SETTING
static Setting<TimeValue>
ELECTION_INITIAL_TIMEOUT_SETTING
static Setting<TimeValue>
ELECTION_MAX_TIMEOUT_SETTING
-
Constructor Summary
Constructors Constructor Description ElectionSchedulerFactory(Settings settings, java.util.Random random, ThreadPool threadPool)
-
Method Summary
Modifier and Type Method Description Releasable
startElectionScheduler(TimeValue gracePeriod, java.lang.Runnable scheduledRunnable)
Start the process to schedule repeated election attempts.java.lang.String
toString()
-
-
-
Constructor Detail
-
ElectionSchedulerFactory
public ElectionSchedulerFactory(Settings settings, java.util.Random random, ThreadPool threadPool)
-
-
Method Detail
-
startElectionScheduler
public Releasable startElectionScheduler(TimeValue gracePeriod, java.lang.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 java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-