Class AckedClusterStateUpdateTask

java.lang.Object
org.elasticsearch.cluster.ClusterStateUpdateTask
org.elasticsearch.cluster.AckedClusterStateUpdateTask
All Implemented Interfaces:
ClusterStateAckListener, ClusterStateTaskListener
Direct Known Subclasses:
RepositoriesService.RegisterRepositoryTask, RepositoriesService.UnregisterRepositoryTask

public abstract class AckedClusterStateUpdateTask extends ClusterStateUpdateTask implements ClusterStateAckListener
An extension interface to ClusterStateUpdateTask that allows the caller to be notified after the master has computed, published, accepted, committed, and applied the cluster state update AND only after the rest of the nodes (or a specified subset) have also accepted and applied the cluster state update.
  • Constructor Details

  • Method Details

    • mustAck

      public boolean mustAck(DiscoveryNode discoveryNode)
      Called to determine which nodes the acknowledgement is expected from
      Specified by:
      mustAck in interface ClusterStateAckListener
      Parameters:
      discoveryNode - a node
      Returns:
      true if the node is expected to send ack back, false otherwise
    • onAllNodesAcked

      public void onAllNodesAcked()
      Description copied from interface: ClusterStateAckListener
      Called once all the selected nodes have acknowledged the cluster state update request. Must be very lightweight execution, since it is executed on the cluster service thread.
      Specified by:
      onAllNodesAcked in interface ClusterStateAckListener
    • onAckFailure

      public void onAckFailure(Exception e)
      Description copied from interface: ClusterStateAckListener
      Called after all the selected nodes have acknowledged the cluster state update request but at least one of them failed. Must be very lightweight execution, since it is executed on the cluster service thread.
      Specified by:
      onAckFailure in interface ClusterStateAckListener
      Parameters:
      e - exception representing the failure.
    • newResponse

      protected AcknowledgedResponse newResponse(boolean acknowledged)
    • onAckTimeout

      public void onAckTimeout()
      Description copied from interface: ClusterStateAckListener
      Called if the acknowledgement timeout defined by ClusterStateAckListener.ackTimeout() expires while still waiting for an acknowledgement from one or more of the selected nodes.
      Specified by:
      onAckTimeout in interface ClusterStateAckListener
    • onFailure

      public void onFailure(Exception e)
      Description copied from interface: ClusterStateTaskListener
      A callback for when task execution fails. May receive a NotMasterException if this node stopped being the master before this task was executed or a ProcessClusterEventTimeoutException 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 a FailedToCommitClusterStateException. 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 an AssertionError. 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.

      Specified by:
      onFailure in interface ClusterStateTaskListener
    • ackTimeout

      public final TimeValue ackTimeout()
      Specified by:
      ackTimeout in interface ClusterStateAckListener
      Returns:
      acknowledgement timeout, i.e. the maximum time interval to wait for a full set of acknowledgements. This time interval is measured from the start of the publication (which is after computing the new cluster state and serializing it as a transport message). If the cluster state is committed (i.e. a quorum of master-eligible nodes have accepted the new state) and then the timeout elapses then the corresponding listener is completed via ClusterStateAckListener.onAckTimeout(). Although the time interval is measured from the start of the publication, it does not have any effect until the cluster state is committed:

      A timeout of TimeValue.MINUS_ONE means that the master should wait indefinitely for acknowledgements.

      A timeout of TimeValue.ZERO means that the master will complete this listener (via ClusterStateAckListener.onAckTimeout()) as soon as the state is committed, before any nodes have applied the new state.