Search in sources :

Example 1 with TaskResultsService

use of org.opensearch.tasks.TaskResultsService in project OpenSearch by opensearch-project.

the class TasksIT method testNodeNotFoundButTaskFound.

public void testNodeNotFoundButTaskFound() throws Exception {
    // Save a fake task that looks like it is from a node that isn't part of the cluster
    CyclicBarrier b = new CyclicBarrier(2);
    TaskResultsService resultsService = internalCluster().getInstance(TaskResultsService.class);
    resultsService.storeResult(new TaskResult(new TaskInfo(new TaskId("fake", 1), "test", "test", "", null, 0, 0, false, false, TaskId.EMPTY_TASK_ID, Collections.emptyMap()), new RuntimeException("test")), new ActionListener<Void>() {

        @Override
        public void onResponse(Void response) {
            try {
                b.await();
            } catch (InterruptedException | BrokenBarrierException e) {
                onFailure(e);
            }
        }

        @Override
        public void onFailure(Exception e) {
            throw new RuntimeException(e);
        }
    });
    b.await();
    // Now we can find it!
    GetTaskResponse response = expectFinishedTask(new TaskId("fake:1"));
    assertEquals("test", response.getTask().getTask().getAction());
    assertNotNull(response.getTask().getError());
    assertNull(response.getTask().getResponse());
}
Also used : TaskInfo(org.opensearch.tasks.TaskInfo) TaskId(org.opensearch.tasks.TaskId) TaskResult(org.opensearch.tasks.TaskResult) GetTaskResponse(org.opensearch.action.admin.cluster.node.tasks.get.GetTaskResponse) TaskResultsService(org.opensearch.tasks.TaskResultsService) OpenSearchException(org.opensearch.OpenSearchException) OpenSearchTimeoutException(org.opensearch.OpenSearchTimeoutException) ReceiveTimeoutTransportException(org.opensearch.transport.ReceiveTimeoutTransportException) ResourceNotFoundException(org.opensearch.ResourceNotFoundException) IOException(java.io.IOException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) CyclicBarrier(java.util.concurrent.CyclicBarrier)

Aggregations

IOException (java.io.IOException)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 OpenSearchException (org.opensearch.OpenSearchException)1 OpenSearchTimeoutException (org.opensearch.OpenSearchTimeoutException)1 ResourceNotFoundException (org.opensearch.ResourceNotFoundException)1 GetTaskResponse (org.opensearch.action.admin.cluster.node.tasks.get.GetTaskResponse)1 TaskId (org.opensearch.tasks.TaskId)1 TaskInfo (org.opensearch.tasks.TaskInfo)1 TaskResult (org.opensearch.tasks.TaskResult)1 TaskResultsService (org.opensearch.tasks.TaskResultsService)1 ReceiveTimeoutTransportException (org.opensearch.transport.ReceiveTimeoutTransportException)1