list_tasks.asciidoc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. [[java-rest-high-tasks-list]]
  2. === List Tasks API
  3. The List Tasks API allows to get information about the tasks currently executing in the cluster.
  4. [[java-rest-high-cluster-list-tasks-request]]
  5. ==== List Tasks Request
  6. A `ListTasksRequest`:
  7. ["source","java",subs="attributes,callouts,macros"]
  8. --------------------------------------------------
  9. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-request]
  10. --------------------------------------------------
  11. There is no required parameters. By default the client will list all tasks and will not wait
  12. for task completion.
  13. ==== Parameters
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-request-filter]
  17. --------------------------------------------------
  18. <1> Request only cluster-related tasks
  19. <2> Request all tasks running on nodes nodeId1 and nodeId2
  20. <3> Request only children of a particular task
  21. ["source","java",subs="attributes,callouts,macros"]
  22. --------------------------------------------------
  23. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-request-detailed]
  24. --------------------------------------------------
  25. <1> Should the information include detailed, potentially slow to generate data. Defaults to `false`
  26. ["source","java",subs="attributes,callouts,macros"]
  27. --------------------------------------------------
  28. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-request-wait-completion]
  29. --------------------------------------------------
  30. <1> Should this request wait for all found tasks to complete. Defaults to `false`
  31. <2> Timeout for the request as a `TimeValue`. Applicable only if `setWaitForCompletion` is `true`.
  32. Defaults to 30 seconds
  33. <3> Timeout as a `String`
  34. [[java-rest-high-cluster-list-tasks-sync]]
  35. ==== Synchronous Execution
  36. ["source","java",subs="attributes,callouts,macros"]
  37. --------------------------------------------------
  38. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-execute]
  39. --------------------------------------------------
  40. [[java-rest-high-cluster-list-tasks-async]]
  41. ==== Asynchronous Execution
  42. The asynchronous execution of a cluster update settings requires both the
  43. `ListTasksRequest` instance and an `ActionListener` instance to be
  44. passed to the asynchronous method:
  45. ["source","java",subs="attributes,callouts,macros"]
  46. --------------------------------------------------
  47. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-execute-async]
  48. --------------------------------------------------
  49. <1> The `ListTasksRequest` to execute and the `ActionListener` to use
  50. when the execution completes
  51. The asynchronous method does not block and returns immediately. Once it is
  52. completed the `ActionListener` is called back using the `onResponse` method
  53. if the execution successfully completed or using the `onFailure` method if
  54. it failed.
  55. A typical listener for `ListTasksResponse` looks like:
  56. ["source","java",subs="attributes,callouts,macros"]
  57. --------------------------------------------------
  58. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-execute-listener]
  59. --------------------------------------------------
  60. <1> Called when the execution is successfully completed. The response is
  61. provided as an argument
  62. <2> Called in case of a failure. The raised exception is provided as an argument
  63. [[java-rest-high-cluster-list-tasks-response]]
  64. ==== List Tasks Response
  65. ["source","java",subs="attributes,callouts,macros"]
  66. --------------------------------------------------
  67. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-tasks]
  68. --------------------------------------------------
  69. <1> List of currently running tasks
  70. ["source","java",subs="attributes,callouts,macros"]
  71. --------------------------------------------------
  72. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-calc]
  73. --------------------------------------------------
  74. <1> List of tasks grouped by a node
  75. <2> List of tasks grouped by a parent task
  76. ["source","java",subs="attributes,callouts,macros"]
  77. --------------------------------------------------
  78. include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-failures]
  79. --------------------------------------------------
  80. <1> List of node failures
  81. <2> List of tasks failures