Package org.elasticsearch.discovery.zen
Class ZenDiscovery
java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.discovery.zen.ZenDiscovery
- All Implemented Interfaces:
Closeable,AutoCloseable,ClusterStatePublisher,LifecycleComponent,org.elasticsearch.core.Releasable,Discovery,PingContextProvider,PublishClusterStateAction.IncomingClusterStateListener
public class ZenDiscovery
extends AbstractLifecycleComponent
implements Discovery, PingContextProvider, PublishClusterStateAction.IncomingClusterStateListener
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.cluster.coordination.ClusterStatePublisher
ClusterStatePublisher.AckListener -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Stringstatic Setting<org.elasticsearch.core.TimeValue>static Setting<org.elasticsearch.core.TimeValue>static Setting<org.elasticsearch.core.TimeValue>static Setting<org.elasticsearch.core.TimeValue>protected ZenPingFields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle -
Constructor Summary
ConstructorsConstructorDescriptionZenDiscovery(Settings settings, ThreadPool threadPool, TransportService transportService, NamedWriteableRegistry namedWriteableRegistry, MasterService masterService, ClusterApplier clusterApplier, ClusterSettings clusterSettings, SeedHostsProvider hostsProvider, AllocationService allocationService, Collection<BiConsumer<DiscoveryNode,ClusterState>> onJoinValidators, RerouteService rerouteService) -
Method Summary
Modifier and TypeMethodDescriptionreturn the current cluster state of the nodeprotected voiddoClose()protected voiddoStart()protected voiddoStop()booleanreturns true if zen discovery is started and there is a currently a background thread active for (re)joining the cluster used for testing.protected ZenPingnewZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, SeedHostsProvider hostsProvider)voidonClusterStateCommitted(String stateUUID, ActionListener<Void> processedListener)called when a cluster state has been committed and is ready to be processedvoidonIncomingClusterState(ClusterState incomingState)called when a new incoming cluster state has been received.voidpublish(ClusterChangedEvent clusterChangedEvent, ActionListener<Void> publishListener, ClusterStatePublisher.AckListener ackListener)Publish all the changes to the cluster from the master (can be called just by the master).protected voidstatic booleanshouldIgnoreOrRejectNewClusterState(org.apache.logging.log4j.Logger logger, ClusterState currentState, ClusterState newClusterState)In the case we follow an elected master the new cluster state needs to have the same elected master and the new cluster state version needs to be equal or higher than our cluster state version.voidTriggers the first join cyclestats()static voidvalidateStateIsFromCurrentMaster(org.apache.logging.log4j.Logger logger, DiscoveryNodes currentNodes, ClusterState newClusterState)In the case we follow an elected master the new cluster state needs to have the same elected master This method checks for this and throws an exception if neededMethods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.common.component.LifecycleComponent
addLifecycleListener, lifecycleState, removeLifecycleListener, start, stopMethods inherited from interface org.elasticsearch.core.Releasable
close
-
Field Details
-
PING_TIMEOUT_SETTING
-
JOIN_TIMEOUT_SETTING
-
JOIN_RETRY_ATTEMPTS_SETTING
-
JOIN_RETRY_DELAY_SETTING
-
MAX_PINGS_FROM_ANOTHER_MASTER_SETTING
-
SEND_LEAVE_REQUEST_SETTING
-
MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING
public static final Setting<org.elasticsearch.core.TimeValue> MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING -
MASTER_ELECTION_IGNORE_NON_MASTER_PINGS_SETTING
-
MAX_PENDING_CLUSTER_STATES_SETTING
-
DISCOVERY_REJOIN_ACTION_NAME
- See Also:
- Constant Field Values
-
zenPing
-
-
Constructor Details
-
ZenDiscovery
public ZenDiscovery(Settings settings, ThreadPool threadPool, TransportService transportService, NamedWriteableRegistry namedWriteableRegistry, MasterService masterService, ClusterApplier clusterApplier, ClusterSettings clusterSettings, SeedHostsProvider hostsProvider, AllocationService allocationService, Collection<BiConsumer<DiscoveryNode,ClusterState>> onJoinValidators, RerouteService rerouteService)
-
-
Method Details
-
newZenPing
protected ZenPing newZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, SeedHostsProvider hostsProvider) -
doStart
protected void doStart()- Specified by:
doStartin classAbstractLifecycleComponent
-
startInitialJoin
public void startInitialJoin()Description copied from interface:DiscoveryTriggers the first join cycle- Specified by:
startInitialJoinin interfaceDiscovery
-
doStop
protected void doStop()- Specified by:
doStopin classAbstractLifecycleComponent
-
doClose
- Specified by:
doClosein classAbstractLifecycleComponent- Throws:
IOException
-
clusterState
Description copied from interface:PingContextProviderreturn the current cluster state of the node- Specified by:
clusterStatein interfacePingContextProvider
-
publish
public void publish(ClusterChangedEvent clusterChangedEvent, ActionListener<Void> publishListener, ClusterStatePublisher.AckListener ackListener)Description copied from interface:ClusterStatePublisherPublish 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 aFailedToCommitClusterStateExceptionto 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.AckListenerallows to keep track of the ack received from nodes, and verify whether they updated their own cluster state or not.- Specified by:
publishin interfaceClusterStatePublisher
-
stats
-
getDiscoverySettings
-
joiningCluster
public boolean joiningCluster()returns true if zen discovery is started and there is a currently a background thread active for (re)joining the cluster used for testing. -
pendingClusterStates
-
shouldIgnoreOrRejectNewClusterState
public static boolean shouldIgnoreOrRejectNewClusterState(org.apache.logging.log4j.Logger logger, ClusterState currentState, ClusterState newClusterState)In the case we follow an elected master the new cluster state needs to have the same elected master and the new cluster state version needs to be equal or higher than our cluster state version. If the first condition fails we reject the cluster state and throw an error. If the second condition fails we ignore the cluster state. -
validateStateIsFromCurrentMaster
public static void validateStateIsFromCurrentMaster(org.apache.logging.log4j.Logger logger, DiscoveryNodes currentNodes, ClusterState newClusterState)In the case we follow an elected master the new cluster state needs to have the same elected master This method checks for this and throws an exception if needed -
rejoin
-
onIncomingClusterState
Description copied from interface:PublishClusterStateAction.IncomingClusterStateListenercalled when a new incoming cluster state has been received. Should validate the incoming state and throw an exception if it's not a valid successor state.- Specified by:
onIncomingClusterStatein interfacePublishClusterStateAction.IncomingClusterStateListener
-
onClusterStateCommitted
Description copied from interface:PublishClusterStateAction.IncomingClusterStateListenercalled when a cluster state has been committed and is ready to be processed- Specified by:
onClusterStateCommittedin interfacePublishClusterStateAction.IncomingClusterStateListener
-
getOnJoinValidators
-