Search in sources :

Example 11 with ImmutableWorkerInfo

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);
}
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 ImmutableWorkerInfo

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());
}
Also used : Worker(io.druid.indexing.worker.Worker) NoopTask(io.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(io.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 13 with ImmutableWorkerInfo

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());
}
Also used : Worker(io.druid.indexing.worker.Worker) NoopTask(io.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(io.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 14 with ImmutableWorkerInfo

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());
}
Also used : Worker(io.druid.indexing.worker.Worker) NoopTask(io.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(io.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Example 15 with ImmutableWorkerInfo

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());
}
Also used : Worker(io.druid.indexing.worker.Worker) NoopTask(io.druid.indexing.common.task.NoopTask) RemoteTaskRunnerConfig(io.druid.indexing.overlord.config.RemoteTaskRunnerConfig) ImmutableWorkerInfo(io.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Aggregations

ImmutableWorkerInfo (io.druid.indexing.overlord.ImmutableWorkerInfo)29 Test (org.junit.Test)20 Worker (io.druid.indexing.worker.Worker)10 RemoteTaskRunner (io.druid.indexing.overlord.RemoteTaskRunner)9 RemoteTaskRunnerConfig (io.druid.indexing.overlord.config.RemoteTaskRunnerConfig)9 DateTime (org.joda.time.DateTime)9 NoopTask (io.druid.indexing.common.task.NoopTask)8 RemoteTaskRunnerWorkItem (io.druid.indexing.overlord.RemoteTaskRunnerWorkItem)5 TestRemoteTaskRunnerConfig (io.druid.indexing.overlord.TestRemoteTaskRunnerConfig)5 Period (org.joda.time.Period)5 Task (io.druid.indexing.common.task.Task)4 WorkerBehaviorConfig (io.druid.indexing.overlord.setup.WorkerBehaviorConfig)4 Duration (org.joda.time.Duration)4 Function (com.google.common.base.Function)3 List (java.util.List)3 ZkWorker (io.druid.indexing.overlord.ZkWorker)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 WorkerSelectStrategy (io.druid.indexing.overlord.setup.WorkerSelectStrategy)1