List Tasks APIedit
The List Tasks API allows to get information about the tasks currently executing in the cluster.
List Tasks Requestedit
A ListTasksRequest
:
ListTasksRequest request = new ListTasksRequest();
There is no required parameters. By default the client will list all tasks and will not wait for task completion.
Parametersedit
request.setActions("cluster:*"); request.setNodes("nodeId1", "nodeId2"); request.setParentTaskId(new TaskId("parentTaskId", 42));
Request only cluster-related tasks |
|
Request all tasks running on nodes nodeId1 and nodeId2 |
|
Request only children of a particular task |
Synchronous Executionedit
ListTasksResponse response = client.tasks().list(request, RequestOptions.DEFAULT);
Asynchronous Executionedit
The asynchronous execution of a cluster update settings requires both the
ListTasksRequest
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 ListTasksResponse
looks like:
List Tasks Responseedit
Map<String, List<TaskInfo>> perNodeTasks = response.getPerNodeTasks(); List<TaskGroup> groups = response.getTaskGroups();