Interface ClusterStateTaskExecutor.TaskContext<T extends ClusterStateTaskListener>
- Enclosing interface:
- ClusterStateTaskExecutor<T extends ClusterStateTaskListener>
-
Method Summary
Modifier and TypeMethodDescriptiongetTask()
void
Record that the cluster state update task failed.void
success
(ActionListener<ClusterState> publishListener) Record that the task succeeded.void
success
(ActionListener<ClusterState> publishListener, ClusterStateAckListener clusterStateAckListener) Record that the task succeeded.default void
success
(ClusterStateAckListener clusterStateAckListener) Record that the task succeeded.
-
Method Details
-
getTask
T getTask()- Returns:
- the task to be executed.
-
success
Record that the task succeeded.Note that some tasks implement
ClusterStateAckListener
and can listen for acks themselves. If so, you may not use this method and must instead callsuccess(ActionListener, ClusterStateAckListener)
, passing the task itself as theclusterStateAckListener
argument.- Parameters:
publishListener
- A listener for the completion of the resulting cluster state publication. This listener is completed with the cluster state that was published (or the publication exception that occurred) in the thread context in which the task was submitted. The task'sClusterStateTaskListener.clusterStateProcessed(org.elasticsearch.cluster.ClusterState, org.elasticsearch.cluster.ClusterState)
method is not called directly by the master service, nor isClusterStateTaskListener.onFailure(java.lang.Exception)
once the task execution has succeeded, but legacy implementations may supply a listener which calls those methods.The listener should prefer not to use the published state for things like determining the result of a task. The task may have been executed as part of a batch, and later tasks in the batch may overwrite the results from earlier tasks. Instead the listener should independently capture the information it needs to properly process the completion of a cluster state update.
-
success
void success(ActionListener<ClusterState> publishListener, ClusterStateAckListener clusterStateAckListener) Record that the task succeeded.Note that some tasks implement
ClusterStateAckListener
and can listen for acks themselves. If so, you must pass the task itself as theclusterStateAckListener
argument.- Parameters:
publishListener
- A listener for the completion of the resulting cluster state publication. This listener is completed with the cluster state that was published (or the publication exception that occurred) in the thread context in which the task was submitted. The task'sClusterStateTaskListener.clusterStateProcessed(org.elasticsearch.cluster.ClusterState, org.elasticsearch.cluster.ClusterState)
method is not called directly by the master service, nor isClusterStateTaskListener.onFailure(java.lang.Exception)
once the task execution has succeeded, but legacy implementations may use this listener to call those methods.The listener should prefer not to use the published state for things like determining the result of a task. The task may have been executed as part of a batch, and later tasks in the batch may overwrite the results from earlier tasks. Instead the listener should independently capture the information it needs to properly process the completion of a cluster state update.
clusterStateAckListener
- A listener for acknowledgements from nodes. If the publication succeeds then this listener is completed as nodes ack the state update. If the publication fails then the failure notification happens viapublishListener.onFailure()
: this listener is not notified.
-
success
Record that the task succeeded.Note that some tasks implement
ClusterStateAckListener
and can listen for acks themselves. If so, you must pass the task itself as theclusterStateAckListener
argument.This method is useful in cases where the task will take some action at the end of acking but takes no action at the end of publication. If publication fails then the task's
ClusterStateTaskListener.onFailure(java.lang.Exception)
method is called.- Parameters:
clusterStateAckListener
- A listener for acknowledgements from nodes. If the publication succeeds then this listener is completed as nodes ack the state update. If the publication fails then the failure notification happens viapublishListener.onFailure()
: this listener is not notified.
-
onFailure
Record that the cluster state update task failed.- Parameters:
failure
- The exception with which the task failed.
-