cancel_tasks.asciidoc 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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[list-tasks-request-filter]
  16. --------------------------------------------------
  17. <1> Cancel a task
  18. <2> Cancel only cluster-related tasks
  19. <3> Cancel all tasks running on nodes nodeId1 and nodeId2
  20. ==== Synchronous Execution
  21. ["source","java",subs="attributes,callouts,macros"]
  22. --------------------------------------------------
  23. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-execute]
  24. --------------------------------------------------
  25. ==== Asynchronous Execution
  26. The asynchronous execution requires `CancelTasksRequest` instance and an
  27. `ActionListener` instance to be passed to the asynchronous method:
  28. ["source","java",subs="attributes,callouts,macros"]
  29. --------------------------------------------------
  30. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-execute-async]
  31. --------------------------------------------------
  32. <1> The `CancelTasksRequest` to execute and the `ActionListener` to use
  33. when the execution completes
  34. The asynchronous method does not block and returns immediately. Once it is
  35. completed the `ActionListener` is called back using the `onResponse` method
  36. if the execution successfully completed or using the `onFailure` method if
  37. it failed.
  38. A typical listener for `CancelTasksResponse` looks like:
  39. ["source","java",subs="attributes,callouts,macros"]
  40. --------------------------------------------------
  41. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-execute-listener]
  42. --------------------------------------------------
  43. <1> Called when the execution is successfully completed. The response is
  44. provided as an argument
  45. <2> Called in case of a failure. The raised exception is provided as an argument
  46. ==== Cancel Tasks Response
  47. ["source","java",subs="attributes,callouts,macros"]
  48. --------------------------------------------------
  49. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-tasks]
  50. --------------------------------------------------
  51. <1> List of cancelled tasks
  52. ["source","java",subs="attributes,callouts,macros"]
  53. --------------------------------------------------
  54. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-calc]
  55. --------------------------------------------------
  56. <1> List of cancelled tasks grouped by a node
  57. <2> List of cancelled tasks grouped by a parent task
  58. ["source","java",subs="attributes,callouts,macros"]
  59. --------------------------------------------------
  60. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-failures]
  61. --------------------------------------------------
  62. <1> List of node failures
  63. <2> List of task cancellation failures