- All Implemented Interfaces:
Closeable
,AutoCloseable
,ClusterStatePublisher
,LifecycleComponent
,Releasable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static interface
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.coordination.ClusterStatePublisher
ClusterStatePublisher.AckListener
-
Field Summary
FieldsFields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
Constructor Summary
ConstructorsConstructorDescriptionCoordinator
(String nodeName, Settings settings, ClusterSettings clusterSettings, TransportService transportService, Client client, NamedWriteableRegistry namedWriteableRegistry, AllocationService allocationService, MasterService masterService, Supplier<CoordinationState.PersistedState> persistedStateSupplier, SeedHostsProvider seedHostsProvider, ClusterApplier clusterApplier, Collection<BiConsumer<DiscoveryNode, ClusterState>> onJoinValidators, Random random, RerouteService rerouteService, ElectionStrategy electionStrategy, NodeHealthService nodeHealthService, CircuitBreakerService circuitBreakerService, Reconfigurator reconfigurator, LeaderHeartbeatService leaderHeartbeatService, PreVoteCollector.Factory preVoteCollectorFactory, CompatibilityVersions compatibilityVersions, FeatureService featureService) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPeerFinderListener
(Coordinator.PeerFinderListener peerFinderListener) protected void
doClose()
Close this component.protected void
doStart()
Start this component.protected void
doStop()
Stop this component.This method returns an object containing information about why cluster formation failed, which can be useful in troubleshooting.void
boolean
void
publish
(ClusterStatePublicationEvent clusterStatePublicationEvent, ActionListener<Void> publishListener, ClusterStatePublisher.AckListener ackListener) Publishes an updatedClusterState
to all the nodes in the cluster: Send the updated state to all nodes.boolean
setInitialConfiguration
(CoordinationMetadata.VotingConfiguration votingConfiguration) Sets the initial configuration to the givenCoordinationMetadata.VotingConfiguration
.void
stats()
Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, start, stop
-
Field Details
-
PUBLISH_INFO_TIMEOUT_SETTING
-
PUBLISH_TIMEOUT_SETTING
-
SINGLE_NODE_CLUSTER_SEED_HOSTS_CHECK_INTERVAL_SETTING
-
COMMIT_STATE_ACTION_NAME
- See Also:
-
-
Constructor Details
-
Coordinator
public Coordinator(String nodeName, Settings settings, ClusterSettings clusterSettings, TransportService transportService, Client client, NamedWriteableRegistry namedWriteableRegistry, AllocationService allocationService, MasterService masterService, Supplier<CoordinationState.PersistedState> persistedStateSupplier, SeedHostsProvider seedHostsProvider, ClusterApplier clusterApplier, Collection<BiConsumer<DiscoveryNode, ClusterState>> onJoinValidators, Random random, RerouteService rerouteService, ElectionStrategy electionStrategy, NodeHealthService nodeHealthService, CircuitBreakerService circuitBreakerService, Reconfigurator reconfigurator, LeaderHeartbeatService leaderHeartbeatService, PreVoteCollector.Factory preVoteCollectorFactory, CompatibilityVersions compatibilityVersions, FeatureService featureService) - Parameters:
nodeName
- The name of the node, used to name theExecutorService
of theSeedHostsResolver
.onJoinValidators
- A collection of join validators to restrict which nodes may join the cluster.
-
-
Method Details
-
getClusterFormationState
This method returns an object containing information about why cluster formation failed, which can be useful in troubleshooting.- Returns:
- Information about why cluster formation failed
-
doStart
protected void doStart()Description copied from class:AbstractLifecycleComponent
Start this component. Typically that means doing things like launching background processes and registering listeners on other components. Other components have been initialized by this point, but may not yet be started.If this method throws an exception then the startup process will fail, but this component will not be stopped before it is closed.
This method is called while synchronized on
AbstractLifecycleComponent.lifecycle
. It is only called once in the lifetime of a component, although it may not be called at all if the startup process encountered some kind of fatal error, such as the failure of some other component to initialize or start.- Specified by:
doStart
in classAbstractLifecycleComponent
-
stats
-
startInitialJoin
public void startInitialJoin() -
doStop
protected void doStop()Description copied from class:AbstractLifecycleComponent
Stop this component. Typically that means doing the reverse of whateverAbstractLifecycleComponent.doStart()
does.This method is called while synchronized on
AbstractLifecycleComponent.lifecycle
. It is only called once in the lifetime of a component, after callingAbstractLifecycleComponent.doStart()
, although it will not be called at all if this component did not successfully start.- Specified by:
doStop
in classAbstractLifecycleComponent
-
doClose
Description copied from class:AbstractLifecycleComponent
Close this component. Typically that means doing the reverse of whatever happened during initialization, such as releasing resources acquired there.This method is called while synchronized on
AbstractLifecycleComponent.lifecycle
. It is called once in the lifetime of a component. If the component was started then it will be stopped before it is closed, and once it is closed it will not be started or stopped.- Specified by:
doClose
in classAbstractLifecycleComponent
- Throws:
IOException
-
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
-
getApplierState
-
publish
public void publish(ClusterStatePublicationEvent clusterStatePublicationEvent, ActionListener<Void> publishListener, ClusterStatePublisher.AckListener ackListener) Description copied from interface:ClusterStatePublisher
Publishes an updatedClusterState
to all the nodes in the cluster:- Send the updated state to all nodes. Typically we only send a
Diff
which each node combines with its local state to yield the updated state very cheaply. - Wait for enough master-eligible nodes to indicate that they have accepted the new state (i.e. written it to durable storage).
- Tell all the nodes that the new state is now committed and should be applied via
ClusterStateApplier.applyClusterState(org.elasticsearch.cluster.ClusterChangedEvent)
. - Finally, apply the state on the master.
- Specified by:
publish
in interfaceClusterStatePublisher
publishListener
- Notified when the publication completes, whether successful or not. In particular, publication may fail with aFailedToCommitClusterStateException
if this node didn't receive responses to indicate that enough other master-eligible nodes accepted this state. In that case this node stops being the elected master and the master election process starts again.If the publication completes successfully then every future state will be a descendant of the published state. If the publication completes exceptionally then the new state may or may not be lost. More precisely, if the published state was accepted by the node that wins the master election triggered by the publication failure then the new master will publish the state which the old master failed to publish.
If the publication completes successfully then the new state has definitely been applied on this node, and it has usually been applied on all other nodes too. However some nodes might have timed out or otherwise failed to apply the state, so it is possible that the last-applied state on some nodes is somewhat stale.
ackListener
- Notified when individual nodes acknowledge that they've applied the cluster state (or failed to do so).
- Send the updated state to all nodes. Typically we only send a
-
getOnJoinValidators
-
addPeerFinderListener
-
getFoundPeers
-
getPeerFinder
-