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());
}
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));
}
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());
}
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());
}
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);
}
Aggregations