Class Coordinator
- java.lang.Object
-
- org.elasticsearch.common.component.AbstractLifecycleComponent
-
- org.elasticsearch.cluster.coordination.Coordinator
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,ClusterStatePublisher
,LifecycleComponent
,Releasable
,Discovery
public class Coordinator extends AbstractLifecycleComponent implements Discovery
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Coordinator.Mode
-
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.coordination.ClusterStatePublisher
ClusterStatePublisher.AckListener
-
-
Field Summary
Fields Modifier and Type Field Description static Setting<TimeValue>
PUBLISH_TIMEOUT_SETTING
static long
ZEN1_BWC_TERM
-
Fields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
-
Constructor Summary
Constructors Constructor Description Coordinator(java.lang.String nodeName, Settings settings, ClusterSettings clusterSettings, TransportService transportService, NamedWriteableRegistry namedWriteableRegistry, AllocationService allocationService, MasterService masterService, java.util.function.Supplier<CoordinationState.PersistedState> persistedStateSupplier, SeedHostsProvider seedHostsProvider, ClusterApplier clusterApplier, java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>> onJoinValidators, java.util.Random random)
-
Method Summary
Modifier and Type Method Description static Settings.Builder
addZen1Attribute(boolean isZen1Node, Settings.Builder builder)
protected void
doClose()
protected void
doStart()
protected void
doStop()
ClusterState
getApplierState()
java.lang.Iterable<DiscoveryNode>
getFoundPeers()
ClusterState
getLastAcceptedState()
java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>>
getOnJoinValidators()
void
invariant()
boolean
isInitialConfigurationSet()
static boolean
isZen1Node(DiscoveryNode discoveryNode)
void
publish(ClusterChangedEvent clusterChangedEvent, ActionListener<java.lang.Void> publishListener, ClusterStatePublisher.AckListener ackListener)
Publish all the changes to the cluster from the master (can be called just by the master).boolean
setInitialConfiguration(CoordinationMetaData.VotingConfiguration votingConfiguration)
Sets the initial configuration to the givenCoordinationMetaData.VotingConfiguration
.void
startInitialJoin()
Triggers the first join cycleDiscoveryStats
stats()
-
Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.component.LifecycleComponent
addLifecycleListener, lifecycleState, removeLifecycleListener, start, stop
-
Methods inherited from interface org.elasticsearch.common.lease.Releasable
close
-
-
-
-
Field Detail
-
ZEN1_BWC_TERM
public static final long ZEN1_BWC_TERM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Coordinator
public Coordinator(java.lang.String nodeName, Settings settings, ClusterSettings clusterSettings, TransportService transportService, NamedWriteableRegistry namedWriteableRegistry, AllocationService allocationService, MasterService masterService, java.util.function.Supplier<CoordinationState.PersistedState> persistedStateSupplier, SeedHostsProvider seedHostsProvider, ClusterApplier clusterApplier, java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>> onJoinValidators, java.util.Random random)
-
-
Method Detail
-
doStart
protected void doStart()
- Specified by:
doStart
in classAbstractLifecycleComponent
-
stats
public DiscoveryStats stats()
-
startInitialJoin
public void startInitialJoin()
Description copied from interface:Discovery
Triggers the first join cycle- Specified by:
startInitialJoin
in interfaceDiscovery
-
doStop
protected void doStop()
- Specified by:
doStop
in classAbstractLifecycleComponent
-
doClose
protected void doClose()
- Specified by:
doClose
in classAbstractLifecycleComponent
-
invariant
public void invariant()
-
isInitialConfigurationSet
public boolean isInitialConfigurationSet()
-
setInitialConfiguration
public boolean setInitialConfiguration(CoordinationMetaData.VotingConfiguration votingConfiguration)
Sets the initial configuration to the givenCoordinationMetaData.VotingConfiguration
. This method is safe to call more than once, as long as the argument to each call is the same.- Parameters:
votingConfiguration
- The nodes that should form the initial configuration.- Returns:
- whether this call successfully set the initial configuration - if false, the cluster has already been bootstrapped.
-
getLastAcceptedState
public ClusterState getLastAcceptedState()
-
getApplierState
@Nullable public ClusterState getApplierState()
-
publish
public void publish(ClusterChangedEvent clusterChangedEvent, ActionListener<java.lang.Void> publishListener, ClusterStatePublisher.AckListener ackListener)
Description copied from interface:ClusterStatePublisher
Publish all the changes to the cluster from the master (can be called just by the master). The publish process should apply this state to the master as well! The publishListener allows to wait for the publication to complete, which can be either successful completion, timing out or failing. The method is guaranteed to pass back aFailedToCommitClusterStateException
to the publishListener if the change is not committed and should be rejected. Any other exception signals that something bad happened but the change is committed. TheClusterStatePublisher.AckListener
allows to keep track of the ack received from nodes, and verify whether they updated their own cluster state or not.- Specified by:
publish
in interfaceClusterStatePublisher
-
getOnJoinValidators
public java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>> getOnJoinValidators()
-
getFoundPeers
public java.lang.Iterable<DiscoveryNode> getFoundPeers()
-
addZen1Attribute
public static Settings.Builder addZen1Attribute(boolean isZen1Node, Settings.Builder builder)
-
isZen1Node
public static boolean isZen1Node(DiscoveryNode discoveryNode)
-
-