Search in sources :

Example 1 with ListTasksResponse

use of org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse in project elasticsearch by elastic.

the class SearchCancellationIT method cancelSearch.

private void cancelSearch(String action) {
    ListTasksResponse listTasksResponse = client().admin().cluster().prepareListTasks().setActions(action).get();
    assertThat(listTasksResponse.getTasks(), hasSize(1));
    TaskInfo searchTask = listTasksResponse.getTasks().get(0);
    logger.info("Cancelling search");
    CancelTasksResponse cancelTasksResponse = client().admin().cluster().prepareCancelTasks().setTaskId(searchTask.getTaskId()).get();
    assertThat(cancelTasksResponse.getTasks(), hasSize(1));
    assertThat(cancelTasksResponse.getTasks().get(0).getTaskId(), equalTo(searchTask.getTaskId()));
}
Also used : TaskInfo(org.elasticsearch.tasks.TaskInfo) CancelTasksResponse(org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse) ListTasksResponse(org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse)

Example 2 with ListTasksResponse

use of org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse in project elasticsearch by elastic.

the class ListTasksResponseTests method testNonEmptyToString.

public void testNonEmptyToString() {
    TaskInfo info = new TaskInfo(new TaskId("node1", 1), "dummy-type", "dummy-action", "dummy-description", null, 0, 1, true, new TaskId("node1", 0));
    ListTasksResponse tasksResponse = new ListTasksResponse(singletonList(info), emptyList(), emptyList());
    assertEquals("{\"tasks\":{\"node1:1\":{\"node\":\"node1\",\"id\":1,\"type\":\"dummy-type\",\"action\":\"dummy-action\"," + "\"description\":\"dummy-description\",\"start_time_in_millis\":0,\"running_time_in_nanos\":1,\"cancellable\":true," + "\"parent_task_id\":\"node1:0\"}}}", tasksResponse.toString());
}
Also used : ListTasksResponse(org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse)

Example 3 with ListTasksResponse

use of org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse in project elasticsearch by elastic.

the class TransportRethrottleActionTests method testRethrottleSuccessfulResponse.

public void testRethrottleSuccessfulResponse() {
    List<TaskInfo> tasks = new ArrayList<>();
    List<BulkByScrollTask.StatusOrException> sliceStatuses = new ArrayList<>(slices);
    for (int i = 0; i < slices; i++) {
        BulkByScrollTask.Status status = believeableInProgressStatus(i);
        tasks.add(new TaskInfo(new TaskId("test", 123), "test", "test", "test", status, 0, 0, true, new TaskId("test", task.getId())));
        sliceStatuses.add(new BulkByScrollTask.StatusOrException(status));
    }
    rethrottleTestCase(slices, listener -> listener.onResponse(new ListTasksResponse(tasks, emptyList(), emptyList())), expectSuccessfulRethrottleWithStatuses(sliceStatuses));
}
Also used : TaskInfo(org.elasticsearch.tasks.TaskInfo) TaskId(org.elasticsearch.tasks.TaskId) ArrayList(java.util.ArrayList) ParentBulkByScrollTask(org.elasticsearch.action.bulk.byscroll.ParentBulkByScrollTask) BulkByScrollTask(org.elasticsearch.action.bulk.byscroll.BulkByScrollTask) ListTasksResponse(org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse)

Example 4 with ListTasksResponse

use of org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse in project elasticsearch by elastic.

the class TransportRethrottleActionTests method testRethrottleTaskOperationFailure.

public void testRethrottleTaskOperationFailure() {
    Exception e = new Exception();
    TaskOperationFailure failure = new TaskOperationFailure("test", 123, e);
    rethrottleTestCase(slices, listener -> listener.onResponse(new ListTasksResponse(emptyList(), singletonList(failure), emptyList())), expectException(hasToString(containsString("Rethrottle of [test:123] failed"))));
}
Also used : TaskOperationFailure(org.elasticsearch.action.TaskOperationFailure) ListTasksResponse(org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse) FailedNodeException(org.elasticsearch.action.FailedNodeException)

Example 5 with ListTasksResponse

use of org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse in project elasticsearch by elastic.

the class TransportRethrottleActionTests method testRethrottleNodeFailure.

public void testRethrottleNodeFailure() {
    FailedNodeException e = new FailedNodeException("test", "test", new Exception());
    rethrottleTestCase(slices, listener -> listener.onResponse(new ListTasksResponse(emptyList(), emptyList(), singletonList(e))), expectException(theInstance(e)));
}
Also used : FailedNodeException(org.elasticsearch.action.FailedNodeException) ListTasksResponse(org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse) FailedNodeException(org.elasticsearch.action.FailedNodeException)

Aggregations

ListTasksResponse (org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse)25 TaskInfo (org.elasticsearch.tasks.TaskInfo)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 ListTasksRequest (org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest)9 TaskId (org.elasticsearch.tasks.TaskId)8 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)6 ExecutionException (java.util.concurrent.ExecutionException)6 Task (org.elasticsearch.tasks.Task)6 List (java.util.List)5 CancelTasksResponse (org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse)5 Map (java.util.Map)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 FailedNodeException (org.elasticsearch.action.FailedNodeException)4 CancelTasksRequest (org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest)4 BulkByScrollTask (org.elasticsearch.action.bulk.byscroll.BulkByScrollTask)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 TaskGroup (org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup)3 BulkByScrollResponse (org.elasticsearch.action.bulk.byscroll.BulkByScrollResponse)3 CancellableTask (org.elasticsearch.tasks.CancellableTask)3