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 to be notified when
all the nodes have acknowledged a cluster state update request-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AckedClusterStateUpdateTask
(AckedRequest request, ActionListener<? extends AcknowledgedResponse> listener) protected
AckedClusterStateUpdateTask
(Priority priority, AckedRequest request, ActionListener<? extends AcknowledgedResponse> listener) -
Method Summary
Modifier and TypeMethodDescriptionfinal TimeValue
Acknowledgement timeout, maximum time interval to wait for acknowledgementsboolean
mustAck
(DiscoveryNode discoveryNode) Called to determine which nodes the acknowledgement is expected fromprotected AcknowledgedResponse
newResponse
(boolean acknowledged) void
Called after all the nodes have acknowledged the cluster state update request but at least one of them failed.void
Called once the acknowledgement timeout defined byackTimeout()
has expiredvoid
Called once all the nodes have acknowledged the cluster state update request.void
A callback for when task execution fails.Methods inherited from class org.elasticsearch.cluster.ClusterStateUpdateTask
clusterStateProcessed, execute, priority, timeout
-
Constructor Details
-
AckedClusterStateUpdateTask
protected AckedClusterStateUpdateTask(AckedRequest request, ActionListener<? extends AcknowledgedResponse> listener) -
AckedClusterStateUpdateTask
protected AckedClusterStateUpdateTask(Priority priority, AckedRequest request, ActionListener<? extends AcknowledgedResponse> listener)
-
-
Method Details
-
mustAck
Called to determine which nodes the acknowledgement is expected from- Specified by:
mustAck
in interfaceClusterStateAckListener
- 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 nodes have acknowledged the cluster state update request. Must be very lightweight execution, since it gets executed on the cluster service thread.- Specified by:
onAllNodesAcked
in interfaceClusterStateAckListener
-
onAckFailure
Description copied from interface:ClusterStateAckListener
Called after all the nodes have acknowledged the cluster state update request but at least one of them failed. Must be very lightweight execution, since it gets executed on the cluster service thread.- Specified by:
onAckFailure
in interfaceClusterStateAckListener
- Parameters:
e
- optional error that might have been thrown
-
newResponse
-
onAckTimeout
public void onAckTimeout()Called once the acknowledgement timeout defined byackTimeout()
has expired- Specified by:
onAckTimeout
in interfaceClusterStateAckListener
-
onFailure
Description copied from interface:ClusterStateTaskListener
A callback for when task execution fails. May receive aNotMasterException
if this node stopped being the master before this task was executed or aProcessClusterEventTimeoutException
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 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
ERROR
level 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:
onFailure
in interfaceClusterStateTaskListener
-
ackTimeout
Acknowledgement timeout, maximum time interval to wait for acknowledgements- Specified by:
ackTimeout
in interfaceClusterStateAckListener
- Returns:
- acknowledgement timeout, maximum time interval to wait for acknowledgements
-