IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Cancel Tasks APIedit
The Cancel Tasks API allows cancellation of a currently running task.
Cancel Tasks Requestedit
A CancelTasksRequest
:
CancelTasksRequest request = new CancelTasksRequest();
There are no required parameters. The task cancellation command supports the same task selection parameters as the list tasks command.
Parametersedit
Synchronous Executionedit
CancelTasksResponse response = client.tasks().cancel(request, RequestOptions.DEFAULT);
Asynchronous Executionedit
The asynchronous execution requires CancelTasksRequest
instance and an
ActionListener
instance to be passed to the asynchronous method:
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:
Cancel Tasks Responseedit
Map<String, List<TaskInfo>> perNodeTasks = response.getPerNodeTasks(); List<TaskGroup> groups = response.getTaskGroups();