-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Paul Sanwald
committed
Jun 8, 2018
1 parent
f4ea2e9
commit 540b117
Showing
12 changed files
with
442 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,4 +178,5 @@ public void onFailure(Exception e) { | |
assertTrue(latch.await(30L, TimeUnit.SECONDS)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.