Search in sources :

Example 1 with TaskMaster

use of io.druid.indexing.overlord.TaskMaster in project druid by druid-io.

the class OverlordTest method setUp.

@Before
public void setUp() throws Exception {
    req = EasyMock.createStrictMock(HttpServletRequest.class);
    supervisorManager = EasyMock.createMock(SupervisorManager.class);
    taskLockbox = EasyMock.createStrictMock(TaskLockbox.class);
    taskLockbox.syncFromStorage();
    EasyMock.expectLastCall().atLeastOnce();
    taskLockbox.add(EasyMock.<Task>anyObject());
    EasyMock.expectLastCall().atLeastOnce();
    taskLockbox.remove(EasyMock.<Task>anyObject());
    EasyMock.expectLastCall().atLeastOnce();
    // for second Noop Task directly added to deep storage.
    taskLockbox.add(EasyMock.<Task>anyObject());
    EasyMock.expectLastCall().atLeastOnce();
    taskLockbox.remove(EasyMock.<Task>anyObject());
    EasyMock.expectLastCall().atLeastOnce();
    taskActionClientFactory = EasyMock.createStrictMock(TaskActionClientFactory.class);
    EasyMock.expect(taskActionClientFactory.create(EasyMock.<Task>anyObject())).andReturn(null).anyTimes();
    EasyMock.replay(taskLockbox, taskActionClientFactory);
    taskStorage = new HeapMemoryTaskStorage(new TaskStorageConfig(null));
    runTaskCountDownLatches = new CountDownLatch[2];
    runTaskCountDownLatches[0] = new CountDownLatch(1);
    runTaskCountDownLatches[1] = new CountDownLatch(1);
    taskCompletionCountDownLatches = new CountDownLatch[2];
    taskCompletionCountDownLatches[0] = new CountDownLatch(1);
    taskCompletionCountDownLatches[1] = new CountDownLatch(1);
    announcementLatch = new CountDownLatch(1);
    IndexerZkConfig indexerZkConfig = new IndexerZkConfig(new ZkPathsConfig(), null, null, null, null, null);
    setupServerAndCurator();
    curator.start();
    curator.blockUntilConnected();
    curator.create().creatingParentsIfNeeded().forPath(indexerZkConfig.getLeaderLatchPath());
    druidNode = new DruidNode("hey", "what", 1234);
    ServiceEmitter serviceEmitter = new NoopServiceEmitter();
    taskMaster = new TaskMaster(new TaskQueueConfig(null, new Period(1), null, new Period(10)), taskLockbox, taskStorage, taskActionClientFactory, druidNode, indexerZkConfig, new TaskRunnerFactory<MockTaskRunner>() {

        @Override
        public MockTaskRunner build() {
            return new MockTaskRunner(runTaskCountDownLatches, taskCompletionCountDownLatches);
        }
    }, curator, new NoopServiceAnnouncer() {

        @Override
        public void announce(DruidNode node) {
            announcementLatch.countDown();
        }
    }, new CoordinatorOverlordServiceConfig(null, null), serviceEmitter, supervisorManager, EasyMock.createNiceMock(OverlordHelperManager.class));
    EmittingLogger.registerEmitter(serviceEmitter);
}
Also used : IndexerZkConfig(io.druid.server.initialization.IndexerZkConfig) NoopServiceEmitter(io.druid.server.metrics.NoopServiceEmitter) ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) Task(io.druid.indexing.common.task.Task) NoopTask(io.druid.indexing.common.task.NoopTask) CoordinatorOverlordServiceConfig(io.druid.server.coordinator.CoordinatorOverlordServiceConfig) TaskStorageConfig(io.druid.indexing.common.config.TaskStorageConfig) HeapMemoryTaskStorage(io.druid.indexing.overlord.HeapMemoryTaskStorage) TaskActionClientFactory(io.druid.indexing.common.actions.TaskActionClientFactory) Period(org.joda.time.Period) NoopServiceEmitter(io.druid.server.metrics.NoopServiceEmitter) CountDownLatch(java.util.concurrent.CountDownLatch) HttpServletRequest(javax.servlet.http.HttpServletRequest) SupervisorManager(io.druid.indexing.overlord.supervisor.SupervisorManager) ZkPathsConfig(io.druid.server.initialization.ZkPathsConfig) TaskLockbox(io.druid.indexing.overlord.TaskLockbox) TaskQueueConfig(io.druid.indexing.overlord.config.TaskQueueConfig) DruidNode(io.druid.server.DruidNode) TaskMaster(io.druid.indexing.overlord.TaskMaster) NoopServiceAnnouncer(io.druid.curator.discovery.NoopServiceAnnouncer) TaskRunnerFactory(io.druid.indexing.overlord.TaskRunnerFactory) Before(org.junit.Before)

Example 2 with TaskMaster

use of io.druid.indexing.overlord.TaskMaster in project druid by druid-io.

the class KafkaSupervisorTest method setUp.

