Package org.elasticsearch.cluster
Class ClusterStateUpdateTask
java.lang.Object
org.elasticsearch.cluster.ClusterStateUpdateTask
- All Implemented Interfaces:
ClusterStateTaskConfig,ClusterStateTaskExecutor<ClusterStateUpdateTask>,ClusterStateTaskListener
- Direct Known Subclasses:
AckedClusterStateUpdateTask,SystemIndexMetadataUpgradeService.SystemIndexMetadataUpdateTask
public abstract class ClusterStateUpdateTask extends java.lang.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.BasicNested classes/interfaces inherited from interface org.elasticsearch.cluster.ClusterStateTaskExecutor
ClusterStateTaskExecutor.ClusterTasksResult<T>, ClusterStateTaskExecutor.TaskResult -
Constructor Summary
Constructors Constructor Description ClusterStateUpdateTask()ClusterStateUpdateTask(Priority priority)ClusterStateUpdateTask(Priority priority, org.elasticsearch.common.unit.TimeValue timeout)ClusterStateUpdateTask(org.elasticsearch.common.unit.TimeValue timeout) -
Method Summary
Modifier and Type Method Description voidclusterStatePublished(ClusterChangedEvent clusterChangedEvent)Callback invoked after new cluster state is published.java.lang.StringdescribeTasks(java.util.List<ClusterStateUpdateTask> tasks)Builds a concise description of a list of tasks (to be used in logging etc.).abstract ClusterStateexecute(ClusterState currentState)Update the cluster state based on the current state.ClusterStateTaskExecutor.ClusterTasksResult<ClusterStateUpdateTask>execute(ClusterState currentState, java.util.List<ClusterStateUpdateTask> tasks)Update the cluster state based on the current state and the given tasks.abstract voidonFailure(java.lang.String source, java.lang.Exception e)A callback called when execute fails.Prioritypriority()ThePriorityfor this cluster state update task configuration.booleanrunOnlyOnMaster()Marked as final as cluster state update tasks should only run on master.org.elasticsearch.common.unit.TimeValuetimeout()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, waitMethods inherited from interface org.elasticsearch.cluster.ClusterStateTaskListener
clusterStateProcessed, onNoLongerMaster
-
Constructor Details
-
ClusterStateUpdateTask
public ClusterStateUpdateTask() -
ClusterStateUpdateTask
-
ClusterStateUpdateTask
public ClusterStateUpdateTask(org.elasticsearch.common.unit.TimeValue timeout) -
ClusterStateUpdateTask
-
-
Method Details
-
execute
public final ClusterStateTaskExecutor.ClusterTasksResult<ClusterStateUpdateTask> execute(ClusterState currentState, java.util.List<ClusterStateUpdateTask> tasks) throws java.lang.ExceptionDescription copied from interface:ClusterStateTaskExecutorUpdate the cluster state based on the current state and the given tasks. Return the *same instance* if no state should be changed.- Specified by:
executein interfaceClusterStateTaskExecutor<ClusterStateUpdateTask>- Throws:
java.lang.Exception
-
describeTasks
Description copied from interface:ClusterStateTaskExecutorBuilds 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:
describeTasksin interfaceClusterStateTaskExecutor<ClusterStateUpdateTask>
-
execute
Update the cluster state based on the current state. Return the *same instance* if no state should be changed.- Throws:
java.lang.Exception
-
onFailure
public abstract void onFailure(java.lang.String source, java.lang.Exception e)A callback called when execute fails.- Specified by:
onFailurein interfaceClusterStateTaskListener
-
clusterStatePublished
Description copied from interface:ClusterStateTaskExecutorCallback 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:
clusterStatePublishedin interfaceClusterStateTaskExecutor<ClusterStateUpdateTask>- Parameters:
clusterChangedEvent- the change event for this cluster state change, containing both old and new states
-
timeout
@Nullable public final org.elasticsearch.common.unit.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:
timeoutin interfaceClusterStateTaskConfig- Returns:
- the timeout, or null if one is not set
-
priority
Description copied from interface:ClusterStateTaskConfigThePriorityfor this cluster state update task configuration.- Specified by:
priorityin 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, useLocalClusterUpdateTaskinstead.- Specified by:
runOnlyOnMasterin interfaceClusterStateTaskExecutor<ClusterStateUpdateTask>
-