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
,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 class
ZenDiscovery.NodeRemovalClusterStateTaskExecutor
static class
ZenDiscovery.RejoinClusterRequest
-
Nested classes/interfaces inherited from interface org.elasticsearch.discovery.Discovery
Discovery.AckListener, Discovery.FailedToCommitClusterStateException
-
-
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<TimeValue>
JOIN_RETRY_DELAY_SETTING
static Setting<TimeValue>
JOIN_TIMEOUT_SETTING
static Setting<java.lang.Boolean>
MASTER_ELECTION_IGNORE_NON_MASTER_PINGS_SETTING
static Setting<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<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, UnicastHostsProvider hostsProvider, AllocationService allocationService, java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>> onJoinValidators)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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, UnicastHostsProvider 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, Discovery.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 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, UnicastHostsProvider hostsProvider, AllocationService allocationService, java.util.Collection<java.util.function.BiConsumer<DiscoveryNode,ClusterState>> onJoinValidators)
-
-
Method Detail
-
newZenPing
protected ZenPing newZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, UnicastHostsProvider 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
public ClusterState 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, Discovery.AckListener ackListener)
Description copied from interface:Discovery
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! TheDiscovery.AckListener
allows to keep track of the ack received from nodes, and verify whether they updated their own cluster state or not. The method is guaranteed to throw aDiscovery.FailedToCommitClusterStateException
if the change is not committed and should be rejected. Any other exception signals the something wrong happened but the change is committed.
-
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.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()
-
-