Search in sources :

Example 11 with RemoteTaskRunner

use of io.druid.indexing.overlord.RemoteTaskRunner 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);
}
Also used : RemoteTaskRunnerWorkItem(io.druid.indexing.overlord.RemoteTaskRunnerWorkItem) RemoteTaskRunner(io.druid.indexing.overlord.RemoteTaskRunner) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 12 with RemoteTaskRunner

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

the class PendingTaskBasedResourceManagementStrategyTest method testSuccessfulMinWorkersProvision.

@Test
public void testSuccessfulMinWorkersProvision() throws Exception {
    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(3);
    EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(5);
    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.<String>newArrayList());
    RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
    // No pending tasks
    EasyMock.expect(runner.getPendingTaskPayloads()).andReturn(Lists.<Task>newArrayList());
    // 1 node already running, only provision 2 more.
    EasyMock.expect(runner.getWorkers()).andReturn(Arrays.asList(new TestZkWorker(testTask).toImmutable()));
    EasyMock.expect(runner.getConfig()).andReturn(new RemoteTaskRunnerConfig());
    EasyMock.expect(autoScaler.provision()).andReturn(new AutoScalingData(Lists.<String>newArrayList("aNode"))).times(2);
    EasyMock.replay(runner, autoScaler);
    boolean provisionedSomething = strategy.doProvision(runner);
    Assert.assertTrue(provisionedSomething);
    Assert.assertTrue(strategy.getStats().toList().size() == 2);
    for (ScalingStats.ScalingEvent event : strategy.getStats().toList()) {
        Assert.assertTrue(event.getEvent() == ScalingStats.EVENT.PROVISION);
    }
}
Also used : RemoteTaskRunner(io.druid.indexing.overlord.RemoteTaskRunner) RemoteTaskRunnerConfig(io.druid.indexing.overlord.config.RemoteTaskRunnerConfig) Test(org.junit.Test)

Example 13 with RemoteTaskRunner

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

the class SimpleResourceManagementStrategyTest method testSomethingProvisioning.

@Test
public void testSomethingProvisioning() throws Exception {
    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0).times(2);
    EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(2).times(2);
    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.<String>newArrayList()).times(2);
    EasyMock.expect(autoScaler.provision()).andReturn(new AutoScalingData(Lists.newArrayList("fake")));
    RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
    EasyMock.expect(runner.getPendingTasks()).andReturn(Collections.singletonList(new RemoteTaskRunnerWorkItem(testTask.getId(), null, null).withQueueInsertionTime(new DateTime()))).times(2);
    EasyMock.expect(runner.getWorkers()).andReturn(Collections.singletonList(new TestZkWorker(testTask).toImmutable())).times(2);
    EasyMock.replay(runner);
    EasyMock.replay(autoScaler);
    boolean provisionedSomething = simpleResourceManagementStrategy.doProvision(runner);
    Assert.assertTrue(provisionedSomething);
    Assert.assertTrue(simpleResourceManagementStrategy.getStats().toList().size() == 1);
    DateTime createdTime = simpleResourceManagementStrategy.getStats().toList().get(0).getTimestamp();
    Assert.assertTrue(simpleResourceManagementStrategy.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.PROVISION);
    provisionedSomething = simpleResourceManagementStrategy.doProvision(runner);
    Assert.assertFalse(provisionedSomething);
    Assert.assertTrue(simpleResourceManagementStrategy.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.PROVISION);
    DateTime anotherCreatedTime = simpleResourceManagementStrategy.getStats().toList().get(0).getTimestamp();
    Assert.assertTrue(createdTime.equals(anotherCreatedTime));
    EasyMock.verify(autoScaler);
    EasyMock.verify(runner);
}
Also used : RemoteTaskRunnerWorkItem(io.druid.indexing.overlord.RemoteTaskRunnerWorkItem) RemoteTaskRunner(io.druid.indexing.overlord.RemoteTaskRunner) List(java.util.List) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 14 with RemoteTaskRunner

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

the class SimpleResourceManagementStrategyTest method testNoActionNeeded.

@Test
public void testNoActionNeeded() throws Exception {
    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.singletonList(new RemoteTaskRunnerWorkItem(testTask.getId(), null, null).withQueueInsertionTime(new DateTime()))).times(2);
    EasyMock.expect(runner.getWorkers()).andReturn(Arrays.asList(new TestZkWorker(NoopTask.create()).toImmutable(), new TestZkWorker(NoopTask.create()).toImmutable())).times(2);
    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);
    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.verify(runner);
}
Also used : RemoteTaskRunnerWorkItem(io.druid.indexing.overlord.RemoteTaskRunnerWorkItem) RemoteTaskRunner(io.druid.indexing.overlord.RemoteTaskRunner) DateTime(org.joda.time.DateTime) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 15 with RemoteTaskRunner

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

the class SimpleResourceManagementStrategyTest method testDoSuccessfulTerminate.

@Test
public void testDoSuccessfulTerminate() throws Exception {
    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0);
    EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(1);
    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.<String>newArrayList());
    EasyMock.expect(autoScaler.terminate(EasyMock.<List<String>>anyObject())).andReturn(new AutoScalingData(Lists.<String>newArrayList()));
    EasyMock.replay(autoScaler);
    RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
    EasyMock.expect(runner.getPendingTasks()).andReturn(Collections.singletonList(new RemoteTaskRunnerWorkItem(testTask.getId(), null, null).withQueueInsertionTime(new DateTime()))).times(2);
    EasyMock.expect(runner.getWorkers()).andReturn(Collections.singletonList(new TestZkWorker(testTask).toImmutable())).times(2);
    EasyMock.expect(runner.markWorkersLazy(EasyMock.<Predicate<ImmutableWorkerInfo>>anyObject(), EasyMock.anyInt())).andReturn(Collections.<Worker>singletonList(new TestZkWorker(testTask).getWorker()));
    EasyMock.expect(runner.getLazyWorkers()).andReturn(Lists.<Worker>newArrayList());
    EasyMock.replay(runner);
    boolean terminatedSomething = simpleResourceManagementStrategy.doTerminate(runner);
    Assert.assertTrue(terminatedSomething);
    Assert.assertTrue(simpleResourceManagementStrategy.getStats().toList().size() == 1);
    Assert.assertTrue(simpleResourceManagementStrategy.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.TERMINATE);
    EasyMock.verify(autoScaler);
}
Also used : RemoteTaskRunnerWorkItem(io.druid.indexing.overlord.RemoteTaskRunnerWorkItem) RemoteTaskRunner(io.druid.indexing.overlord.RemoteTaskRunner) DateTime(org.joda.time.DateTime) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Aggregations

RemoteTaskRunner (io.druid.indexing.overlord.RemoteTaskRunner)18 Test (org.junit.Test)18 DateTime (org.joda.time.DateTime)10 ImmutableWorkerInfo (io.druid.indexing.overlord.ImmutableWorkerInfo)9 RemoteTaskRunnerWorkItem (io.druid.indexing.overlord.RemoteTaskRunnerWorkItem)9 RemoteTaskRunnerConfig (io.druid.indexing.overlord.config.RemoteTaskRunnerConfig)7 List (java.util.List)6 NoopTask (io.druid.indexing.common.task.NoopTask)4 Task (io.druid.indexing.common.task.Task)4 ServiceEmitter (com.metamx.emitter.service.ServiceEmitter)2 ZkWorker (io.druid.indexing.overlord.ZkWorker)2 Worker (io.druid.indexing.worker.Worker)2