Interface ClusterStateTaskExecutor.TaskContext<T extends ClusterStateTaskListener>
- Enclosing interface:
ClusterStateTaskExecutor<T extends ClusterStateTaskListener>
-
Method Summary
Modifier and TypeMethodDescriptionCreates a context which captures any response headers (e.g.getTask()
void
Record that the cluster state update task failed.void
Record that the task succeeded.void
success
(Runnable onPublicationSuccess, ClusterStateAckListener clusterStateAckListener) Record that the task succeeded.void
success
(Consumer<ClusterState> publishedStateConsumer) Deprecated.void
success
(Consumer<ClusterState> publishedStateConsumer, ClusterStateAckListener clusterStateAckListener) Deprecated.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(Runnable, ClusterStateAckListener)
, passing the task itself as theclusterStateAckListener
argument.- Parameters:
onPublicationSuccess
- An action executed when (if?) the cluster state update succeeds.
-
success
Deprecated.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(Consumer, ClusterStateAckListener)
, passing the task itself as theclusterStateAckListener
argument.- Parameters:
publishedStateConsumer
- A consumer of the cluster state that was ultimately published.The consumer 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
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:
onPublicationSuccess
- An action executed when (if?) the cluster state update succeeds.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
@Deprecated void success(Consumer<ClusterState> publishedStateConsumer, ClusterStateAckListener clusterStateAckListener) Deprecated.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:
publishedStateConsumer
- A consumer of the cluster state that was ultimately published.The consumer 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.
-
captureResponseHeaders
Releasable captureResponseHeaders()Creates a context which captures any response headers (e.g. deprecation warnings) to be fed to the task's listener on completion.
-