Search in sources :

Example 6 with TaskStorage

use of org.apache.druid.indexing.overlord.TaskStorage in project druid by druid-io.

the class MaterializedViewSupervisorTest method setUp.

@Before
public void setUp() {
    TestDerbyConnector derbyConnector = derbyConnectorRule.getConnector();
    derbyConnector.createDataSourceTable();
    derbyConnector.createSegmentTable();
    taskStorage = EasyMock.createMock(TaskStorage.class);
    taskMaster = EasyMock.createMock(TaskMaster.class);
    indexerMetadataStorageCoordinator = new IndexerSQLMetadataStorageCoordinator(objectMapper, derbyConnectorRule.metadataTablesConfigSupplier().get(), derbyConnector);
    metadataSupervisorManager = EasyMock.createMock(MetadataSupervisorManager.class);
    sqlSegmentsMetadataManager = EasyMock.createMock(SqlSegmentsMetadataManager.class);
    taskQueue = EasyMock.createMock(TaskQueue.class);
    taskQueue.start();
    objectMapper.registerSubtypes(new NamedType(HashBasedNumberedShardSpec.class, "hashed"));
    spec = new MaterializedViewSupervisorSpec("base", new DimensionsSpec(Collections.singletonList(new StringDimensionSchema("dim"))), new AggregatorFactory[] { new LongSumAggregatorFactory("m1", "m1") }, HadoopTuningConfig.makeDefaultTuningConfig(), null, null, null, null, null, false, objectMapper, taskMaster, taskStorage, metadataSupervisorManager, sqlSegmentsMetadataManager, indexerMetadataStorageCoordinator, new MaterializedViewTaskConfig(), EasyMock.createMock(AuthorizerMapper.class), EasyMock.createMock(ChatHandlerProvider.class), new SupervisorStateManagerConfig());
    derivativeDatasourceName = spec.getDataSourceName();
    supervisor = (MaterializedViewSupervisor) spec.createSupervisor();
}
Also used : IndexerSQLMetadataStorageCoordinator(org.apache.druid.metadata.IndexerSQLMetadataStorageCoordinator) HashBasedNumberedShardSpec(org.apache.druid.timeline.partition.HashBasedNumberedShardSpec) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) LongSumAggregatorFactory(org.apache.druid.query.aggregation.LongSumAggregatorFactory) TestDerbyConnector(org.apache.druid.metadata.TestDerbyConnector) LongSumAggregatorFactory(org.apache.druid.query.aggregation.LongSumAggregatorFactory) AggregatorFactory(org.apache.druid.query.aggregation.AggregatorFactory) StringDimensionSchema(org.apache.druid.data.input.impl.StringDimensionSchema) TaskStorage(org.apache.druid.indexing.overlord.TaskStorage) SupervisorStateManagerConfig(org.apache.druid.indexing.overlord.supervisor.SupervisorStateManagerConfig) TaskQueue(org.apache.druid.indexing.overlord.TaskQueue) DimensionsSpec(org.apache.druid.data.input.impl.DimensionsSpec) MetadataSupervisorManager(org.apache.druid.metadata.MetadataSupervisorManager) TaskMaster(org.apache.druid.indexing.overlord.TaskMaster) SqlSegmentsMetadataManager(org.apache.druid.metadata.SqlSegmentsMetadataManager) Before(org.junit.Before)

Example 7 with TaskStorage

use of org.apache.druid.indexing.overlord.TaskStorage in project druid by druid-io.

the class KinesisSupervisorTest method setupTest.

