mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
high level REST api: cancel task (#30745)
* Initial commit of rest high level exposure of cancel task * fix javadocs * address some code review comments * update branch to use tasks namespace instead of cluster * High-level client: list tasks failure to not lose nodeId This commit reworks testing for `ListTasksResponse` so that random fields insertion can be tested and xcontent equivalence can be checked too. Proper exclusions need to be configured, and failures need to be tested separately. This helped finding a little problem, whenever there is a node failure returned, the nodeId was lost as it was never printed out as part of the exception toXContent. * added comment * merge from master * re-work CancelTasksResponseTests to separate XContent failure cases from non-failure cases * remove duplication of logic in parser creation * code review changes * refactor TasksClient to support RequestOptions * add tests for parent task id * address final PR review comments, mostly formatting and such
This commit is contained in:
parent
e481b860a1
commit
e82e5cc2e8
12 changed files with 442 additions and 19 deletions
|
@ -140,5 +140,7 @@ include::snapshot/verify_repository.asciidoc[]
|
|||
The Java High Level REST Client supports the following Tasks APIs:
|
||||
|
||||
* <<java-rest-high-tasks-list>>
|
||||
* <<java-rest-high-cluster-cancel-tasks>>
|
||||
|
||||
include::tasks/list_tasks.asciidoc[]
|
||||
include::tasks/cancel_tasks.asciidoc[]
|
||||
|
|
82
docs/java-rest/high-level/tasks/cancel_tasks.asciidoc
Normal file
82
docs/java-rest/high-level/tasks/cancel_tasks.asciidoc
Normal file
|
@ -0,0 +1,82 @@
|
|||
[[java-rest-high-cluster-cancel-tasks]]
|
||||
=== Cancel Tasks API
|
||||
|
||||
The Cancel Tasks API allows cancellation of a currently running task.
|
||||
|
||||
==== Cancel Tasks Request
|
||||
|
||||
A `CancelTasksRequest`:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-request]
|
||||
--------------------------------------------------
|
||||
There are no required parameters. The task cancellation command supports the same
|
||||
task selection parameters as the list tasks command.
|
||||
|
||||
==== Parameters
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-request-filter]
|
||||
--------------------------------------------------
|
||||
<1> Cancel a task
|
||||
<2> Cancel only cluster-related tasks
|
||||
<3> Cancel all tasks running on nodes nodeId1 and nodeId2
|
||||
|
||||
==== Synchronous Execution
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-execute]
|
||||
--------------------------------------------------
|
||||
|
||||
==== Asynchronous Execution
|
||||
|
||||
The asynchronous execution requires `CancelTasksRequest` instance and an
|
||||
`ActionListener` instance to be passed to the asynchronous method:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-execute-async]
|
||||
--------------------------------------------------
|
||||
<1> The `CancelTasksRequest` to execute and the `ActionListener` to use
|
||||
when the execution completes
|
||||
|
||||
The asynchronous method does not block and returns immediately. Once it is
|
||||
completed the `ActionListener` is called back using the `onResponse` method
|
||||
if the execution successfully completed or using the `onFailure` method if
|
||||
it failed.
|
||||
|
||||
A typical listener for `CancelTasksResponse` looks like:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/TasksClientDocumentationIT.java[cancel-tasks-execute-listener]
|
||||
--------------------------------------------------
|
||||
<1> Called when the execution is successfully completed. The response is
|
||||
provided as an argument
|
||||
<2> Called in case of a failure. The raised exception is provided as an argument
|
||||
|
||||
==== Cancel Tasks Response
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-tasks]
|
||||
--------------------------------------------------
|
||||
<1> List of cancelled tasks
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-calc]
|
||||
--------------------------------------------------
|
||||
<1> List of cancelled tasks grouped by a node
|
||||
<2> List of cancelled tasks grouped by a parent task
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/TasksClientDocumentationIT.java[list-tasks-response-failures]
|
||||
--------------------------------------------------
|
||||
<1> List of node failures
|
||||
<2> List of task cancellation failures
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue