Package org.elasticsearch.cluster
Class ClusterStateUpdateTask
java.lang.Object
org.elasticsearch.cluster.ClusterStateUpdateTask
- All Implemented Interfaces:
ClusterStateTaskConfig
,ClusterStateTaskExecutor<ClusterStateUpdateTask>
,ClusterStateTaskListener
- Direct Known Subclasses:
AckedClusterStateUpdateTask
,MigrationResultsUpdateTask
,SystemIndexMetadataUpgradeService.SystemIndexMetadataUpdateTask
public abstract class ClusterStateUpdateTask
extends Object
implements ClusterStateTaskConfig, ClusterStateTaskExecutor<ClusterStateUpdateTask>, ClusterStateTaskListener
A task that can update the cluster state.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.ClusterStateTaskConfig
ClusterStateTaskConfig.Basic
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.ClusterStateTaskExecutor
ClusterStateTaskExecutor.ClusterTasksResult<T>, ClusterStateTaskExecutor.TaskResult
-
Constructor Summary
ConstructorDescriptionClusterStateUpdateTask
(Priority priority) ClusterStateUpdateTask
(Priority priority, org.elasticsearch.core.TimeValue timeout) ClusterStateUpdateTask
(org.elasticsearch.core.TimeValue timeout) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
clusterStatePublished
(ClusterStatePublicationEvent clusterStatePublicationEvent) Callback invoked after new cluster state is published.describeTasks
(List<ClusterStateUpdateTask> tasks) Builds a concise description of a list of tasks (to be used in logging etc.).abstract ClusterState
execute
(ClusterState currentState) Update the cluster state based on the current state.execute
(ClusterState currentState, List<ClusterStateUpdateTask> tasks) Update the cluster state based on the current state and the given tasks.abstract void
A callback for when task execution fails.final Priority
priority()
ThePriority
for this cluster state update task configuration.final boolean
Marked as final as cluster state update tasks should only run on master.final org.elasticsearch.core.TimeValue
timeout()
If the cluster state update task wasn't processed by the provided timeout, callClusterStateTaskListener.onFailure(String, 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, onNoLongerMaster
-
Constructor Details
-
ClusterStateUpdateTask
public ClusterStateUpdateTask() -
ClusterStateUpdateTask
-
ClusterStateUpdateTask
public ClusterStateUpdateTask(org.elasticsearch.core.TimeValue timeout) -
ClusterStateUpdateTask
-
-
Method Details
-
execute
public final ClusterStateTaskExecutor.ClusterTasksResult<ClusterStateUpdateTask> execute(ClusterState currentState, List<ClusterStateUpdateTask> tasks) throws Exception Description copied from interface:ClusterStateTaskExecutor
Update the cluster state based on the current state and the given tasks. Return the *same instance* if no state should be changed.- Specified by:
execute
in interfaceClusterStateTaskExecutor<ClusterStateUpdateTask>
- Throws:
Exception
-
describeTasks
Description copied from interface:ClusterStateTaskExecutor
Builds a concise description of a list of tasks (to be used in logging etc.). Note that the tasks given are not necessarily the same as those that will be passed toClusterStateTaskExecutor.execute(ClusterState, List)
. but are guaranteed to be a subset of them. This method can be called multiple times with different lists before execution. This allows groupd task description but the submitting source.- Specified by:
describeTasks
in interfaceClusterStateTaskExecutor<ClusterStateUpdateTask>
-
execute
Update the cluster state based on the current state. Return the *same instance* if no state should be changed.- Throws:
Exception
-
onFailure
A callback for when task execution fails. Implementations of this callback should not throw exceptions: an exception thrown here is logged by the master service atERROR
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
-
clusterStatePublished
Description copied from interface:ClusterStateTaskExecutor
Callback invoked after new cluster state is published. Note that this method is not invoked if the cluster state was not updated. Note that this method will be executed using system context.- Specified by:
clusterStatePublished
in interfaceClusterStateTaskExecutor<ClusterStateUpdateTask>
- Parameters:
clusterStatePublicationEvent
- the change event for this cluster state publication, containing both old and new states
-
timeout
@Nullable public final org.elasticsearch.core.TimeValue timeout()If the cluster state update task wasn't processed by the provided timeout, callClusterStateTaskListener.onFailure(String, 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.- Specified by:
priority
in interfaceClusterStateTaskConfig
- Returns:
- the priority
-
runOnlyOnMaster
public final boolean runOnlyOnMaster()Marked as final as cluster state update tasks should only run on master. For local requests, useLocalClusterUpdateTask
instead.- Specified by:
runOnlyOnMaster
in interfaceClusterStateTaskExecutor<ClusterStateUpdateTask>
-