Search in sources :

Example 6 with CancelTasksResponse

use of org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse in project elasticsearch by elastic.

the class TasksIT method testTasksCancellation.

public void testTasksCancellation() throws Exception {
    // Start blocking test task
    // Get real client (the plugin is not registered on transport nodes)
    ListenableActionFuture<TestTaskPlugin.NodesResponse> future = TestTaskPlugin.TestTaskAction.INSTANCE.newRequestBuilder(client()).execute();
    logger.info("--> started test tasks");
    // Wait for the task to start on all nodes
    assertBusy(() -> assertEquals(internalCluster().size(), client().admin().cluster().prepareListTasks().setActions(TestTaskPlugin.TestTaskAction.NAME + "[n]").get().getTasks().size()));
    logger.info("--> cancelling the main test task");
    CancelTasksResponse cancelTasksResponse = client().admin().cluster().prepareCancelTasks().setActions(TestTaskPlugin.TestTaskAction.NAME).get();
    assertEquals(1, cancelTasksResponse.getTasks().size());
    future.get();
    logger.info("--> checking that test tasks are not running");
    assertEquals(0, client().admin().cluster().prepareListTasks().setActions(TestTaskPlugin.TestTaskAction.NAME + "*").get().getTasks().size());
}
Also used : CancelTasksResponse(org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse)

Aggregations

CancelTasksResponse (org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse)6 ListTasksResponse (org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse)5 IOException (java.io.IOException)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 ExecutionException (java.util.concurrent.ExecutionException)4 CancelTasksRequest (org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest)4 ListTasksRequest (org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest)4 Task (org.elasticsearch.tasks.Task)4 TaskId (org.elasticsearch.tasks.TaskId)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 CancellableTask (org.elasticsearch.tasks.CancellableTask)3 TaskCancelledException (org.elasticsearch.tasks.TaskCancelledException)3 TaskInfo (org.elasticsearch.tasks.TaskInfo)3 FailedNodeException (org.elasticsearch.action.FailedNodeException)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1