Search in sources :

Example 1 with IndexingServiceCondition

use of io.druid.indexing.common.IndexingServiceCondition in project druid by druid-io.

the class RemoteTaskRunnerTest method testRunSameAvailabilityGroup.

@Test
public void testRunSameAvailabilityGroup() throws Exception {
    doSetup();
    TestRealtimeTask task1 = new TestRealtimeTask("rt1", new TaskResource("rt1", 1), "foo", TaskStatus.running("rt1"), jsonMapper);
    remoteTaskRunner.run(task1);
    Assert.assertTrue(taskAnnounced(task1.getId()));
    mockWorkerRunningTask(task1);
    TestRealtimeTask task2 = new TestRealtimeTask("rt2", new TaskResource("rt1", 1), "foo", TaskStatus.running("rt2"), jsonMapper);
    remoteTaskRunner.run(task2);
    TestRealtimeTask task3 = new TestRealtimeTask("rt3", new TaskResource("rt2", 1), "foo", TaskStatus.running("rt3"), jsonMapper);
    remoteTaskRunner.run(task3);
    Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {

        @Override
        public boolean isValid() {
            return remoteTaskRunner.getRunningTasks().size() == 2;
        }
    }));
    Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {

        @Override
        public boolean isValid() {
            return remoteTaskRunner.getPendingTasks().size() == 1;
        }
    }));
    Assert.assertTrue(remoteTaskRunner.getPendingTasks().iterator().next().getTaskId().equals("rt2"));
}
Also used : TestRealtimeTask(io.druid.indexing.common.TestRealtimeTask) TaskResource(io.druid.indexing.common.task.TaskResource) IndexingServiceCondition(io.druid.indexing.common.IndexingServiceCondition) Test(org.junit.Test)

Example 2 with IndexingServiceCondition

use of io.druid.indexing.common.IndexingServiceCondition in project druid by druid-io.

the class RemoteTaskRunnerTest method testWorkerRemoved.

@Test
public void testWorkerRemoved() throws Exception {
    doSetup();
    Future<TaskStatus> future = remoteTaskRunner.run(task);
    Assert.assertTrue(taskAnnounced(task.getId()));
    mockWorkerRunningTask(task);
    Assert.assertTrue(workerRunningTask(task.getId()));
    cf.delete().forPath(announcementsPath);
    TaskStatus status = future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
    Assert.assertEquals(TaskStatus.Status.FAILED, status.getStatusCode());
    RemoteTaskRunnerConfig config = remoteTaskRunner.getRemoteTaskRunnerConfig();
    Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {

        @Override
        public boolean isValid() {
            return remoteTaskRunner.getRemovedWorkerCleanups().isEmpty();
        }
    }, // cleanup task is independently scheduled by event listener. we need to wait some more time.
    config.getTaskCleanupTimeout().toStandardDuration().getMillis() * 2));
    Assert.assertNull(cf.checkExists().forPath(statusPath));
}
Also used : IndexingServiceCondition(io.druid.indexing.common.IndexingServiceCondition) TaskStatus(io.druid.indexing.common.TaskStatus) RemoteTaskRunnerConfig(io.druid.indexing.overlord.config.RemoteTaskRunnerConfig) Test(org.junit.Test)

Example 3 with IndexingServiceCondition

use of io.druid.indexing.common.IndexingServiceCondition in project druid by druid-io.

the class RemoteTaskRunnerTest method testWorkerZKReconnect.

@Test
public void testWorkerZKReconnect() throws Exception {
    makeWorker();
    makeRemoteTaskRunner(new TestRemoteTaskRunnerConfig(new Period("PT5M")));
    Future<TaskStatus> future = remoteTaskRunner.run(task);
    Assert.assertTrue(taskAnnounced(task.getId()));
    mockWorkerRunningTask(task);
    Assert.assertTrue(workerRunningTask(task.getId()));
    byte[] bytes = cf.getData().forPath(announcementsPath);
    cf.delete().forPath(announcementsPath);
    // worker task cleanup scheduled
    Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {

        @Override
        public boolean isValid() {
            return remoteTaskRunner.getRemovedWorkerCleanups().containsKey(worker.getHost());
        }
    }));
    // Worker got reconnected
    cf.create().forPath(announcementsPath, bytes);
    // worker task cleanup should get cancelled and removed
    Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {

        @Override
        public boolean isValid() {
            return !remoteTaskRunner.getRemovedWorkerCleanups().containsKey(worker.getHost());
        }
    }));
    mockWorkerCompleteSuccessfulTask(task);
    TaskStatus status = future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
    Assert.assertEquals(status.getStatusCode(), TaskStatus.Status.SUCCESS);
    Assert.assertEquals(TaskStatus.Status.SUCCESS, status.getStatusCode());
}
Also used : IndexingServiceCondition(io.druid.indexing.common.IndexingServiceCondition) Period(org.joda.time.Period) TaskStatus(io.druid.indexing.common.TaskStatus) Test(org.junit.Test)

Example 4 with IndexingServiceCondition

use of io.druid.indexing.common.IndexingServiceCondition in project druid by druid-io.

the class RemoteTaskRunnerTest method testRunWithCapacity.

@Test
public void testRunWithCapacity() throws Exception {
    doSetup();
    TestRealtimeTask task1 = new TestRealtimeTask("rt1", new TaskResource("rt1", 1), "foo", TaskStatus.running("rt1"), jsonMapper);
    remoteTaskRunner.run(task1);
    Assert.assertTrue(taskAnnounced(task1.getId()));
    mockWorkerRunningTask(task1);
    TestRealtimeTask task2 = new TestRealtimeTask("rt2", new TaskResource("rt2", 3), "foo", TaskStatus.running("rt2"), jsonMapper);
    remoteTaskRunner.run(task2);
    TestRealtimeTask task3 = new TestRealtimeTask("rt3", new TaskResource("rt3", 2), "foo", TaskStatus.running("rt3"), jsonMapper);
    remoteTaskRunner.run(task3);
    Assert.assertTrue(taskAnnounced(task3.getId()));
    mockWorkerRunningTask(task3);
    Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {

        @Override
        public boolean isValid() {
            return remoteTaskRunner.getRunningTasks().size() == 2;
        }
    }));
    Assert.assertTrue(TestUtils.conditionValid(new IndexingServiceCondition() {

        @Override
        public boolean isValid() {
            return remoteTaskRunner.getPendingTasks().size() == 1;
        }
    }));
    Assert.assertTrue(remoteTaskRunner.getPendingTasks().iterator().next().getTaskId().equals("rt2"));
}
Also used : TestRealtimeTask(io.druid.indexing.common.TestRealtimeTask) TaskResource(io.druid.indexing.common.task.TaskResource) IndexingServiceCondition(io.druid.indexing.common.IndexingServiceCondition) Test(org.junit.Test)

Aggregations

IndexingServiceCondition (io.druid.indexing.common.IndexingServiceCondition)4 Test (org.junit.Test)4 TaskStatus (io.druid.indexing.common.TaskStatus)2 TestRealtimeTask (io.druid.indexing.common.TestRealtimeTask)2 TaskResource (io.druid.indexing.common.task.TaskResource)2 RemoteTaskRunnerConfig (io.druid.indexing.overlord.config.RemoteTaskRunnerConfig)1 Period (org.joda.time.Period)1