Search in sources :

Example 16 with ImmutableWorkerInfo

use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo 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"));
    // batch tasks should be sent to worker1
    Assert.assertEquals(worker1, workerForBatchTask);
    ImmutableWorkerInfo workerForOtherTask = STRATEGY.findWorkerForTask(new TestRemoteTaskRunnerConfig(new Period("PT1S")), workerMap, createMockTask("other_type"));
    // all other tasks should be sent to worker2
    Assert.assertEquals(worker2, workerForOtherTask);
}
Also used : TestRemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.TestRemoteTaskRunnerConfig) Period(org.joda.time.Period) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 17 with ImmutableWorkerInfo

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

the class JavaScriptWorkerSelectStrategyTest method testNoWorkerCanRunTask.

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

Example 18 with ImmutableWorkerInfo

use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo 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));
    ImmutableWorkerInfo workerForBatchTask = STRATEGY.findWorkerForTask(new TestRemoteTaskRunnerConfig(new Period("PT1S")), workerMap, createMockTask("index_hadoop"));
    Assert.assertEquals(workerMap.get("10.0.0.2"), workerForBatchTask);
}
Also used : TestRemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.TestRemoteTaskRunnerConfig) Period(org.joda.time.Period) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 19 with ImmutableWorkerInfo

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

the class PendingTaskBasedProvisioningStrategyTest method testGetExpectedWorkerCapacityWithMultipleWorker.

@Test
public void testGetExpectedWorkerCapacityWithMultipleWorker() {
    int workerOneCapacity = 3;
    int workerTwoCapacity = 6;
    Collection<ImmutableWorkerInfo> workerInfoCollection = ImmutableList.of(new ImmutableWorkerInfo(new Worker("http", "localhost0", "localhost0", workerOneCapacity, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc()), new ImmutableWorkerInfo(new Worker("http", "localhost0", "localhost0", workerTwoCapacity + 3, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc()));
    int expectedWorkerCapacity = strategy.getExpectedWorkerCapacity(workerInfoCollection);
    // Use capacity of the first worker in the list
    Assert.assertEquals(workerOneCapacity, expectedWorkerCapacity);
}
Also used : Worker(org.apache.druid.indexing.worker.Worker) ZkWorker(org.apache.druid.indexing.overlord.ZkWorker) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 20 with ImmutableWorkerInfo

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

the class FillCapacityWithCategorySpecWorkerSelectStrategyTest method testFindWorkerForTaskWithPreferredTier.

@Test
public void testFindWorkerForTaskWithPreferredTier() {
    // test defaultTier != null and tierAffinity is not empty
    final WorkerCategorySpec workerCategorySpec1 = new WorkerCategorySpec(ImmutableMap.of("noop", new WorkerCategorySpec.CategoryConfig("c1", ImmutableMap.of("ds1", "c1"))), false);
    ImmutableWorkerInfo worker1 = selectWorker(workerCategorySpec1);
    Assert.assertEquals("localhost1", worker1.getWorker().getHost());
    // test defaultTier == null and tierAffinity is not empty
    final WorkerCategorySpec workerCategorySpec2 = new WorkerCategorySpec(ImmutableMap.of("noop", new WorkerCategorySpec.CategoryConfig(null, ImmutableMap.of("ds1", "c1"))), false);
    ImmutableWorkerInfo worker2 = selectWorker(workerCategorySpec2);
    Assert.assertEquals("localhost1", worker2.getWorker().getHost());
    // test defaultTier != null and tierAffinity is empty
    final WorkerCategorySpec workerCategorySpec3 = new WorkerCategorySpec(ImmutableMap.of("noop", new WorkerCategorySpec.CategoryConfig("c1", null)), false);
    ImmutableWorkerInfo worker3 = selectWorker(workerCategorySpec3);
    Assert.assertEquals("localhost1", worker3.getWorker().getHost());
}
Also used : ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Aggregations

ImmutableWorkerInfo (org.apache.druid.indexing.overlord.ImmutableWorkerInfo)42 Test (org.junit.Test)31 RemoteTaskRunnerConfig (org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig)14 Worker (org.apache.druid.indexing.worker.Worker)14 NoopTask (org.apache.druid.indexing.common.task.NoopTask)12 TestRemoteTaskRunnerConfig (org.apache.druid.indexing.overlord.TestRemoteTaskRunnerConfig)5 Period (org.joda.time.Period)5 HashMap (java.util.HashMap)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 WorkerTaskRunner (org.apache.druid.indexing.overlord.WorkerTaskRunner)3 DefaultWorkerBehaviorConfig (org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig)3 WorkerBehaviorConfig (org.apache.druid.indexing.overlord.setup.WorkerBehaviorConfig)3 HashSet (java.util.HashSet)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Nullable (javax.annotation.Nullable)2 Response (javax.ws.rs.core.Response)2 ZkWorker (org.apache.druid.indexing.overlord.ZkWorker)2 AutoScaler (org.apache.druid.indexing.overlord.autoscaling.AutoScaler)2 ResourceFilters (com.sun.jersey.spi.container.ResourceFilters)1 GET (javax.ws.rs.GET)1