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
ConstructorsConstructorDescriptionClusterStateUpdateTask
(Priority priority) ClusterStateUpdateTask
(Priority priority, TimeValue timeout) ClusterStateUpdateTask
(TimeValue timeout) -
Method Summary
Modifier and TypeMethodDescriptionabstract ClusterState
execute
(ClusterState currentState) Computes the cluster state that results from executing this task on the given state.abstract void
A callback for when task execution fails.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
clusterStateProcessed
-
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
-
onFailure
A callback for when task execution fails. May receive aNotMasterException
if this node stopped being the master before this task was executed or aProcessClusterEventTimeoutException
if the task timed out before it was executed. If the task fails during execution then this method receives the corresponding exception. If the task executes successfully but the resulting cluster state publication fails then this method receives aFailedToCommitClusterStateException
. If publication fails then a new master is elected and the update might or might not take effect, depending on whether or not the newly-elected master accepted the published state that failed to be committed.Use
MasterService.isPublishFailureException(java.lang.Exception)
to detect the "expected" master failure cases if needed.Implementations of this callback should not throw exceptions: an exception thrown here is logged by the master service at
ERROR
level and otherwise ignored. If log-and-ignore is the right behaviour then implementations should do so themselves, typically using a more specific logger and at a less dramatic log level.- Specified by:
onFailure
in interfaceClusterStateTaskListener
-
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 priorites 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
-