@Before
public void setupTest() {
    taskStorage = createMock(TaskStorage.class);
    taskMaster = createMock(TaskMaster.class);
    taskRunner = createMock(TaskRunner.class);
    indexerMetadataStorageCoordinator = createMock(IndexerMetadataStorageCoordinator.class);
    taskClient = createMock(KinesisIndexTaskClient.class);
    taskQueue = createMock(TaskQueue.class);
    supervisorRecordSupplier = createMock(KinesisRecordSupplier.class);
    tuningConfig = new KinesisSupervisorTuningConfig(null, 1000, null, null, 50000, null, new Period("P1Y"), new File("/test"), null, null, null, false, null, null, null, null, numThreads, TEST_CHAT_THREADS, TEST_CHAT_RETRIES, TEST_HTTP_TIMEOUT, TEST_SHUTDOWN_TIMEOUT, null, null, null, 5000, null, null, null, null, null, null, null, null, null);
    rowIngestionMetersFactory = new TestUtils().getRowIngestionMetersFactory();
    serviceEmitter = new ExceptionCapturingServiceEmitter();
    EmittingLogger.registerEmitter(serviceEmitter);
    supervisorConfig = new SupervisorStateManagerConfig();
}
Also used : IndexerMetadataStorageCoordinator(org.apache.druid.indexing.overlord.IndexerMetadataStorageCoordinator) KinesisRecordSupplier(org.apache.druid.indexing.kinesis.KinesisRecordSupplier) KinesisIndexTaskClient(org.apache.druid.indexing.kinesis.KinesisIndexTaskClient) Period(org.joda.time.Period) TaskRunner(org.apache.druid.indexing.overlord.TaskRunner) SeekableStreamIndexTaskRunner(org.apache.druid.indexing.seekablestream.SeekableStreamIndexTaskRunner) TestUtils(org.apache.druid.indexing.common.TestUtils) TaskStorage(org.apache.druid.indexing.overlord.TaskStorage) SupervisorStateManagerConfig(org.apache.druid.indexing.overlord.supervisor.SupervisorStateManagerConfig) TaskQueue(org.apache.druid.indexing.overlord.TaskQueue) TaskMaster(org.apache.druid.indexing.overlord.TaskMaster) File(java.io.File) ExceptionCapturingServiceEmitter(org.apache.druid.server.metrics.ExceptionCapturingServiceEmitter) Before(org.junit.Before)

Example 8 with TaskStorage

use of org.apache.druid.indexing.overlord.TaskStorage in project druid by druid-io.

the class HttpRemoteTaskRunnerTest method testTaskAddedOrUpdated3.

/*
   * Notifications received for tasks not known to TaskRunner maybe known to TaskStorage.
   * This could happen when TaskRunner starts and workers reports running/completed tasks on them.
   */
