Search in sources :

Example 11 with NoopTask

use of org.apache.druid.indexing.common.task.NoopTask in project druid by druid-io.

the class FillCapacityWithAffinityWorkerSelectStrategyTest method testFindWorkerForTask.

@Test
public void testFindWorkerForTask() {
    FillCapacityWorkerSelectStrategy strategy = new FillCapacityWithAffinityWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost")), false));
    ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("lhost", new ImmutableWorkerInfo(new Worker("http", "lhost", "lhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc()), "localhost", new ImmutableWorkerInfo(new Worker("http", "localhost", "localhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null) {

        @Override
        public String getDataSource() {
            return "foo";
        }
    });
    Assert.assertEquals("localhost", worker.getWorker().getHost());
}
Also used : Worker(org.apache.druid.indexing.worker.Worker) NoopTask(org.apache.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 12 with NoopTask

use of org.apache.druid.indexing.common.task.NoopTask in project druid by druid-io.

the class FillCapacityWithAffinityWorkerSelectStrategyTest method testFindWorkerForTaskWithNulls.

@Test
public void testFindWorkerForTaskWithNulls() {
    FillCapacityWorkerSelectStrategy strategy = new FillCapacityWithAffinityWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost")), false));
    ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("lhost", new ImmutableWorkerInfo(new Worker("http", "lhost", "lhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc()), "localhost", new ImmutableWorkerInfo(new Worker("http", "localhost", "localhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null));
    Assert.assertEquals("lhost", worker.getWorker().getHost());
}
Also used : Worker(org.apache.druid.indexing.worker.Worker) NoopTask(org.apache.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 13 with NoopTask

use of org.apache.druid.indexing.common.task.NoopTask in project druid by druid-io.

the class ParallelIndexPhaseRunnerTest method testLargeEstimatedNumSplits.

@Test
public void testLargeEstimatedNumSplits() throws Exception {
    final NoopTask task = NoopTask.create();
    final TaskActionClient actionClient = createActionClient(task);
    final TaskToolbox toolbox = createTaskToolbox(task, actionClient);
    final TestPhaseRunner runner = new TestPhaseRunner(toolbox, "supervisorTaskId", "groupId", AbstractParallelIndexSupervisorTaskTest.DEFAULT_TUNING_CONFIG_FOR_PARALLEL_INDEXING, 10, 12);
    Assert.assertEquals(TaskState.SUCCESS, runner.run());
}
Also used : TaskToolbox(org.apache.druid.indexing.common.TaskToolbox) TaskActionClient(org.apache.druid.indexing.common.actions.TaskActionClient) NoopTask(org.apache.druid.indexing.common.task.NoopTask) Test(org.junit.Test)

Example 14 with NoopTask

use of org.apache.druid.indexing.common.task.NoopTask in project druid by druid-io.

the class OverlordTest method testOverlordRun.

@Test(timeout = 60_000L)
public void testOverlordRun() throws Exception {
    // basic task master lifecycle test
    taskMaster.start();
    announcementLatch.await();
    while (!taskMaster.isLeader()) {
        // I believe the control will never reach here and thread will never sleep but just to be on safe side
        Thread.sleep(10);
    }
    Assert.assertEquals(taskMaster.getCurrentLeader(), druidNode.getHostAndPort());
    final TaskStorageQueryAdapter taskStorageQueryAdapter = new TaskStorageQueryAdapter(taskStorage, taskLockbox);
    final WorkerTaskRunnerQueryAdapter workerTaskRunnerQueryAdapter = new WorkerTaskRunnerQueryAdapter(taskMaster, null);
    // Test Overlord resource stuff
    overlordResource = new OverlordResource(taskMaster, taskStorageQueryAdapter, new IndexerMetadataStorageAdapter(taskStorageQueryAdapter, null), null, null, null, AuthTestUtils.TEST_AUTHORIZER_MAPPER, workerTaskRunnerQueryAdapter, null);
    Response response = overlordResource.getLeader();
    Assert.assertEquals(druidNode.getHostAndPort(), response.getEntity());
    final String taskId_0 = "0";
    NoopTask task_0 = NoopTask.create(taskId_0, 0);
    response = overlordResource.taskPost(task_0, req);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(ImmutableMap.of("task", taskId_0), response.getEntity());
    // Duplicate task - should fail
    response = overlordResource.taskPost(task_0, req);
    Assert.assertEquals(400, response.getStatus());
    // Task payload for task_0 should be present in taskStorage
    response = overlordResource.getTaskPayload(taskId_0);
    Assert.assertEquals(task_0, ((TaskPayloadResponse) response.getEntity()).getPayload());
    // Task not present in taskStorage - should fail
    response = overlordResource.getTaskPayload("whatever");
    Assert.assertEquals(404, response.getStatus());
    // Task status of the submitted task should be running
    response = overlordResource.getTaskStatus(taskId_0);
    Assert.assertEquals(taskId_0, ((TaskStatusResponse) response.getEntity()).getTask());
    Assert.assertEquals(TaskStatus.running(taskId_0).getStatusCode(), ((TaskStatusResponse) response.getEntity()).getStatus().getStatusCode());
    // Simulate completion of task_0
    taskCompletionCountDownLatches[Integer.parseInt(taskId_0)].countDown();
    // Wait for taskQueue to handle success status of task_0
    waitForTaskStatus(taskId_0, TaskState.SUCCESS);
    // Manually insert task in taskStorage
    // Verifies sync from storage
    final String taskId_1 = "1";
    NoopTask task_1 = NoopTask.create(taskId_1, 0);
    taskStorage.insert(task_1, TaskStatus.running(taskId_1));
    // Wait for task runner to run task_1
    runTaskCountDownLatches[Integer.parseInt(taskId_1)].await();
    response = overlordResource.getRunningTasks(null, req);
    // 1 task that was manually inserted should be in running state
    Assert.assertEquals(1, (((List) response.getEntity()).size()));
    final TaskStatusPlus taskResponseObject = ((List<TaskStatusPlus>) response.getEntity()).get(0);
    Assert.assertEquals(taskId_1, taskResponseObject.getId());
    Assert.assertEquals(TASK_LOCATION, taskResponseObject.getLocation());
    // Simulate completion of task_1
    taskCompletionCountDownLatches[Integer.parseInt(taskId_1)].countDown();
    // Wait for taskQueue to handle success status of task_1
    waitForTaskStatus(taskId_1, TaskState.SUCCESS);
    // should return number of tasks which are not in running state
    response = overlordResource.getCompleteTasks(null, req);
    Assert.assertEquals(2, (((List) response.getEntity()).size()));
    response = overlordResource.getCompleteTasks(1, req);
    Assert.assertEquals(1, (((List) response.getEntity()).size()));
    taskMaster.stop();
    Assert.assertFalse(taskMaster.isLeader());
    EasyMock.verify(taskLockbox, taskActionClientFactory);
}
Also used : IndexerMetadataStorageAdapter(org.apache.druid.indexing.overlord.IndexerMetadataStorageAdapter) Response(javax.ws.rs.core.Response) TaskStatusPlus(org.apache.druid.indexer.TaskStatusPlus) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) NoopTask(org.apache.druid.indexing.common.task.NoopTask) WorkerTaskRunnerQueryAdapter(org.apache.druid.indexing.overlord.WorkerTaskRunnerQueryAdapter) TaskStorageQueryAdapter(org.apache.druid.indexing.overlord.TaskStorageQueryAdapter) Test(org.junit.Test)

Example 15 with NoopTask

use of org.apache.druid.indexing.common.task.NoopTask in project druid by druid-io.

the class EqualDistributionWithCategorySpecWorkerSelectStrategyTest method selectWorker.

private ImmutableWorkerInfo selectWorker(WorkerCategorySpec workerCategorySpec) {
    final EqualDistributionWithCategorySpecWorkerSelectStrategy strategy = new EqualDistributionWithCategorySpecWorkerSelectStrategy(workerCategorySpec);
    ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_TIER_TESTS, new NoopTask(null, null, "ds1", 1, 0, null, null, null));
    return worker;
}
Also used : NoopTask(org.apache.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo)

Aggregations

NoopTask (org.apache.druid.indexing.common.task.NoopTask)20 Test (org.junit.Test)18 ImmutableWorkerInfo (org.apache.druid.indexing.overlord.ImmutableWorkerInfo)12 RemoteTaskRunnerConfig (org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig)12 Worker (org.apache.druid.indexing.worker.Worker)10 TaskToolbox (org.apache.druid.indexing.common.TaskToolbox)3 Response (javax.ws.rs.core.Response)2 TaskStatus (org.apache.druid.indexer.TaskStatus)2 TaskActionClient (org.apache.druid.indexing.common.actions.TaskActionClient)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 TaskLocation (org.apache.druid.indexer.TaskLocation)1 TaskStatusPlus (org.apache.druid.indexer.TaskStatusPlus)1 Task (org.apache.druid.indexing.common.task.Task)1 IndexerMetadataStorageAdapter (org.apache.druid.indexing.overlord.IndexerMetadataStorageAdapter)1 TaskStorageQueryAdapter (org.apache.druid.indexing.overlord.TaskStorageQueryAdapter)1 WorkerTaskRunnerQueryAdapter (org.apache.druid.indexing.overlord.WorkerTaskRunnerQueryAdapter)1