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);
}
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;
}
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);
}
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());
}
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());
}
Aggregations