@Test
public void testTaskAddedOrUpdated3() {
    Task task1 = NoopTask.create("task1");
    Task task2 = NoopTask.create("task2");
    Task task3 = NoopTask.create("task3");
    Task task4 = NoopTask.create("task4");
    Task task5 = NoopTask.create("task5");
    Task task6 = NoopTask.create("task6");
    TaskStorage taskStorage = EasyMock.createMock(TaskStorage.class);
    EasyMock.expect(taskStorage.getStatus(task1.getId())).andReturn(Optional.of(TaskStatus.running(task1.getId())));
    EasyMock.expect(taskStorage.getStatus(task2.getId())).andReturn(Optional.of(TaskStatus.running(task2.getId())));
    EasyMock.expect(taskStorage.getStatus(task3.getId())).andReturn(Optional.of(TaskStatus.success(task3.getId())));
    EasyMock.expect(taskStorage.getStatus(task4.getId())).andReturn(Optional.of(TaskStatus.success(task4.getId())));
    EasyMock.expect(taskStorage.getStatus(task5.getId())).andReturn(Optional.absent());
    EasyMock.expect(taskStorage.getStatus(task6.getId())).andReturn(Optional.absent());
    EasyMock.replay(taskStorage);
    List<Object> listenerNotificationsAccumulator = new ArrayList<>();
    HttpRemoteTaskRunner taskRunner = createTaskRunnerForTestTaskAddedOrUpdated(taskStorage, listenerNotificationsAccumulator);
    Worker worker = new Worker("http", "localhost", "127.0.0.1", 1, "v1", WorkerConfig.DEFAULT_CATEGORY);
    WorkerHolder workerHolder = EasyMock.createMock(WorkerHolder.class);
    EasyMock.expect(workerHolder.getWorker()).andReturn(worker).anyTimes();
    workerHolder.setLastCompletedTaskTime(EasyMock.anyObject());
    workerHolder.resetContinuouslyFailedTasksCount();
    EasyMock.expect(workerHolder.getContinuouslyFailedTasksCount()).andReturn(0);
    workerHolder.shutdownTask(task3.getId());
    workerHolder.shutdownTask(task5.getId());
    EasyMock.replay(workerHolder);
    Assert.assertEquals(0, taskRunner.getKnownTasks().size());
    taskRunner.taskAddedOrUpdated(TaskAnnouncement.create(task1, TaskStatus.running(task1.getId()), TaskLocation.create("worker", 1, 2)), workerHolder);
    taskRunner.taskAddedOrUpdated(TaskAnnouncement.create(task2, TaskStatus.success(task2.getId()), TaskLocation.create("worker", 3, 4)), workerHolder);
    taskRunner.taskAddedOrUpdated(TaskAnnouncement.create(task3, TaskStatus.running(task3.getId()), TaskLocation.create("worker", 5, 6)), workerHolder);
    taskRunner.taskAddedOrUpdated(TaskAnnouncement.create(task4, TaskStatus.success(task4.getId()), TaskLocation.create("worker", 7, 8)), workerHolder);
    taskRunner.taskAddedOrUpdated(TaskAnnouncement.create(task5, TaskStatus.running(task5.getId()), TaskLocation.create("worker", 9, 10)), workerHolder);
    taskRunner.taskAddedOrUpdated(TaskAnnouncement.create(task6, TaskStatus.success(task6.getId()), TaskLocation.create("worker", 11, 12)), workerHolder);
    EasyMock.verify(workerHolder, taskStorage);
    Assert.assertEquals(listenerNotificationsAccumulator, ImmutableList.of(ImmutableList.of(task1.getId(), TaskLocation.create("worker", 1, 2)), ImmutableList.of(task2.getId(), TaskLocation.create("worker", 3, 4)), ImmutableList.of(task2.getId(), TaskStatus.success(task2.getId()))));
}
Also used : Task(org.apache.druid.indexing.common.task.Task) NoopTask(org.apache.druid.indexing.common.task.NoopTask) TaskStorage(org.apache.druid.indexing.overlord.TaskStorage) ArrayList(java.util.ArrayList) Worker(org.apache.druid.indexing.worker.Worker) Test(org.junit.Test)

Example 9 with TaskStorage

use of org.apache.druid.indexing.overlord.TaskStorage in project druid by druid-io.

the class SeekableStreamSupervisorStateTest method setupTest.

