Search in sources :

Example 1 with TestRemoteTaskRunnerConfig

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

the class JavaScriptWorkerSelectStrategyTest method testFillWorkerCapacity.

@Test
public void testFillWorkerCapacity() {
    // tasks shoudl be assigned to the worker with maximum currCapacity used until its full
    ImmutableMap<String, ImmutableWorkerInfo> workerMap = ImmutableMap.of("10.0.0.1", createMockWorker(1, true, true), "10.0.0.2", createMockWorker(5, true, true));
    Optional<ImmutableWorkerInfo> workerForBatchTask = STRATEGY.findWorkerForTask(new TestRemoteTaskRunnerConfig(new Period("PT1S")), workerMap, createMockTask("index_hadoop"));
    Assert.assertEquals(workerMap.get("10.0.0.2"), workerForBatchTask.get());
}
Also used : TestRemoteTaskRunnerConfig(io.druid.indexing.overlord.TestRemoteTaskRunnerConfig) Period(org.joda.time.Period) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 2 with TestRemoteTaskRunnerConfig

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

the class WorkerTaskMonitorTest method setUp.

@Before
public void setUp() throws Exception {
    testingCluster = new TestingCluster(1);
    testingCluster.start();
    cf = CuratorFrameworkFactory.builder().connectString(testingCluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1, 10)).compressionProvider(new PotentiallyGzippedCompressionProvider(false)).build();
    cf.start();
    cf.blockUntilConnected();
    cf.create().creatingParentsIfNeeded().forPath(basePath);
    worker = new Worker("worker", "localhost", 3, "0");
    workerCuratorCoordinator = new WorkerCuratorCoordinator(jsonMapper, new IndexerZkConfig(new ZkPathsConfig() {

        @Override
        public String getBase() {
            return basePath;
        }
    }, null, null, null, null, null), new TestRemoteTaskRunnerConfig(new Period("PT1S")), cf, worker);
    workerCuratorCoordinator.start();
    // Start a task monitor
    workerTaskMonitor = createTaskMonitor();
    TestTasks.registerSubtypes(jsonMapper);
    jsonMapper.registerSubtypes(new NamedType(TestRealtimeTask.class, "test_realtime"));
    workerTaskMonitor.start();
    task = TestTasks.immediateSuccess("test");
}
Also used : IndexerZkConfig(io.druid.server.initialization.IndexerZkConfig) TestRemoteTaskRunnerConfig(io.druid.indexing.overlord.TestRemoteTaskRunnerConfig) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) Period(org.joda.time.Period) PotentiallyGzippedCompressionProvider(io.druid.curator.PotentiallyGzippedCompressionProvider) TestRealtimeTask(io.druid.indexing.common.TestRealtimeTask) TestingCluster(org.apache.curator.test.TestingCluster) ZkPathsConfig(io.druid.server.initialization.ZkPathsConfig) Before(org.junit.Before)

Example 3 with TestRemoteTaskRunnerConfig

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

the class JavaScriptWorkerSelectStrategyTest method testNoValidWorker.

@Test
public void testNoValidWorker() {
    ImmutableMap<String, ImmutableWorkerInfo> workerMap = ImmutableMap.of("10.0.0.1", createMockWorker(1, true, false), "10.0.0.4", createMockWorker(1, true, false));
    Optional<ImmutableWorkerInfo> workerForBatchTask = STRATEGY.findWorkerForTask(new TestRemoteTaskRunnerConfig(new Period("PT1S")), workerMap, createMockTask("index_hadoop"));
    Assert.assertFalse(workerForBatchTask.isPresent());
    Optional<ImmutableWorkerInfo> workerForOtherTask = STRATEGY.findWorkerForTask(new TestRemoteTaskRunnerConfig(new Period("PT1S")), workerMap, createMockTask("otherTask"));
    // all other tasks should be sent to worker2
    Assert.assertFalse(workerForOtherTask.isPresent());
}
Also used : TestRemoteTaskRunnerConfig(io.druid.indexing.overlord.TestRemoteTaskRunnerConfig) Period(org.joda.time.Period) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 4 with TestRemoteTaskRunnerConfig

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

the class JavaScriptWorkerSelectStrategyTest method testIsolationOfBatchWorker.

@Test
public void testIsolationOfBatchWorker() {
    ImmutableMap<String, ImmutableWorkerInfo> workerMap = ImmutableMap.of("10.0.0.1", createMockWorker(1, true, true), "10.0.0.2", createMockWorker(1, true, true));
    Optional<ImmutableWorkerInfo> workerForOtherTask = STRATEGY.findWorkerForTask(new TestRemoteTaskRunnerConfig(new Period("PT1S")), workerMap, createMockTask("other_type"));
    Assert.assertFalse(workerForOtherTask.isPresent());
}
Also used : TestRemoteTaskRunnerConfig(io.druid.indexing.overlord.TestRemoteTaskRunnerConfig) Period(org.joda.time.Period) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 5 with TestRemoteTaskRunnerConfig

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

the class JavaScriptWorkerSelectStrategyTest method testFindWorkerForTask.

@Test
public void testFindWorkerForTask() {
    ImmutableWorkerInfo worker1 = createMockWorker(1, true, true);
    ImmutableWorkerInfo worker2 = createMockWorker(1, true, true);
    ImmutableMap<String, ImmutableWorkerInfo> workerMap = ImmutableMap.of("10.0.0.1", worker1, "10.0.0.3", worker2);
    ImmutableWorkerInfo workerForBatchTask = STRATEGY.findWorkerForTask(new TestRemoteTaskRunnerConfig(new Period("PT1S")), workerMap, createMockTask("index_hadoop")).get();
    // batch tasks should be sent to worker1
    Assert.assertEquals(worker1, workerForBatchTask);
    ImmutableWorkerInfo workerForOtherTask = STRATEGY.findWorkerForTask(new TestRemoteTaskRunnerConfig(new Period("PT1S")), workerMap, createMockTask("other_type")).get();
    // all other tasks should be sent to worker2
    Assert.assertEquals(worker2, workerForOtherTask);
}
Also used : TestRemoteTaskRunnerConfig(io.druid.indexing.overlord.TestRemoteTaskRunnerConfig) Period(org.joda.time.Period) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Aggregations

TestRemoteTaskRunnerConfig (io.druid.indexing.overlord.TestRemoteTaskRunnerConfig)6 Period (org.joda.time.Period)6 ImmutableWorkerInfo (io.druid.indexing.overlord.ImmutableWorkerInfo)5 Test (org.junit.Test)5 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)1 PotentiallyGzippedCompressionProvider (io.druid.curator.PotentiallyGzippedCompressionProvider)1 TestRealtimeTask (io.druid.indexing.common.TestRealtimeTask)1 IndexerZkConfig (io.druid.server.initialization.IndexerZkConfig)1 ZkPathsConfig (io.druid.server.initialization.ZkPathsConfig)1 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)1 TestingCluster (org.apache.curator.test.TestingCluster)1 Before (org.junit.Before)1