Search in sources :

Example 1 with NoopTask

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

the class ParallelIndexPhaseRunnerTest method testSmallEstimatedNumSplits.

@Test
public void testSmallEstimatedNumSplits() 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, 8);
    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 2 with NoopTask

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

the class SingleTaskBackgroundRunnerTest method testGetQueryRunner.

@Test
public void testGetQueryRunner() throws ExecutionException, InterruptedException {
    runner.run(new NoopTask(null, null, "foo", 500L, 0, null, null, null)).get().getStatusCode();
    final QueryRunner<ScanResultValue> queryRunner = Druids.newScanQueryBuilder().dataSource("foo").intervals(new MultipleIntervalSegmentSpec(Intervals.ONLY_ETERNITY)).build().getRunner(runner);
    Assert.assertThat(queryRunner, CoreMatchers.instanceOf(SetAndVerifyContextQueryRunner.class));
}
Also used : SetAndVerifyContextQueryRunner(org.apache.druid.server.SetAndVerifyContextQueryRunner) ScanResultValue(org.apache.druid.query.scan.ScanResultValue) MultipleIntervalSegmentSpec(org.apache.druid.query.spec.MultipleIntervalSegmentSpec) NoopTask(org.apache.druid.indexing.common.task.NoopTask) Test(org.junit.Test)

Example 3 with NoopTask

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

the class SingleTaskBackgroundRunnerTest method testStopNonRestorableTask.

@Test
public void testStopNonRestorableTask() throws InterruptedException {
    // latch to wait for SingleTaskBackgroundRunnerCallable to be executed before stopping the task
    // We need this latch because TaskRunnerListener is currently racy.
    // See https://github.com/apache/druid/issues/11445 for more details.
    CountDownLatch runLatch = new CountDownLatch(1);
    // statusChanged callback can be called by multiple threads.
    AtomicReference<TaskStatus> statusHolder = new AtomicReference<>();
    runner.registerListener(new TaskRunnerListener() {

        @Override
        public String getListenerId() {
            return "testStopNonRestorableTask";
        }

        @Override
        public void locationChanged(String taskId, TaskLocation newLocation) {
        // do nothing
        }

        @Override
        public void statusChanged(String taskId, TaskStatus status) {
            if (status.getStatusCode() == TaskState.RUNNING) {
                runLatch.countDown();
            } else {
                statusHolder.set(status);
            }
        }
    }, Execs.directExecutor());
    runner.run(new NoopTask(null, null, "datasource", // 10 sec
    10000, 0, null, null, null));
    Assert.assertTrue(runLatch.await(1, TimeUnit.SECONDS));
    runner.stop();
    Assert.assertEquals(TaskState.FAILED, statusHolder.get().getStatusCode());
    Assert.assertEquals("Canceled as task execution process stopped", statusHolder.get().getErrorMsg());
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) TaskStatus(org.apache.druid.indexer.TaskStatus) NoopTask(org.apache.druid.indexing.common.task.NoopTask) TaskLocation(org.apache.druid.indexer.TaskLocation) Test(org.junit.Test)

Example 4 with NoopTask

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

the class SingleTaskBackgroundRunnerTest method testStop.

@Test
public void testStop() throws ExecutionException, InterruptedException, TimeoutException {
    final ListenableFuture<TaskStatus> future = runner.run(// infinite task
    new NoopTask(null, null, null, Long.MAX_VALUE, 0, null, null, null));
    runner.stop();
    Assert.assertEquals(TaskState.FAILED, future.get(1000, TimeUnit.MILLISECONDS).getStatusCode());
}
Also used : TaskStatus(org.apache.druid.indexer.TaskStatus) NoopTask(org.apache.druid.indexing.common.task.NoopTask) Test(org.junit.Test)

Example 5 with NoopTask

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

the class EqualDistributionWithAffinityWorkerSelectStrategyTest method testIsolation.

@Test
public void testIsolation() {
    EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWithAffinityWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost")), false));
    ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("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.assertNull(worker);
}
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)

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