Class ClusterApplierService
java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.cluster.service.ClusterApplierService
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ClusterApplier
,LifecycleComponent
,org.elasticsearch.core.Releasable
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Setting<org.elasticsearch.core.TimeValue>
static final String
Fields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
Constructor Summary
ConstructorDescriptionClusterApplierService
(String nodeName, Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a high priority applier of updated cluster states.void
addListener
(ClusterStateListener listener) Add a listener for updated cluster states.void
Add a listener for on/off local node master eventsvoid
addLowPriorityApplier
(ClusterStateApplier applier) Adds an applier which will be called after all high priority and normal appliers have been called.void
addStateApplier
(ClusterStateApplier applier) Adds a applier of updated cluster states.void
addTimeoutListener
(org.elasticsearch.core.TimeValue timeout, TimeoutClusterStateListener listener) Adds a cluster state listener that is expected to be removed during a short period of time.protected boolean
static boolean
asserts that the current thread is NOT the cluster state update threadprotected void
connectToNodesAndWait
(ClusterState newClusterState) protected final void
connectToNodesAsync
(ClusterState newClusterState, Runnable onCompletion) protected PrioritizedEsThreadPoolExecutor
protected void
doClose()
protected void
doStart()
protected void
doStop()
getStats()
void
onNewClusterState
(String source, Supplier<ClusterState> clusterStateSupplier, ActionListener<Void> listener) Method to invoke when a new cluster state is available to be appliedvoid
removeApplier
(ClusterStateApplier applier) Removes an applier of updated cluster states.void
removeListener
(ClusterStateListener listener) Removes a listener for updated cluster states.void
Removes a timeout listener for updated cluster states.void
runOnApplierThread
(String source, Priority priority, Consumer<ClusterState> clusterStateConsumer, ActionListener<Void> listener) Run the given clusterStateConsumer on the applier thread.void
setInitialState
(ClusterState initialState) Sets the initial state for this applier.void
setNodeConnectionsService
(NodeConnectionsService nodeConnectionsService) state()
The current cluster state.Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
-
Field Details
-
CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING
public static final Setting<org.elasticsearch.core.TimeValue> CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING -
CLUSTER_UPDATE_THREAD_NAME
- See Also:
-
-
Constructor Details
-
ClusterApplierService
public ClusterApplierService(String nodeName, Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool)
-
-
Method Details
-
setNodeConnectionsService
-
setInitialState
Description copied from interface:ClusterApplier
Sets the initial state for this applier. Should only be called once.- Specified by:
setInitialState
in interfaceClusterApplier
- Parameters:
initialState
- the initial state to set
-
doStart
protected void doStart()- Specified by:
doStart
in classAbstractLifecycleComponent
-
createThreadPoolExecutor
-
doStop
protected void doStop()- Specified by:
doStop
in classAbstractLifecycleComponent
-
doClose
protected void doClose()- Specified by:
doClose
in classAbstractLifecycleComponent
-
state
The current cluster state. Should be renamed to appliedClusterState -
addHighPriorityApplier
Adds a high priority applier of updated cluster states. -
addLowPriorityApplier
Adds an applier which will be called after all high priority and normal appliers have been called. -
addStateApplier
Adds a applier of updated cluster states. -
removeApplier
Removes an applier of updated cluster states. -
addListener
Add a listener for updated cluster states. Listeners are executed in the system thread context. -
removeListener
Removes a listener for updated cluster states. -
removeTimeoutListener
Removes a timeout listener for updated cluster states. -
addLocalNodeMasterListener
Add a listener for on/off local node master events -
addTimeoutListener
public void addTimeoutListener(@Nullable org.elasticsearch.core.TimeValue timeout, TimeoutClusterStateListener listener) Adds a cluster state listener that is expected to be removed during a short period of time. If provided, the listener will be notified once a specific time has elapsed. NOTE: the listener is not removed on timeout. This is the responsibility of the caller. -
runOnApplierThread
public void runOnApplierThread(String source, Priority priority, Consumer<ClusterState> clusterStateConsumer, ActionListener<Void> listener) Run the given clusterStateConsumer on the applier thread. Should only be used in tests and byIndicesStore
when it's deleting the data behind a shard that moved away from a node.- Parameters:
priority
-Priority.HIGH
unless in tests.
-
threadPool
-
onNewClusterState
public void onNewClusterState(String source, Supplier<ClusterState> clusterStateSupplier, ActionListener<Void> listener) Description copied from interface:ClusterApplier
Method to invoke when a new cluster state is available to be applied- Specified by:
onNewClusterState
in interfaceClusterApplier
- Parameters:
source
- information where the cluster state came fromclusterStateSupplier
- the cluster state supplier which provides the latest cluster state to applylistener
- notified after cluster state is applied. The implementation must not throw exceptions: an exception thrown by this listener is logged by the cluster applier service atERROR
level and otherwise ignored, except in tests where it raises anAssertionError
. If log-and-ignore is the right behaviour then implementations must do so themselves, typically using a more specific logger and at a less dramatic log level.
-
assertNotClusterStateUpdateThread
asserts that the current thread is NOT the cluster state update thread -
connectToNodesAndWait
-
connectToNodesAsync
-
applicationMayFail
protected boolean applicationMayFail() -
getStats
- Specified by:
getStats
in interfaceClusterApplier
-