Class AckedBatchedClusterStateUpdateTask
- All Implemented Interfaces:
ClusterStateAckListener,ClusterStateTaskListener
-
Constructor Summary
ConstructorsConstructorDescriptionAckedBatchedClusterStateUpdateTask(TimeValue ackTimeout, ActionListener<AcknowledgedResponse> listener) -
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 byClusterStateAckListener.ackTimeout()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.voidA callback for when task execution fails.
-
Constructor Details
-
AckedBatchedClusterStateUpdateTask
public AckedBatchedClusterStateUpdateTask(TimeValue ackTimeout, ActionListener<AcknowledgedResponse> listener)
-
-
Method Details
-
onFailure
Description copied from interface:ClusterStateTaskListenerA callback for when task execution fails. May receive aNotMasterExceptionif this node stopped being the master before this task was executed or aProcessClusterEventTimeoutExceptionif 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
ERRORlevel 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.- Specified by:
onFailurein interfaceClusterStateTaskListener
-
mustAck
Description copied from interface:ClusterStateAckListenerCalled 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.
- Specified by:
mustAckin interfaceClusterStateAckListener- Returns:
trueif and only if this task will wait for an ack from the given node.
-
onAllNodesAcked
public void onAllNodesAcked()Description copied from interface:ClusterStateAckListenerCalled 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:
onAllNodesAckedin interfaceClusterStateAckListener
-
onAckFailure
Description copied from interface:ClusterStateAckListenerCalled 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:
onAckFailurein interfaceClusterStateAckListener- Parameters:
e- exception representing the failure.
-
onAckTimeout
public void onAckTimeout()Description copied from interface:ClusterStateAckListenerCalled if the acknowledgement timeout defined byClusterStateAckListener.ackTimeout()expires while still waiting for an acknowledgement from one or more of the selected nodes.- Specified by:
onAckTimeoutin interfaceClusterStateAckListener
-
ackTimeout
- Specified by:
ackTimeoutin interfaceClusterStateAckListener- 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:-
If the cluster state update fails before committing then the failure is always reported via
ClusterStateAckListener.onAckFailure(Exception)rather thanClusterStateAckListener.onAckTimeout(), 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 viaClusterStateAckListener.onAckTimeout()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 (viaClusterStateAckListener.onAckTimeout()) 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
-