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
,org.elasticsearch.common.lease.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 class
ZenDiscovery.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.String
DISCOVERY_REJOIN_ACTION_NAME
static Setting<java.lang.Integer>
JOIN_RETRY_ATTEMPTS_SETTING
static Setting<org.elasticsearch.common.unit.TimeValue>
JOIN_RETRY_DELAY_SETTING
static Setting<org.elasticsearch.common.unit.TimeValue>
JOIN_TIMEOUT_SETTING
static Setting<java.lang.Boolean>
MASTER_ELECTION_IGNORE_NON_MASTER_PINGS_SETTING
static Setting<org.elasticsearch.common.unit.TimeValue>
MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING
static Setting<java.lang.Integer>
MAX_PENDING_CLUSTER_STATES_SETTING
static Setting<java.lang.Integer>
MAX_PINGS_FROM_ANOTHER_MASTER_SETTING
static Setting<org.elasticsearch.common.unit.TimeValue>
PING_TIMEOUT_SETTING
static Setting<java.lang.Boolean>
SEND_LEAVE_REQUEST_SETTING
protected ZenPing
zenPing
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, RerouteService rerouteService)
-
Method Summary
Modifier and Type Method Description ClusterState
clusterState()
return the current cluster state of the nodeprotected void
doClose()
protected void
doStart()
protected void
doStop()
DiscoverySettings
getDiscoverySettings()
java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>>
getOnJoinValidators()
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.protected ZenPing
newZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, SeedHostsProvider hostsProvider)
void
onClusterStateCommitted(java.lang.String stateUUID, ActionListener<java.lang.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.ClusterState[]
pendingClusterStates()
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).protected void
rejoin(java.lang.String reason)
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
startInitialJoin()
Triggers the first join cycleDiscoveryStats
stats()
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.common.lease.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.common.unit.TimeValue> MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING -
MASTER_ELECTION_IGNORE_NON_MASTER_PINGS_SETTING
-
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
-
-
Constructor Details
-
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, 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
protected void doClose() throws java.io.IOException- Specified by:
doClose
in classAbstractLifecycleComponent
- Throws:
java.io.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<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
-
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
protected void rejoin(java.lang.String reason) -
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
public void onClusterStateCommitted(java.lang.String stateUUID, ActionListener<java.lang.Void> processedListener)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
public final java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>> getOnJoinValidators()
-