use of io.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class SimpleResourceManagementStrategyTest method testMinCountIncrease.
@Test
public void testMinCountIncrease() throws Exception {
// Don't terminate anything
EasyMock.reset(autoScaler);
EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0);
EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(2);
EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.newArrayList("ip"));
EasyMock.replay(autoScaler);
RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
EasyMock.expect(runner.getPendingTasks()).andReturn(Collections.<RemoteTaskRunnerWorkItem>emptyList()).times(3);
EasyMock.expect(runner.getWorkers()).andReturn(Collections.singletonList(new TestZkWorker(NoopTask.create(), "h1", "i1", "0").toImmutable())).times(3);
EasyMock.expect(runner.getLazyWorkers()).andReturn(Lists.<Worker>newArrayList());
EasyMock.expect(runner.markWorkersLazy(EasyMock.<Predicate<ImmutableWorkerInfo>>anyObject(), EasyMock.anyInt())).andReturn(Collections.<Worker>emptyList());
EasyMock.replay(runner);
boolean terminatedSomething = simpleResourceManagementStrategy.doTerminate(runner);
Assert.assertFalse(terminatedSomething);
EasyMock.verify(autoScaler);
// Don't provision anything
EasyMock.reset(autoScaler);
EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0);
EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(2);
EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.newArrayList("ip"));
EasyMock.replay(autoScaler);
boolean provisionedSomething = simpleResourceManagementStrategy.doProvision(runner);
Assert.assertFalse(provisionedSomething);
EasyMock.verify(autoScaler);
EasyMock.reset(autoScaler);
// Increase minNumWorkers
EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(3);
EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(5);
EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.newArrayList("ip"));
EasyMock.expect(autoScaler.provision()).andReturn(new AutoScalingData(Lists.newArrayList("h3")));
// Should provision two new workers
EasyMock.expect(autoScaler.provision()).andReturn(new AutoScalingData(Lists.newArrayList("h4")));
EasyMock.replay(autoScaler);
provisionedSomething = simpleResourceManagementStrategy.doProvision(runner);
Assert.assertTrue(provisionedSomething);
EasyMock.verify(autoScaler);
EasyMock.verify(runner);
}
use of io.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWorkerSelectStrategyTest method testFindWorkerForTask.
@Test
public void testFindWorkerForTask() throws Exception {
final EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWorkerSelectStrategy();
Optional<ImmutableWorkerInfo> optional = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("lhost", new ImmutableWorkerInfo(new Worker("lhost", "lhost", 1, "v1"), 0, Sets.<String>newHashSet(), Sets.<String>newHashSet(), DateTime.now()), "localhost", new ImmutableWorkerInfo(new Worker("localhost", "localhost", 1, "v1"), 1, Sets.<String>newHashSet(), Sets.<String>newHashSet(), DateTime.now())), new NoopTask(null, 1, 0, null, null, null) {
@Override
public String getDataSource() {
return "foo";
}
});
ImmutableWorkerInfo worker = optional.get();
Assert.assertEquals("lhost", worker.getWorker().getHost());
}
use of io.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWorkerSelectStrategyTest method testOneDisableWorkerSameUsedCapacity.
@Test
public void testOneDisableWorkerSameUsedCapacity() throws Exception {
String DISABLED_VERSION = "";
final EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWorkerSelectStrategy();
Optional<ImmutableWorkerInfo> optional = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("lhost", new ImmutableWorkerInfo(new Worker("disableHost", "disableHost", 10, DISABLED_VERSION), 5, Sets.<String>newHashSet(), Sets.<String>newHashSet(), DateTime.now()), "localhost", new ImmutableWorkerInfo(new Worker("enableHost", "enableHost", 10, "v1"), 5, Sets.<String>newHashSet(), Sets.<String>newHashSet(), DateTime.now())), new NoopTask(null, 1, 0, null, null, null) {
@Override
public String getDataSource() {
return "foo";
}
});
ImmutableWorkerInfo worker = optional.get();
Assert.assertEquals("enableHost", worker.getWorker().getHost());
}
use of io.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWorkerSelectStrategyTest method testOneDisableWorkerDifferentUsedCapacity.
@Test
public void testOneDisableWorkerDifferentUsedCapacity() throws Exception {
String DISABLED_VERSION = "";
final EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWorkerSelectStrategy();
Optional<ImmutableWorkerInfo> optional = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("lhost", new ImmutableWorkerInfo(new Worker("disableHost", "disableHost", 10, DISABLED_VERSION), 2, Sets.<String>newHashSet(), Sets.<String>newHashSet(), DateTime.now()), "localhost", new ImmutableWorkerInfo(new Worker("enableHost", "enableHost", 10, "v1"), 5, Sets.<String>newHashSet(), Sets.<String>newHashSet(), DateTime.now())), new NoopTask(null, 1, 0, null, null, null) {
@Override
public String getDataSource() {
return "foo";
}
});
ImmutableWorkerInfo worker = optional.get();
Assert.assertEquals("enableHost", worker.getWorker().getHost());
}
use of io.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class FillCapacityWithAffinityWorkerSelectStrategyTest method testIsolation.
@Test
public void testIsolation() throws Exception {
FillCapacityWorkerSelectStrategy strategy = new FillCapacityWithAffinityWorkerSelectStrategy(new FillCapacityWithAffinityConfig(ImmutableMap.of("foo", Arrays.asList("localhost"))));
Optional<ImmutableWorkerInfo> optional = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("localhost", new ImmutableWorkerInfo(new Worker("localhost", "localhost", 1, "v1"), 0, Sets.<String>newHashSet(), Sets.<String>newHashSet(), DateTime.now())), new NoopTask(null, 1, 0, null, null, null));
Assert.assertFalse(optional.isPresent());
}
Aggregations