Class ClusterStateUpdateTask

java.lang.Object
org.elasticsearch.cluster.ClusterStateUpdateTask
All Implemented Interfaces:
ClusterStateTaskConfig, ClusterStateTaskListener
Direct Known Subclasses:
AckedClusterStateUpdateTask, MigrationResultsUpdateTask, SystemIndexMetadataUpgradeService.SystemIndexMetadataUpdateTask

public abstract class ClusterStateUpdateTask extends Object implements ClusterStateTaskConfig, ClusterStateTaskListener
A task that can update the cluster state.
  • Constructor Details

    • ClusterStateUpdateTask

      public ClusterStateUpdateTask()
    • ClusterStateUpdateTask

      public ClusterStateUpdateTask(Priority priority)
    • ClusterStateUpdateTask

      public ClusterStateUpdateTask(org.elasticsearch.core.TimeValue timeout)
    • ClusterStateUpdateTask

      public ClusterStateUpdateTask(Priority priority, org.elasticsearch.core.TimeValue timeout)
  • Method Details

    • execute

      public abstract ClusterState execute(ClusterState currentState) throws Exception
      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.
      Throws:
      Exception
    • onFailure

      public abstract void onFailure(Exception e)
      A callback for when task execution fails.

      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 interface ClusterStateTaskListener
    • timeout

      @Nullable public final org.elasticsearch.core.TimeValue timeout()
      If the cluster state update task wasn't processed by the provided timeout, call ClusterStateTaskListener.onFailure(Exception). May return null to indicate no timeout is needed (default).
      Specified by:
      timeout in interface ClusterStateTaskConfig
      Returns:
      the timeout, or null if one is not set
    • priority

      public final Priority priority()
      Description copied from interface: ClusterStateTaskConfig
      The Priority for this cluster state update task configuration. Avoid priorites other than Priority.NORMAL where possible. A stream of higher-priority tasks can starve lower-priority ones from running. Higher-priority tasks should definitely share a ClusterStateTaskExecutor instance so that they are executed in batches.
      Specified by:
      priority in interface ClusterStateTaskConfig
      Returns:
      the priority