java.lang.Object
org.elasticsearch.cluster.ClusterStateUpdateTask
org.elasticsearch.upgrades.MigrationResultsUpdateTask
- All Implemented Interfaces:
ClusterStateTaskConfig
,ClusterStateTaskListener
Handles updating the
FeatureMigrationResults
in the cluster state.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.ClusterStateTaskConfig
ClusterStateTaskConfig.Basic
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clusterStateProcessed
(ClusterState oldState, ClusterState newState) Called when the result of theClusterStateTaskExecutor.execute(ClusterState, List)
method have been processed properly by all listeners.execute
(ClusterState currentState) Computes the cluster state that results from executing this task on the given state.void
A callback for when task execution fails.void
submit
(ClusterService clusterService) Submit the update task so that it will actually be executed.static MigrationResultsUpdateTask
upsert
(String featureName, SingleFeatureMigrationResult status, ActionListener<ClusterState> listener) Creates a task that will update the status of a feature migration.Methods inherited from class org.elasticsearch.cluster.ClusterStateUpdateTask
priority, timeout
-
Method Details
-
upsert
public static MigrationResultsUpdateTask upsert(String featureName, SingleFeatureMigrationResult status, ActionListener<ClusterState> listener) Creates a task that will update the status of a feature migration.- Parameters:
featureName
- The name of the feature whose status should be updated.status
- The status to be associated with the given feature.listener
- A listener that will be called upon successfully updating the cluster state.
-
submit
Submit the update task so that it will actually be executed.- Parameters:
clusterService
- The cluster service to which this task should be submitted.
-
execute
Description copied from class:ClusterStateUpdateTask
Computes the cluster state that results from executing this task on the given state. Returns the *same instance* if no change is required, which is an important and valuable optimisation since it short-circuits the whole publication process and saves a bunch of time and effort.- Specified by:
execute
in classClusterStateUpdateTask
- Throws:
Exception
-
clusterStateProcessed
Description copied from interface:ClusterStateTaskListener
Called when the result of theClusterStateTaskExecutor.execute(ClusterState, List)
method have been processed properly by all listeners. The parameter is the state that was ultimately published. This can lead to surprising behaviour if tasks are batched together: a later task in the batch may undo or overwrite the changes made by an earlier task. In general you should prefer to ignore the published state and instead handle the success of a publication via the listener that the executor passes toClusterStateTaskExecutor.TaskContext.success(org.elasticsearch.action.ActionListener<org.elasticsearch.cluster.ClusterState>)
. Implementations of this callback must not throw exceptions: an exception thrown here is logged by the master service atERROR
level and otherwise ignored, except in tests where it raises anAssertionError
. If log-and-ignore is the right behaviour then implementations must do so themselves, typically using a more specific logger and at a less dramatic log level. -
onFailure
Description copied from class:ClusterStateUpdateTask
A callback for when task execution fails. May receive aNotMasterException
if this node stopped being the master before this task was executed or aProcessClusterEventTimeoutException
if the task timed out before it was executed. If the task fails during execution then this method receives the corresponding exception. If the task executes successfully but the resulting cluster state publication fails then this method receives aFailedToCommitClusterStateException
. If publication fails then a new master is elected and the update might or might not take effect, depending on whether or not the newly-elected master accepted the published state that failed to be committed.Use
MasterService.isPublishFailureException(java.lang.Exception)
to detect the "expected" master failure cases if needed.Implementations of this callback should not throw exceptions: an exception thrown here is logged by the master service at
ERROR
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
- Specified by:
onFailure
in classClusterStateUpdateTask
-