@Before
public void setupTest() {
    taskStorage = createMock(TaskStorage.class);
    taskMaster = createMock(TaskMaster.class);
    taskRunner = createMock(TaskRunner.class);
    taskQueue = createMock(TaskQueue.class);
    indexerMetadataStorageCoordinator = createMock(IndexerMetadataStorageCoordinator.class);
    taskClientFactory = createMock(SeekableStreamIndexTaskClientFactory.class);
    spec = createMock(SeekableStreamSupervisorSpec.class);
    indexTaskClient = createMock(SeekableStreamIndexTaskClient.class);
    recordSupplier = (RecordSupplier<String, String, ByteEntity>) createMock(RecordSupplier.class);
    rowIngestionMetersFactory = new TestUtils().getRowIngestionMetersFactory();
    supervisorConfig = new SupervisorStateManagerConfig();
    emitter = new TestEmitter();
    EasyMock.expect(spec.getSupervisorStateManagerConfig()).andReturn(supervisorConfig).anyTimes();
    EasyMock.expect(spec.getDataSchema()).andReturn(getDataSchema()).anyTimes();
    EasyMock.expect(spec.getIoConfig()).andReturn(getIOConfig()).anyTimes();
    EasyMock.expect(spec.getTuningConfig()).andReturn(getTuningConfig()).anyTimes();
    EasyMock.expect(spec.getEmitter()).andReturn(emitter).anyTimes();
    EasyMock.expect(taskClientFactory.build(EasyMock.anyObject(), EasyMock.anyString(), EasyMock.anyInt(), EasyMock.anyObject(), EasyMock.anyLong())).andReturn(indexTaskClient).anyTimes();
    EasyMock.expect(taskMaster.getTaskRunner()).andReturn(Optional.of(taskRunner)).anyTimes();
    EasyMock.expect(taskMaster.getTaskQueue()).andReturn(Optional.of(taskQueue)).anyTimes();
    taskRunner.registerListener(EasyMock.anyObject(TaskRunnerListener.class), EasyMock.anyObject(Executor.class));
    EasyMock.expect(indexerMetadataStorageCoordinator.retrieveDataSourceMetadata(DATASOURCE)).andReturn(null).anyTimes();
    EasyMock.expect(recordSupplier.getAssignment()).andReturn(ImmutableSet.of(SHARD0_PARTITION)).anyTimes();
    EasyMock.expect(recordSupplier.getLatestSequenceNumber(EasyMock.anyObject())).andReturn("10").anyTimes();
}
Also used : SeekableStreamIndexTaskClient(org.apache.druid.indexing.seekablestream.SeekableStreamIndexTaskClient) IndexerMetadataStorageCoordinator(org.apache.druid.indexing.overlord.IndexerMetadataStorageCoordinator) TaskRunnerListener(org.apache.druid.indexing.overlord.TaskRunnerListener) ByteEntity(org.apache.druid.data.input.impl.ByteEntity) SeekableStreamIndexTaskClientFactory(org.apache.druid.indexing.seekablestream.SeekableStreamIndexTaskClientFactory) TaskRunner(org.apache.druid.indexing.overlord.TaskRunner) SeekableStreamIndexTaskRunner(org.apache.druid.indexing.seekablestream.SeekableStreamIndexTaskRunner) TestUtils(org.apache.druid.indexing.common.TestUtils) Executor(java.util.concurrent.Executor) TaskStorage(org.apache.druid.indexing.overlord.TaskStorage) SupervisorStateManagerConfig(org.apache.druid.indexing.overlord.supervisor.SupervisorStateManagerConfig) TaskQueue(org.apache.druid.indexing.overlord.TaskQueue) TaskMaster(org.apache.druid.indexing.overlord.TaskMaster) Before(org.junit.Before)

Aggregations

TaskStorage (org.apache.druid.indexing.overlord.TaskStorage)9 Before (org.junit.Before)6 TaskMaster (org.apache.druid.indexing.overlord.TaskMaster)5 SupervisorStateManagerConfig (org.apache.druid.indexing.overlord.supervisor.SupervisorStateManagerConfig)5 TestUtils (org.apache.druid.indexing.common.TestUtils)4 IndexerMetadataStorageCoordinator (org.apache.druid.indexing.overlord.IndexerMetadataStorageCoordinator)4 Test (org.junit.Test)4 File (java.io.File)3 Executor (java.util.concurrent.Executor)3 TaskQueue (org.apache.druid.indexing.overlord.TaskQueue)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ImmutableList (com.google.common.collect.ImmutableList)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 TaskStatus (org.apache.druid.indexer.TaskStatus)2 TaskToolbox (org.apache.druid.indexing.common.TaskToolbox)2 TaskStorageConfig (org.apache.druid.indexing.common.config.TaskStorageConfig)2 HeapMemoryTaskStorage (org.apache.druid.indexing.overlord.HeapMemoryTaskStorage)2