Module org.elasticsearch.server
Package org.elasticsearch.cluster
Interface ClusterStateTaskListener
- All Known Implementing Classes:
AckedClusterStateUpdateTask
,ClusterStateUpdateTask
,JoinTask
,LocalMasterServiceTask
,MigrationResultsUpdateTask
,NodeRemovalClusterStateTaskExecutor.Task
,ReservedStateErrorTask
,ReservedStateUpdateTask
,ShardStateAction.FailedShardUpdateTask
,ShardStateAction.StartedShardUpdateTask
,SystemIndexMetadataUpgradeService.SystemIndexMetadataUpdateTask
,TransportClusterUpdateSettingsAction.ClusterUpdateSettingsTask
public interface ClusterStateTaskListener
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
clusterStateProcessed
(ClusterState oldState, ClusterState newState) Called when the result of theClusterStateTaskExecutor.execute(ClusterState, List)
method have been processed properly by all listeners.void
A callback for when task execution fails.
-
Method Details
-
onFailure
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 must not throw exceptions: an exception thrown here is logged by the master service at
ERROR
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. -
clusterStateProcessed
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(java.lang.Runnable)
. 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.
-