Package org.elasticsearch.cluster
Class ClusterStateUpdateTask
- java.lang.Object
-
- org.elasticsearch.cluster.ClusterStateUpdateTask
-
- All Implemented Interfaces:
ClusterStateTaskConfig
,ClusterStateTaskExecutor<ClusterStateUpdateTask>
,ClusterStateTaskListener
- Direct Known Subclasses:
AckedClusterStateUpdateTask
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.Basic
-
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.ClusterStateTaskExecutor
ClusterStateTaskExecutor.ClusterTasksResult<T>, ClusterStateTaskExecutor.TaskResult
-
-
Constructor Summary
Constructors Constructor Description ClusterStateUpdateTask()
ClusterStateUpdateTask(Priority priority)
-
Method Summary
Modifier and Type Method Description void
clusterStatePublished(ClusterChangedEvent clusterChangedEvent)
Callback invoked after new cluster state is published.java.lang.String
describeTasks(java.util.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.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 void
onFailure(java.lang.String source, java.lang.Exception e)
A callback called when execute fails.Priority
priority()
ThePriority
for this cluster state update task configuration.boolean
runOnlyOnMaster()
Marked as final as cluster state update tasks should only run on master.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 Detail
-
ClusterStateUpdateTask
public ClusterStateUpdateTask()
-
ClusterStateUpdateTask
public ClusterStateUpdateTask(Priority priority)
-
-
Method Detail
-
execute
public final ClusterStateTaskExecutor.ClusterTasksResult<ClusterStateUpdateTask> execute(ClusterState currentState, java.util.List<ClusterStateUpdateTask> tasks) throws java.lang.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:
java.lang.Exception
-
describeTasks
public java.lang.String describeTasks(java.util.List<ClusterStateUpdateTask> tasks)
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
public abstract ClusterState execute(ClusterState currentState) throws java.lang.Exception
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:
onFailure
in interfaceClusterStateTaskListener
-
clusterStatePublished
public final void clusterStatePublished(ClusterChangedEvent clusterChangedEvent)
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:
clusterChangedEvent
- the change event for this cluster state change, containing both old and new states
-
timeout
@Nullable public 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
public Priority 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>
-
-