@Before
public void setUp() throws Exception {
    taskStorage = createMock(TaskStorage.class);
    taskMaster = createMock(TaskMaster.class);
    taskRunner = createMock(TaskRunner.class);
    indexerMetadataStorageCoordinator = createMock(IndexerMetadataStorageCoordinator.class);
    taskClient = createMock(KafkaIndexTaskClient.class);
    taskQueue = createMock(TaskQueue.class);
    zkServer = new TestingCluster(1);
    zkServer.start();
    kafkaServer = new TestBroker(zkServer.getConnectString(), tempFolder.newFolder(), 1, ImmutableMap.of("num.partitions", String.valueOf(NUM_PARTITIONS)));
    kafkaServer.start();
    kafkaHost = String.format("localhost:%d", kafkaServer.getPort());
    dataSchema = getDataSchema(DATASOURCE);
    tuningConfig = new KafkaSupervisorTuningConfig(1000, 50000, new Period("P1Y"), new File("/test"), null, null, true, false, null, null, numThreads, TEST_CHAT_THREADS, TEST_CHAT_RETRIES, TEST_HTTP_TIMEOUT, TEST_SHUTDOWN_TIMEOUT);
}
Also used : IndexerMetadataStorageCoordinator(io.druid.indexing.overlord.IndexerMetadataStorageCoordinator) TestingCluster(org.apache.curator.test.TestingCluster) TaskStorage(io.druid.indexing.overlord.TaskStorage) TestBroker(io.druid.indexing.kafka.test.TestBroker) KafkaIndexTaskClient(io.druid.indexing.kafka.KafkaIndexTaskClient) TaskQueue(io.druid.indexing.overlord.TaskQueue) Period(org.joda.time.Period) TaskMaster(io.druid.indexing.overlord.TaskMaster) File(java.io.File) TaskRunner(io.druid.indexing.overlord.TaskRunner) Before(org.junit.Before)

Example 3 with TaskMaster

use of io.druid.indexing.overlord.TaskMaster in project druid by druid-io.

the class OverlordResourceTest method setUp.

@Before
public void setUp() throws Exception {
    taskRunner = EasyMock.createMock(TaskRunner.class);
    taskMaster = EasyMock.createStrictMock(TaskMaster.class);
    tsqa = EasyMock.createStrictMock(TaskStorageQueryAdapter.class);
    req = EasyMock.createStrictMock(HttpServletRequest.class);
    EasyMock.expect(taskMaster.getTaskRunner()).andReturn(Optional.of(taskRunner)).anyTimes();
    overlordResource = new OverlordResource(taskMaster, tsqa, null, null, null, new AuthConfig(true));
    EasyMock.expect(req.getAttribute(AuthConfig.DRUID_AUTH_TOKEN)).andReturn(new AuthorizationInfo() {

        @Override
        public Access isAuthorized(Resource resource, Action action) {
            if (resource.getName().equals("allow")) {
                return new Access(true);
            } else {
                return new Access(false);
            }
        }
    });
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Action(io.druid.server.security.Action) Resource(io.druid.server.security.Resource) Access(io.druid.server.security.Access) AuthConfig(io.druid.server.security.AuthConfig) TaskMaster(io.druid.indexing.overlord.TaskMaster) AuthorizationInfo(io.druid.server.security.AuthorizationInfo) TaskStorageQueryAdapter(io.druid.indexing.overlord.TaskStorageQueryAdapter) TaskRunner(io.druid.indexing.overlord.TaskRunner) Before(org.junit.Before)

Aggregations

TaskMaster (io.druid.indexing.overlord.TaskMaster)3 Before (org.junit.Before)3 TaskRunner (io.druid.indexing.overlord.TaskRunner)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Period (org.joda.time.Period)2 ServiceEmitter (com.metamx.emitter.service.ServiceEmitter)1 NoopServiceAnnouncer (io.druid.curator.discovery.NoopServiceAnnouncer)1 TaskActionClientFactory (io.druid.indexing.common.actions.TaskActionClientFactory)1 TaskStorageConfig (io.druid.indexing.common.config.TaskStorageConfig)1 NoopTask (io.druid.indexing.common.task.NoopTask)1 Task (io.druid.indexing.common.task.Task)1 KafkaIndexTaskClient (io.druid.indexing.kafka.KafkaIndexTaskClient)1 TestBroker (io.druid.indexing.kafka.test.TestBroker)1 HeapMemoryTaskStorage (io.druid.indexing.overlord.HeapMemoryTaskStorage)1 IndexerMetadataStorageCoordinator (io.druid.indexing.overlord.IndexerMetadataStorageCoordinator)1 TaskLockbox (io.druid.indexing.overlord.TaskLockbox)1 TaskQueue (io.druid.indexing.overlord.TaskQueue)1 TaskRunnerFactory (io.druid.indexing.overlord.TaskRunnerFactory)1 TaskStorage (io.druid.indexing.overlord.TaskStorage)1 TaskStorageQueryAdapter (io.druid.indexing.overlord.TaskStorageQueryAdapter)1