Search in sources :

Example 16 with TaskToolbox

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

the class TaskLifecycleTest method testSimple.

@Test
public void testSimple() throws Exception {
    final Task task = new AbstractFixedIntervalTask("id1", "id1", new TaskResource("id1", 1), "ds", new Interval("2012-01-01/P1D"), null) {

        @Override
        public String getType() {
            return "test";
        }

        @Override
        public TaskStatus run(TaskToolbox toolbox) throws Exception {
            final TaskLock myLock = Iterables.getOnlyElement(toolbox.getTaskActionClient().submit(new LockListAction()));
            final DataSegment segment = DataSegment.builder().dataSource("ds").interval(new Interval("2012-01-01/P1D")).version(myLock.getVersion()).build();
            toolbox.getTaskActionClient().submit(new SegmentInsertAction(ImmutableSet.of(segment)));
            return TaskStatus.success(getId());
        }
    };
    final TaskStatus status = runTask(task);
    Assert.assertEquals("statusCode", TaskStatus.Status.SUCCESS, status.getStatusCode());
    Assert.assertEquals("segments published", 1, mdc.getPublished().size());
    Assert.assertEquals("segments nuked", 0, mdc.getNuked().size());
}
Also used : TaskToolbox(io.druid.indexing.common.TaskToolbox) LockListAction(io.druid.indexing.common.actions.LockListAction) IndexTask(io.druid.indexing.common.task.IndexTask) RealtimeIndexTask(io.druid.indexing.common.task.RealtimeIndexTask) Task(io.druid.indexing.common.task.Task) AbstractFixedIntervalTask(io.druid.indexing.common.task.AbstractFixedIntervalTask) KillTask(io.druid.indexing.common.task.KillTask) TaskResource(io.druid.indexing.common.task.TaskResource) TaskLock(io.druid.indexing.common.TaskLock) SegmentInsertAction(io.druid.indexing.common.actions.SegmentInsertAction) TaskStatus(io.druid.indexing.common.TaskStatus) DataSegment(io.druid.timeline.DataSegment) AbstractFixedIntervalTask(io.druid.indexing.common.task.AbstractFixedIntervalTask) Interval(org.joda.time.Interval) FireDepartmentTest(io.druid.segment.realtime.FireDepartmentTest) Test(org.junit.Test)

Aggregations

TaskToolbox (io.druid.indexing.common.TaskToolbox)16 TaskStatus (io.druid.indexing.common.TaskStatus)13 Test (org.junit.Test)12 DataSegment (io.druid.timeline.DataSegment)9 TestIndexerMetadataStorageCoordinator (io.druid.indexing.test.TestIndexerMetadataStorageCoordinator)8 MapBasedInputRow (io.druid.data.input.MapBasedInputRow)7 File (java.io.File)6 TaskLock (io.druid.indexing.common.TaskLock)5 LockListAction (io.druid.indexing.common.actions.LockListAction)5 Interval (org.joda.time.Interval)5 SegmentInsertAction (io.druid.indexing.common.actions.SegmentInsertAction)4 Pair (io.druid.java.util.common.Pair)4 SegmentDescriptor (io.druid.query.SegmentDescriptor)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 InputRow (io.druid.data.input.InputRow)3 TaskActionClient (io.druid.indexing.common.actions.TaskActionClient)3 AbstractFixedIntervalTask (io.druid.indexing.common.task.AbstractFixedIntervalTask)3 IndexTask (io.druid.indexing.common.task.IndexTask)3 KillTask (io.druid.indexing.common.task.KillTask)3 RealtimeIndexTask (io.druid.indexing.common.task.RealtimeIndexTask)3