Package org.elasticsearch.discovery.zen
Class ZenDiscovery
- java.lang.Object
-
- org.elasticsearch.common.component.AbstractLifecycleComponent
-
- org.elasticsearch.discovery.zen.ZenDiscovery
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ClusterStatePublisher,LifecycleComponent,Releasable,Discovery,PingContextProvider,PublishClusterStateAction.IncomingClusterStateListener
public class ZenDiscovery extends AbstractLifecycleComponent implements Discovery, PingContextProvider, PublishClusterStateAction.IncomingClusterStateListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classZenDiscovery.RejoinClusterRequest-
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.coordination.ClusterStatePublisher
ClusterStatePublisher.AckListener
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDISCOVERY_REJOIN_ACTION_NAMEstatic Setting<java.lang.Integer>JOIN_RETRY_ATTEMPTS_SETTINGstatic Setting<TimeValue>JOIN_RETRY_DELAY_SETTINGstatic Setting<TimeValue>JOIN_TIMEOUT_SETTINGstatic Setting<java.lang.Boolean>MASTER_ELECTION_IGNORE_NON_MASTER_PINGS_SETTINGstatic Setting<TimeValue>MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTINGstatic Setting<java.lang.Integer>MAX_PENDING_CLUSTER_STATES_SETTINGstatic Setting<java.lang.Integer>MAX_PINGS_FROM_ANOTHER_MASTER_SETTINGstatic Setting<TimeValue>PING_TIMEOUT_SETTINGstatic Setting<java.lang.Boolean>SEND_LEAVE_REQUEST_SETTINGprotected ZenPingzenPing-
Fields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
-
Constructor Summary
Constructors Constructor Description ZenDiscovery(Settings settings, ThreadPool threadPool, TransportService transportService, NamedWriteableRegistry namedWriteableRegistry, MasterService masterService, ClusterApplier clusterApplier, ClusterSettings clusterSettings, SeedHostsProvider hostsProvider, AllocationService allocationService, java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>> onJoinValidators, GatewayMetaState gatewayMetaState, RerouteService rerouteService)
-
Method Summary
Modifier and Type Method Description ClusterStateclusterState()return the current cluster state of the nodeprotected voiddoClose()protected voiddoStart()protected voiddoStop()DiscoverySettingsgetDiscoverySettings()java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>>getOnJoinValidators()booleanjoiningCluster()returns 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(java.lang.String stateUUID, ActionListener<java.lang.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.ClusterState[]pendingClusterStates()voidpublish(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).protected voidrejoin(java.lang.String reason)static 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.voidstartInitialJoin()Triggers the first join cycleDiscoveryStatsstats()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 needed-
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
-
JOIN_RETRY_ATTEMPTS_SETTING
public static final Setting<java.lang.Integer> JOIN_RETRY_ATTEMPTS_SETTING
-
MAX_PINGS_FROM_ANOTHER_MASTER_SETTING
public static final Setting<java.lang.Integer> MAX_PINGS_FROM_ANOTHER_MASTER_SETTING
-
SEND_LEAVE_REQUEST_SETTING
public static final Setting<java.lang.Boolean> SEND_LEAVE_REQUEST_SETTING
-
MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING
public static final Setting<TimeValue> MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING
-
MASTER_ELECTION_IGNORE_NON_MASTER_PINGS_SETTING
public static final Setting<java.lang.Boolean> MASTER_ELECTION_IGNORE_NON_MASTER_PINGS_SETTING
-
MAX_PENDING_CLUSTER_STATES_SETTING
public static final Setting<java.lang.Integer> MAX_PENDING_CLUSTER_STATES_SETTING
-
DISCOVERY_REJOIN_ACTION_NAME
public static final java.lang.String DISCOVERY_REJOIN_ACTION_NAME
- See Also:
- Constant Field Values
-
zenPing
protected final ZenPing zenPing
-
-
Constructor Detail
-
ZenDiscovery
public ZenDiscovery(Settings settings, ThreadPool threadPool, TransportService transportService, NamedWriteableRegistry namedWriteableRegistry, MasterService masterService, ClusterApplier clusterApplier, ClusterSettings clusterSettings, SeedHostsProvider hostsProvider, AllocationService allocationService, java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>> onJoinValidators, GatewayMetaState gatewayMetaState, RerouteService rerouteService)
-
-
Method Detail
-
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
protected void doClose() throws java.io.IOException- Specified by:
doClosein classAbstractLifecycleComponent- Throws:
java.io.IOException
-
clusterState
public ClusterState clusterState()
Description copied from interface:PingContextProviderreturn the current cluster state of the node- Specified by:
clusterStatein interfacePingContextProvider
-
publish
public void publish(ClusterChangedEvent clusterChangedEvent, ActionListener<java.lang.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
public DiscoveryStats stats()
-
getDiscoverySettings
public DiscoverySettings 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
public ClusterState[] 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
protected void rejoin(java.lang.String reason)
-
onIncomingClusterState
public void onIncomingClusterState(ClusterState incomingState)
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
public void onClusterStateCommitted(java.lang.String stateUUID, ActionListener<java.lang.Void> processedListener)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
public final java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>> getOnJoinValidators()
-
-