Search in sources :

Example 16 with RemoteTaskRunner

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

the class PendingTaskBasedResourceManagementStrategyTest method testSomethingTerminating.

@Test
public void testSomethingTerminating() throws Exception {
    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0).times(1);
    EasyMock.expect(autoScaler.ipToIdLookup(EasyMock.<List<String>>anyObject())).andReturn(Lists.<String>newArrayList("ip")).times(2);
    EasyMock.expect(autoScaler.terminate(EasyMock.<List<String>>anyObject())).andReturn(new AutoScalingData(Lists.<String>newArrayList("ip")));
    EasyMock.replay(autoScaler);
    RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
    EasyMock.expect(runner.getWorkers()).andReturn(Arrays.asList(new TestZkWorker(testTask).toImmutable())).times(2);
    EasyMock.expect(runner.getLazyWorkers()).andReturn(Lists.<Worker>newArrayList()).times(2);
    EasyMock.expect(runner.markWorkersLazy((Predicate<ImmutableWorkerInfo>) EasyMock.anyObject(), EasyMock.anyInt())).andReturn(Arrays.asList(new TestZkWorker(testTask).toImmutable().getWorker()));
    EasyMock.replay(runner);
    boolean terminatedSomething = strategy.doTerminate(runner);
    Assert.assertTrue(terminatedSomething);
    Assert.assertTrue(strategy.getStats().toList().size() == 1);
    Assert.assertTrue(strategy.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.TERMINATE);
    terminatedSomething = strategy.doTerminate(runner);
    Assert.assertFalse(terminatedSomething);
    Assert.assertTrue(strategy.getStats().toList().size() == 1);
    Assert.assertTrue(strategy.getStats().toList().get(0).getEvent() == ScalingStats.EVENT.TERMINATE);
    EasyMock.verify(autoScaler);
    EasyMock.verify(runner);
}
Also used : RemoteTaskRunner(io.druid.indexing.overlord.RemoteTaskRunner) Worker(io.druid.indexing.worker.Worker) ZkWorker(io.druid.indexing.overlord.ZkWorker) List(java.util.List) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 17 with RemoteTaskRunner

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

the class PendingTaskBasedResourceManagementStrategyTest method testSuccessfulMinWorkersProvisionWithOldVersionNodeRunning.

@Test
public void testSuccessfulMinWorkersProvisionWithOldVersionNodeRunning() 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.<ImmutableWorkerInfo>asList(new TestZkWorker(testTask).toImmutable(), // Invalid version node
    new TestZkWorker(testTask, "h1", "n1", INVALID_VERSION).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 18 with RemoteTaskRunner

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

the class PendingTaskBasedResourceManagementStrategyTest method testNullWorkerConfig.

@Test
public void testNullWorkerConfig() throws Exception {
    workerConfig.set(null);
    EasyMock.replay(autoScaler);
    RemoteTaskRunner runner = EasyMock.createMock(RemoteTaskRunner.class);
    EasyMock.expect(runner.getPendingTaskPayloads()).andReturn(Arrays.<Task>asList(NoopTask.create())).times(1);
    EasyMock.expect(runner.getWorkers()).andReturn(Arrays.asList(new TestZkWorker(null).toImmutable())).times(2);
    EasyMock.replay(runner);
    boolean terminatedSomething = strategy.doTerminate(runner);
    boolean provisionedSomething = strategy.doProvision(runner);
    Assert.assertFalse(terminatedSomething);
    Assert.assertFalse(provisionedSomething);
    EasyMock.verify(autoScaler);
    EasyMock.verify(runner);
}
Also used : Task(io.druid.indexing.common.task.Task) NoopTask(io.druid.indexing.common.task.NoopTask) RemoteTaskRunner(io.druid.indexing.overlord.RemoteTaskRunner) 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