cancel_tasks.asciidoc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. [[java-rest-high-cluster-cancel-tasks]]
  2. === Cancel Tasks API
  3. The Cancel Tasks API allows cancellation of a currently running task.
  4. ==== Cancel Tasks Request
  5. A `CancelTasksRequest`:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-request]
  9. --------------------------------------------------
  10. There are no required parameters. The task cancellation command supports the same
  11. task selection parameters as the list tasks command.
  12. ==== Parameters
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-request-filter]
  16. --------------------------------------------------
  17. <1> Cancel a task
  18. <2> Cancel only cluster-related tasks
  19. <3> Should the request block until the cancellation of the task and its child tasks is completed.
  20. Otherwise, the request can return soon after the cancellation is started. Defaults to `false`.
  21. <4> Cancel all tasks running on nodes nodeId1 and nodeId2
  22. ==== Synchronous Execution
  23. ["source","java",subs="attributes,callouts,macros"]
  24. --------------------------------------------------
  25. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-execute]
  26. --------------------------------------------------
  27. ==== Asynchronous Execution
  28. The asynchronous execution requires `CancelTasksRequest` instance and an
  29. `ActionListener` instance to be passed to the asynchronous method:
  30. ["source","java",subs="attributes,callouts,macros"]
  31. --------------------------------------------------
  32. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-execute-async]
  33. --------------------------------------------------
  34. <1> The `CancelTasksRequest` to execute and the `ActionListener` to use
  35. when the execution completes
  36. The asynchronous method does not block and returns immediately. Once it is
  37. completed the `ActionListener` is called back using the `onResponse` method
  38. if the execution successfully completed or using the `onFailure` method if
  39. it failed.
  40. A typical listener for `CancelTasksResponse` looks like:
  41. ["source","java",subs="attributes,callouts,macros"]
  42. --------------------------------------------------
  43. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-execute-listener]
  44. --------------------------------------------------
  45. <1> Called when the execution is successfully completed. The response is
  46. provided as an argument
  47. <2> Called in case of a failure. The raised exception is provided as an argument
  48. ==== Cancel Tasks Response
  49. ["source","java",subs="attributes,callouts,macros"]
  50. --------------------------------------------------
  51. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-response-tasks]
  52. --------------------------------------------------
  53. <1> List of cancelled tasks
  54. ["source","java",subs="attributes,callouts,macros"]
  55. --------------------------------------------------
  56. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-response-calc]
  57. --------------------------------------------------
  58. <1> List of cancelled tasks grouped by a node
  59. <2> List of cancelled tasks grouped by a parent task
  60. ["source","java",subs="attributes,callouts,macros"]
  61. --------------------------------------------------
  62. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-response-failures]
  63. --------------------------------------------------
  64. <1> List of node failures
  65. <2> List of task cancellation failures