Search in sources :

Example 1 with MultipleFileTaskReportFileWriter

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

the class ThreadingTaskRunnerTest method testTaskStatusWhenTaskThrowsExceptionWhileRunning.

@Test
public void testTaskStatusWhenTaskThrowsExceptionWhileRunning() throws ExecutionException, InterruptedException {
    ThreadingTaskRunner runner = new ThreadingTaskRunner(mockTaskToolboxFactory(), new TaskConfig(null, null, null, null, ImmutableList.of(), false, new Period("PT0S"), new Period("PT10S"), ImmutableList.of(), false, false, TaskConfig.BATCH_PROCESSING_MODE_DEFAULT.name()), new WorkerConfig(), new NoopTaskLogs(), new DefaultObjectMapper(), new TestAppenderatorsManager(), new MultipleFileTaskReportFileWriter(), new DruidNode("middleManager", "host", false, 8091, null, true, false));
    Future<TaskStatus> statusFuture = runner.run(new AbstractTask("id", "datasource", null) {

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

        @Override
        public boolean isReady(TaskActionClient taskActionClient) {
            return true;
        }

        @Override
        public void stopGracefully(TaskConfig taskConfig) {
        }

        @Override
        public TaskStatus run(TaskToolbox toolbox) {
            throw new RuntimeException("Task failure test");
        }
    });
    TaskStatus status = statusFuture.get();
    Assert.assertEquals(TaskState.FAILED, status.getStatusCode());
    Assert.assertEquals("Failed with an exception. See indexer logs for more details.", status.getErrorMsg());
}
Also used : NoopTaskLogs(org.apache.druid.tasklogs.NoopTaskLogs) AbstractTask(org.apache.druid.indexing.common.task.AbstractTask) Period(org.joda.time.Period) TaskConfig(org.apache.druid.indexing.common.config.TaskConfig) TaskStatus(org.apache.druid.indexer.TaskStatus) MultipleFileTaskReportFileWriter(org.apache.druid.indexing.common.MultipleFileTaskReportFileWriter) TaskToolbox(org.apache.druid.indexing.common.TaskToolbox) TaskActionClient(org.apache.druid.indexing.common.actions.TaskActionClient) WorkerConfig(org.apache.druid.indexing.worker.config.WorkerConfig) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) DruidNode(org.apache.druid.server.DruidNode) TestAppenderatorsManager(org.apache.druid.indexing.common.task.TestAppenderatorsManager) Test(org.junit.Test)

Aggregations

TaskStatus (org.apache.druid.indexer.TaskStatus)1 MultipleFileTaskReportFileWriter (org.apache.druid.indexing.common.MultipleFileTaskReportFileWriter)1 TaskToolbox (org.apache.druid.indexing.common.TaskToolbox)1 TaskActionClient (org.apache.druid.indexing.common.actions.TaskActionClient)1 TaskConfig (org.apache.druid.indexing.common.config.TaskConfig)1 AbstractTask (org.apache.druid.indexing.common.task.AbstractTask)1 TestAppenderatorsManager (org.apache.druid.indexing.common.task.TestAppenderatorsManager)1 WorkerConfig (org.apache.druid.indexing.worker.config.WorkerConfig)1 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)1 DruidNode (org.apache.druid.server.DruidNode)1 NoopTaskLogs (org.apache.druid.tasklogs.NoopTaskLogs)1 Period (org.joda.time.Period)1 Test (org.junit.Test)1