Search in sources :

Example 26 with RemoteTaskRunnerConfig

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

the class PendingTaskBasedProvisioningStrategyTest method testProvisioning.

@Test
public void testProvisioning() {
    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(1).times(3);
    EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(2).times(1);
    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.anyObject())).andReturn(new ArrayList<String>()).times(2);
    EasyMock.expect(autoScaler.provision()).andReturn(new AutoScalingData(Collections.singletonList("fake")));
    RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
    EasyMock.expect(runner.getPendingTaskPayloads()).andReturn(Collections.singletonList(NoopTask.create())).times(2);
    EasyMock.expect(runner.getWorkers()).andReturn(Arrays.asList(new TestZkWorker(testTask).toImmutable(), // Invalid version node
    new TestZkWorker(testTask, "http", "h1", "n1", INVALID_VERSION).toImmutable())).times(2);
    EasyMock.expect(runner.getConfig()).andReturn(new RemoteTaskRunnerConfig()).times(1);
    EasyMock.replay(runner);
    EasyMock.replay(autoScaler);
    Provisioner provisioner = strategy.makeProvisioner(runner);
    boolean provisionedSomething = provisioner.doProvision();
    Assert.assertTrue(provisionedSomething);
    Assert.assertTrue(provisioner.getStats().toList().size() == 1);
    DateTime createdTime = provisioner.getStats().toList().get(0).getTimestamp();
    Assert.assertTrue(provisioner.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.PROVISION);
    provisionedSomething = provisioner.doProvision();
    Assert.assertFalse(provisionedSomething);
    Assert.assertTrue(provisioner.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.PROVISION);
    DateTime anotherCreatedTime = provisioner.getStats().toList().get(0).getTimestamp();
    Assert.assertTrue(createdTime.equals(anotherCreatedTime));
    EasyMock.verify(autoScaler);
    EasyMock.verify(runner);
}
Also used : RemoteTaskRunner(org.apache.druid.indexing.overlord.RemoteTaskRunner) ArrayList(java.util.ArrayList) RemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 27 with RemoteTaskRunnerConfig

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

the class EqualDistributionWithCategorySpecWorkerSelectStrategyTest method selectWorker.

private ImmutableWorkerInfo selectWorker(WorkerCategorySpec workerCategorySpec) {
    final EqualDistributionWithCategorySpecWorkerSelectStrategy strategy = new EqualDistributionWithCategorySpecWorkerSelectStrategy(workerCategorySpec);
    ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_TIER_TESTS, new NoopTask(null, null, "ds1", 1, 0, null, null, null));
    return worker;
}
Also used : NoopTask(org.apache.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo)

Example 28 with RemoteTaskRunnerConfig

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

the class FillCapacityWithAffinityWorkerSelectStrategyTest method testIsolation.

@Test
public void testIsolation() {
    FillCapacityWorkerSelectStrategy strategy = new FillCapacityWithAffinityWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost")), false));
    ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("localhost", new ImmutableWorkerInfo(new Worker("http", "localhost", "localhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null));
    Assert.assertNull(worker);
}
Also used : Worker(org.apache.druid.indexing.worker.Worker) NoopTask(org.apache.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 29 with RemoteTaskRunnerConfig

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

the class EqualDistributionWithAffinityWorkerSelectStrategyTest method testFindWorkerForTaskWithNulls.

@Test
public void testFindWorkerForTaskWithNulls() {
    EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWithAffinityWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost")), false));
    ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("lhost", new ImmutableWorkerInfo(new Worker("http", "lhost", "lhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc()), "localhost", new ImmutableWorkerInfo(new Worker("http", "localhost", "localhost", 1, "v1", WorkerConfig.DEFAULT_CATEGORY), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null));
    Assert.assertEquals("lhost", worker.getWorker().getHost());
}
Also used : Worker(org.apache.druid.indexing.worker.Worker) NoopTask(org.apache.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 30 with RemoteTaskRunnerConfig

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

the class EqualDistributionWorkerSelectStrategyTest method testStrongAffinity.

@Test
public void testStrongAffinity() {
    EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost1", "localhost2", "localhost3"), "bar", ImmutableSet.of("nonexistent-worker")), true));
    ImmutableWorkerInfo workerFoo = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_AFFINITY_TESTS, createDummyTask("foo"));
    Assert.assertEquals("localhost1", workerFoo.getWorker().getHost());
    // With strong affinity, no workers can be found for bar.
    ImmutableWorkerInfo workerBar = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_AFFINITY_TESTS, createDummyTask("bar"));
    Assert.assertNull(workerBar);
    ImmutableWorkerInfo workerBaz = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_AFFINITY_TESTS, createDummyTask("baz"));
    Assert.assertEquals("localhost0", workerBaz.getWorker().getHost());
}
Also used : RemoteTaskRunnerConfig(org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Aggregations

RemoteTaskRunnerConfig (org.apache.druid.indexing.overlord.config.RemoteTaskRunnerConfig)32 Test (org.junit.Test)29 ImmutableWorkerInfo (org.apache.druid.indexing.overlord.ImmutableWorkerInfo)14 NoopTask (org.apache.druid.indexing.common.task.NoopTask)12 RemoteTaskRunner (org.apache.druid.indexing.overlord.RemoteTaskRunner)11 Worker (org.apache.druid.indexing.worker.Worker)11 TaskStatus (org.apache.druid.indexer.TaskStatus)5 TestRealtimeTask (org.apache.druid.indexing.common.TestRealtimeTask)5 TaskResource (org.apache.druid.indexing.common.task.TaskResource)5 Supplier (com.google.common.base.Supplier)4 ArrayList (java.util.ArrayList)4 DateTime (org.joda.time.DateTime)4 Period (org.joda.time.Period)4 Function (com.google.common.base.Function)1 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)1 TestingCluster (org.apache.curator.test.TestingCluster)1 PotentiallyGzippedCompressionProvider (org.apache.druid.curator.PotentiallyGzippedCompressionProvider)1 IndexingServiceCondition (org.apache.druid.indexing.common.IndexingServiceCondition)1 WorkerCuratorCoordinator (org.apache.druid.indexing.worker.WorkerCuratorCoordinator)1 ServiceEmitter (org.apache.druid.java.util.emitter.service.ServiceEmitter)1