java.lang.Object
org.elasticsearch.cluster.ClusterStateUpdateTask
- All Implemented Interfaces:
ClusterStateTaskConfig
,ClusterStateTaskListener
- Direct Known Subclasses:
AckedClusterStateUpdateTask
,MigrationResultsUpdateTask
,SystemIndexMetadataUpgradeService.SystemIndexMetadataUpdateTask
public abstract class ClusterStateUpdateTask
extends Object
implements ClusterStateTaskConfig, ClusterStateTaskListener
A task that can update the cluster state.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.ClusterStateTaskConfig
ClusterStateTaskConfig.Basic
-
Constructor Summary
ConstructorDescriptionClusterStateUpdateTask
(Priority priority) ClusterStateUpdateTask
(Priority priority, TimeValue timeout) ClusterStateUpdateTask
(TimeValue timeout) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clusterStateProcessed
(ClusterState initialState, ClusterState newState) Called when the result of theexecute(org.elasticsearch.cluster.ClusterState)
method has been processed properly by all listeners.abstract ClusterState
execute
(ClusterState currentState) Computes the cluster state that results from executing this task on the given state.final Priority
priority()
ThePriority
for this cluster state update task configuration.final TimeValue
timeout()
If the cluster state update task wasn't processed by the provided timeout, callClusterStateTaskListener.onFailure(Exception)
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.cluster.ClusterStateTaskListener
onFailure
-
Constructor Details
-
ClusterStateUpdateTask
public ClusterStateUpdateTask() -
ClusterStateUpdateTask
-
ClusterStateUpdateTask
-
ClusterStateUpdateTask
-
-
Method Details
-
execute
Computes the cluster state that results from executing this task on the given state. Returns the *same instance* if no change is required, which is an important and valuable optimisation since it short-circuits the whole publication process and saves a bunch of time and effort.- Throws:
Exception
-
clusterStateProcessed
Called when the result of theexecute(org.elasticsearch.cluster.ClusterState)
method has been processed properly by all listeners. The parameter is the state that was ultimately published. Implementations of this callback must not throw exceptions: an exception thrown here is logged by the master 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. -
timeout
If the cluster state update task wasn't processed by the provided timeout, callClusterStateTaskListener.onFailure(Exception)
. May return null to indicate no timeout is needed (default).- Specified by:
timeout
in interfaceClusterStateTaskConfig
- Returns:
- the timeout, or null if one is not set
-
priority
Description copied from interface:ClusterStateTaskConfig
ThePriority
for this cluster state update task configuration. Avoid priorities other thanPriority.NORMAL
where possible. A stream of higher-priority tasks can starve lower-priority ones from running. Higher-priority tasks should definitely share aClusterStateTaskExecutor
instance so that they are executed in batches.- Specified by:
priority
in interfaceClusterStateTaskConfig
- Returns:
- the priority
-