use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWithAffinityWorkerSelectStrategyTest method testFindWorkerForTaskWithNulls.
@Test
public void testFindWorkerForTaskWithNulls() {
EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWithAffinityWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost")), false));
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), 0, new HashSet<>(), new HashSet<>(), DateTimes.nowUtc())), new NoopTask(null, null, null, 1, 0, null, null, null));
Assert.assertEquals("lhost", worker.getWorker().getHost());
}
use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWorkerSelectStrategyTest method testStrongAffinity.
@Test
public void testStrongAffinity() {
EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost1", "localhost2", "localhost3"), "bar", ImmutableSet.of("nonexistent-worker")), true));
ImmutableWorkerInfo workerFoo = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_AFFINITY_TESTS, createDummyTask("foo"));
Assert.assertEquals("localhost1", workerFoo.getWorker().getHost());
// With strong affinity, no workers can be found for bar.
ImmutableWorkerInfo workerBar = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_AFFINITY_TESTS, createDummyTask("bar"));
Assert.assertNull(workerBar);
ImmutableWorkerInfo workerBaz = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_AFFINITY_TESTS, createDummyTask("baz"));
Assert.assertEquals("localhost0", workerBaz.getWorker().getHost());
}
use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class EqualDistributionWorkerSelectStrategyTest method testWeakAffinity.
@Test
public void testWeakAffinity() {
EqualDistributionWorkerSelectStrategy strategy = new EqualDistributionWorkerSelectStrategy(new AffinityConfig(ImmutableMap.of("foo", ImmutableSet.of("localhost1", "localhost2", "localhost3"), "bar", ImmutableSet.of("nonexistent-worker")), false));
ImmutableWorkerInfo workerFoo = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_AFFINITY_TESTS, createDummyTask("foo"));
Assert.assertEquals("localhost1", workerFoo.getWorker().getHost());
// With weak affinity, bar (which has no affinity workers available) can use a non-affinity worker.
ImmutableWorkerInfo workerBar = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_AFFINITY_TESTS, createDummyTask("bar"));
Assert.assertEquals("localhost0", workerBar.getWorker().getHost());
ImmutableWorkerInfo workerBaz = strategy.findWorkerForTask(new RemoteTaskRunnerConfig(), WORKERS_FOR_AFFINITY_TESTS, createDummyTask("baz"));
Assert.assertEquals("localhost0", workerBaz.getWorker().getHost());
}
use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class FillCapacityWithCategorySpecWorkerSelectStrategyTest 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);
}
use of org.apache.druid.indexing.overlord.ImmutableWorkerInfo in project druid by druid-io.
the class FillCapacityWithCategorySpecWorkerSelectStrategyTest method testFindWorkerForTaskWithNullWorkerTierSpec.
@Test
public void testFindWorkerForTaskWithNullWorkerTierSpec() {
ImmutableWorkerInfo worker = selectWorker(null);
Assert.assertEquals("localhost3", worker.getWorker().getHost());
}
Aggregations