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 classes/interfaces inherited from interface org.elasticsearch.cluster.coordination.ClusterStatePublisher
ClusterStatePublisher.AckListener
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
static Setting<org.elasticsearch.core.TimeValue>
static Setting<org.elasticsearch.core.TimeValue>
static Setting<org.elasticsearch.core.TimeValue>
static Setting<org.elasticsearch.core.TimeValue>
protected ZenPing
Fields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
Constructor Summary
ConstructorDescriptionZenDiscovery(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 void
doClose()
protected void
doStart()
protected void
doStop()
boolean
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 ZenPing
newZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, SeedHostsProvider hostsProvider)
void
onClusterStateCommitted(String stateUUID, ActionListener<Void> processedListener)
called when a cluster state has been committed and is ready to be processedvoid
onIncomingClusterState(ClusterState incomingState)
called when a new incoming cluster state has been received.void
publish(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 void
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.void
Triggers the first join cyclestats()
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 neededMethods 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.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:
doStart
in classAbstractLifecycleComponent
-
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
- Specified by:
doClose
in classAbstractLifecycleComponent
- Throws:
IOException
-
clusterState
Description copied from interface:PingContextProvider
return the current cluster state of the node- Specified by:
clusterState
in interfacePingContextProvider
-
publish
public void publish(ClusterChangedEvent clusterChangedEvent, ActionListener<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
-
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.IncomingClusterStateListener
called 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:
onIncomingClusterState
in interfacePublishClusterStateAction.IncomingClusterStateListener
-
onClusterStateCommitted
Description copied from interface:PublishClusterStateAction.IncomingClusterStateListener
called when a cluster state has been committed and is ready to be processed- Specified by:
onClusterStateCommitted
in interfacePublishClusterStateAction.IncomingClusterStateListener
-
getOnJoinValidators
-