2017-03-28 17:23:01 -04:00
|
|
|
[float]
|
|
|
|
[[api-java-ack-watch]]
|
2019-09-30 13:18:50 -04:00
|
|
|
=== Ack watch API
|
2017-03-28 17:23:01 -04:00
|
|
|
|
2019-09-30 13:18:50 -04:00
|
|
|
<<actions-ack-throttle,Acknowledging>> a watch enables you to manually throttle
|
2017-03-28 17:23:01 -04:00
|
|
|
execution of the watch actions. The action's _acknowledgement state_ is stored in
|
2017-05-04 04:08:34 -04:00
|
|
|
the `status.actions.<id>.ack.state` structure.
|
2017-03-28 17:23:01 -04:00
|
|
|
|
|
|
|
The current status of the watch and the state of its actions are returned as part
|
2019-09-30 13:18:50 -04:00
|
|
|
of the <<api-java-get-watch,get watch API>> response:
|
2017-03-28 17:23:01 -04:00
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
GetWatchResponse getWatchResponse = watcherClient.prepareGetWatch("my-watch").get();
|
|
|
|
State state = getWatchResponse.getStatus().actionStatus("my-action").ackStatus().state();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
The action state of a newly created watch is `awaits_successful_execution`. When
|
|
|
|
the watch runs and its condition is met, the state changes to `ackable`.
|
|
|
|
Acknowledging the action sets the state to `acked`.
|
|
|
|
|
|
|
|
When an action state is set to `acked`, further executions of that action are
|
|
|
|
throttled until its state is reset to `awaits_successful_execution`. This happens
|
|
|
|
when the watch condition is no longer met (the condition evaluates to `false`).
|
|
|
|
|
|
|
|
The following snippet shows how to acknowledge an action. You specify the IDs of
|
|
|
|
the watch and the action you want to acknowledge--in this example `my-watch` and
|
|
|
|
`my-action`:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
AckWatchResponse ackResponse = watcherClient.prepareAckWatch("my-watch").setActionIds("my-action").get();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
As a response to this request, the status of the watch and the state of the
|
|
|
|
action are returned and can be obtained from `AckWatchResponse` object:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
WatchStatus status = ackResponse.getStatus();
|
|
|
|
ActionStatus actionStatus = status.actionStatus("my-action");
|
|
|
|
ActionStatus.AckStatus ackStatus = actionStatus.ackStatus();
|
|
|
|
ActionStatus.AckStatus.State ackState = ackStatus.state();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
You can acknowledge multiple actions:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
AckWatchResponse ackResponse = watcherClient.prepareAckWatch("my-watch")
|
|
|
|
.setActionIds("action1", "action2")
|
|
|
|
.get();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
To acknowledge all actions of a watch, specify only the watch ID:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
AckWatchResponse ackResponse = watcherClient.prepareAckWatch("my-watch").get();
|
|
|
|
--------------------------------------------------
|