- All Known Implementing Classes:
AckedBatchedClusterStateUpdateTask,AckedClusterStateUpdateTask,RepositoriesService.RegisterRepositoryTask,RepositoriesService.UnregisterRepositoryTask
public interface ClusterStateAckListener
Interface that a cluster state update task can implement to indicate that it wishes to be notified when the update has been acked by
(some subset of) the nodes in the cluster. Nodes ack a cluster state update after successfully applying the resulting state. Note that
updates which do not change the cluster state are automatically reported as acked by all nodes without checking to see whether there are
any nodes that have not already applied this state.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanmustAck(DiscoveryNode discoveryNode) Called to determine the nodes from which an acknowledgement is expected.voidCalled after all the selected nodes have acknowledged the cluster state update request but at least one of them failed.voidCalled if the acknowledgement timeout defined byackTimeout()expires while still waiting for an acknowledgement from one or more of the selected nodes.voidCalled once all the selected nodes have acknowledged the cluster state update request.
-
Method Details
-
mustAck
Called to determine the nodes from which an acknowledgement is expected.This method will be called multiple times to determine the set of acking nodes, so it is crucial for it to return consistent results: Given the same listener instance and the same node parameter, the method implementation should return the same result.
- Returns:
trueif and only if this task will wait for an ack from the given node.
-
onAllNodesAcked
void onAllNodesAcked()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. -
onAckFailure
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.- Parameters:
e- exception representing the failure.
-
onAckTimeout
void onAckTimeout()Called if the acknowledgement timeout defined byackTimeout()expires while still waiting for an acknowledgement from one or more of the selected nodes. -
ackTimeout
TimeValue ackTimeout()- 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
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:-
If the cluster state update fails before committing then the failure is always reported via
onAckFailure(Exception)rather thanonAckTimeout(), and this may therefore happen some time after the timeout period elapses. -
If the cluster state update is eventually committed, but takes longer than
ackTimeoutto do so, then the corresponding listener will be completed viaonAckTimeout()when it is committed, and this may therefore happen some time after the timeout period elapses.
A timeout of
TimeValue.MINUS_ONEmeans that the master should wait indefinitely for acknowledgements.A timeout of
TimeValue.ZEROmeans that the master will complete this listener (viaonAckTimeout()) as soon as the state is committed, before any nodes have applied the new state. -
If the cluster state update fails before committing then the failure is always reported via
-