ack-watch.asciidoc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. [float]
  2. [[api-java-ack-watch]]
  3. === Ack Watch API
  4. <<actions-ack-throttle, Acknowledging>> a watch enables you to manually throttle
  5. execution of the watch actions. The action's _acknowledgement state_ is stored in
  6. the `status.actions.<id>.ack.state` structure.
  7. The current status of the watch and the state of its actions are returned as part
  8. of the <<api-java-get-watch, Get Watch API>> response:
  9. [source,java]
  10. --------------------------------------------------
  11. GetWatchResponse getWatchResponse = watcherClient.prepareGetWatch("my-watch").get();
  12. State state = getWatchResponse.getStatus().actionStatus("my-action").ackStatus().state();
  13. --------------------------------------------------
  14. The action state of a newly created watch is `awaits_successful_execution`. When
  15. the watch runs and its condition is met, the state changes to `ackable`.
  16. Acknowledging the action sets the state to `acked`.
  17. When an action state is set to `acked`, further executions of that action are
  18. throttled until its state is reset to `awaits_successful_execution`. This happens
  19. when the watch condition is no longer met (the condition evaluates to `false`).
  20. The following snippet shows how to acknowledge an action. You specify the IDs of
  21. the watch and the action you want to acknowledge--in this example `my-watch` and
  22. `my-action`:
  23. [source,java]
  24. --------------------------------------------------
  25. AckWatchResponse ackResponse = watcherClient.prepareAckWatch("my-watch").setActionIds("my-action").get();
  26. --------------------------------------------------
  27. As a response to this request, the status of the watch and the state of the
  28. action are returned and can be obtained from `AckWatchResponse` object:
  29. [source,java]
  30. --------------------------------------------------
  31. WatchStatus status = ackResponse.getStatus();
  32. ActionStatus actionStatus = status.actionStatus("my-action");
  33. ActionStatus.AckStatus ackStatus = actionStatus.ackStatus();
  34. ActionStatus.AckStatus.State ackState = ackStatus.state();
  35. --------------------------------------------------
  36. You can acknowledge multiple actions:
  37. [source,java]
  38. --------------------------------------------------
  39. AckWatchResponse ackResponse = watcherClient.prepareAckWatch("my-watch")
  40. .setActionIds("action1", "action2")
  41. .get();
  42. --------------------------------------------------
  43. To acknowledge all actions of a watch, specify only the watch ID:
  44. [source,java]
  45. --------------------------------------------------
  46. AckWatchResponse ackResponse = watcherClient.prepareAckWatch("my-watch").get();
  47. --------------------------------------------------