Class ShardStateAction.ShardStartedClusterStateTaskExecutor

java.lang.Object
org.elasticsearch.cluster.action.shard.ShardStateAction.ShardStartedClusterStateTaskExecutor
All Implemented Interfaces:
ClusterStateTaskExecutor<ShardStateAction.StartedShardUpdateTask>
Enclosing class:
ShardStateAction

public static class ShardStateAction.ShardStartedClusterStateTaskExecutor extends Object implements ClusterStateTaskExecutor<ShardStateAction.StartedShardUpdateTask>
  • Constructor Details

  • Method Details

    • execute

      Description copied from interface: ClusterStateTaskExecutor
      Update the cluster state based on the current state and the given tasks. Return batchExecutionContext.initialState() to avoid publishing any update.

      If this method throws an exception then the cluster state is unchanged and every task's ClusterStateTaskListener.onFailure(java.lang.Exception) method is called.

      A common implementation pattern is to iterate through the tasks, constructing a new and updated ClusterState for each one. This works ok but beware that constructing a whole new ClusterState can be somewhat expensive, and there may sometimes be surprisingly many tasks to process in the batch. If it's possible to accumulate the effects of the tasks at a lower level then you should do that instead.

      Returning batchExecutionContext.initialState() is an important and useful optimisation in most cases, but note that this fast-path exposes APIs to the risk of stale reads in the vicinity of a master failover: a node N that handles such a no-op task batch does not verify with its peers that it's still the master, and if it's not the master then another node M may already have become master and updated the state in a way that would be inconsistent with the response that N sends back to clients.

      Specified by:
      execute in interface ClusterStateTaskExecutor<ShardStateAction.StartedShardUpdateTask>
      Returns:
      The resulting cluster state after executing all the tasks. If batchExecutionContext.initialState() is returned then no update is published.
      Throws:
      Exception
    • clusterStatePublished

      public void clusterStatePublished(ClusterState newClusterState)
      Description copied from interface: ClusterStateTaskExecutor
      Callback invoked after new cluster state is published. Note that this method is not invoked if the cluster state was not updated. Note that this method will be executed using system context.
      Specified by:
      clusterStatePublished in interface ClusterStateTaskExecutor<ShardStateAction.StartedShardUpdateTask>
      Parameters:
      newClusterState - The new state which was published.