use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWorkerSelectStrategyTest method testOneDisableWorkerSameUsedCapacity.
@Test
public void testOneDisableWorkerSameUsedCapacity() {
String disabledVersion = "";
final EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWorkerSelectStrategy(null);
ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("lhost", new ImmutableWorkerInfo(new Worker("http", "disableHost", "disableHost", 10, disabledVersion, WorkerConfig.DEFAULT_CATEGORY), 5, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc()), "localhost", new ImmutableWorkerInfo(new Worker("http", "enableHost", "enableHost", 10, "v1", WorkerConfig.DEFAULT_CATEGORY), 5, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null) {
@Override
public String getDataSource() {
return "foo";
}
});
Assert.assertEquals("enableHost", worker.getWorker().getHost());
}
use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWorkerSelectStrategyTest method testFindWorkerForTaskWhenSameCurrCapacityUsed.
@Test
public void testFindWorkerForTaskWhenSameCurrCapacityUsed() {
final EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWorkerSelectStrategy(null);
ImmutableWorkerInfo worker = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), ImmutableMap.of("lhost", new ImmutableWorkerInfo(new Worker("http", "lhost", "lhost", 5, "v1", WorkerConfig.DEFAULT_CATEGORY), 5, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc()), "localhost", new ImmutableWorkerInfo(new Worker("http", "localhost", "localhost", 10, "v1", WorkerConfig.DEFAULT_CATEGORY), 5, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null) {
@Override
public String getDataSource() {
return "foo";
}
});
Assert.assertEquals("localhost", worker.getWorker().getHost());
}
use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWorkerSelectStrategyTest method testFindWorkerForTask.
@Test
public void testFindWorkerForTask() {
final EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWorkerSelectStrategy(null);
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), 1, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null) {
@Override
public String getDataSource() {
return "foo";
}
});
Assert.assertEquals("lhost", worker.getWorker().getHost());
}
use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class OverlordResourceTest method testGetTotalWorkerCapacityWithAutoScaleConfiguredAndProvisioningStrategySupportExpectedWorkerCapacity.
@Test
public void testGetTotalWorkerCapacityWithAutoScaleConfiguredAndProvisioningStrategySupportExpectedWorkerCapacity() {
int expectedWorkerCapacity = 3;
int maxNumWorkers = 2;
WorkerTaskRunner workerTaskRunner = EasyMock.createMock(WorkerTaskRunner.class);
Collection<ImmutableWorkerInfo> workerInfos = ImmutableList.of(new ImmutableWorkerInfo(new Worker("http", "testWorker", "192.0.0.1", expectedWorkerCapacity, "v1", WorkerConfig.DEFAULT_CATEGORY), 2, ImmutableSet.of("grp1", "grp2"), ImmutableSet.of("task1", "task2"), DateTimes.of("2015-01-01T01:01:01Z")));
EasyMock.expect(workerTaskRunner.getWorkers()).andReturn(workerInfos);
EasyMock.reset(taskMaster);
EasyMock.expect(taskMaster.getTaskRunner()).andReturn(Optional.of(workerTaskRunner)).anyTimes();
EasyMock.expect(provisioningStrategy.getExpectedWorkerCapacity(workerInfos)).andReturn(expectedWorkerCapacity).anyTimes();
AutoScaler autoScaler = EasyMock.createMock(AutoScaler.class);
EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0);
EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(maxNumWorkers);
DefaultWorkerBehaviorConfig workerBehaviorConfig = new DefaultWorkerBehaviorConfig(null, autoScaler);
AtomicReference<WorkerBehaviorConfig> workerBehaviorConfigAtomicReference = new AtomicReference<>(workerBehaviorConfig);
EasyMock.expect(configManager.watch(WorkerBehaviorConfig.CONFIG_KEY, WorkerBehaviorConfig.class)).andReturn(workerBehaviorConfigAtomicReference);
EasyMock.replay(workerTaskRunner, autoScaler, taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req, workerTaskRunnerQueryAdapter, configManager, provisioningStrategy);
final Response response = overlordResource.getTotalWorkerCapacity();
Assert.assertEquals(HttpResponseStatus.OK.getCode(), response.getStatus());
Assert.assertEquals(expectedWorkerCapacity, ((TotalWorkerCapacityResponse) response.getEntity()).getCurrentClusterCapacity());
Assert.assertEquals(expectedWorkerCapacity * maxNumWorkers, ((TotalWorkerCapacityResponse) response.getEntity()).getMaximumCapacityWithAutoScale());
}
use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWithCategorySpecWorkerSelectStrategyTest method testStrongTierSpec.
@Test
public void testStrongTierSpec() {
final WorkerCategorySpec workerCategorySpec = new WorkerCategorySpec(ImmutableMap.of("noop", new WorkerCategorySpec.CategoryConfig("c1", ImmutableMap.of("ds1", "c3"))), true);
ImmutableWorkerInfo worker = selectWorker(workerCategorySpec);
Assert.assertNull(worker);
}
Aggregations