WARNING: Deprecated in 7.15.0.
The Java REST Client is deprecated in favor of the Java API Client.
Cancel Tasks API
editCancel Tasks API
editThe Cancel Tasks API allows cancellation of a currently running task.
Cancel Tasks Request
editA CancelTasksRequest
:
CancelTasksRequest request = new org.elasticsearch.client.tasks.CancelTasksRequest.Builder() .withNodesFiltered(Arrays.asList("nodeId1", "nodeId2")) .withActionsFiltered(Collections.singletonList("cluster:*")) .build();
There are no required parameters. The task cancellation command supports the same task selection parameters as the list tasks command.
Parameters
editSynchronous Execution
editCancelTasksResponse response = client.tasks().cancel(request, RequestOptions.DEFAULT);
Asynchronous Execution
editThe 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 Response
editMap<String, List<org.elasticsearch.client.tasks.TaskInfo>> perNodeTasks = response.getPerNodeTasks(); List<org.elasticsearch.client.tasks.TaskGroup> groups = response.getTaskGroups();