use of org.apache.druid.server.coordinator.CachingCostBalancerStrategy in project druid by druid-io.
the class CachingCostBalancerStrategyTest method decisionTest.
@Test
public void decisionTest() {
CachingCostBalancerStrategy cachingCostBalancerStrategy = createCachingCostBalancerStrategy(serverHolderList, executorService);
CostBalancerStrategy costBalancerStrategy = createCostBalancerStrategy(executorService);
int notEqual = segmentQueries.stream().mapToInt(s -> {
ServerHolder s1 = cachingCostBalancerStrategy.findNewSegmentHomeBalancer(s, serverHolderList);
ServerHolder s2 = costBalancerStrategy.findNewSegmentHomeBalancer(s, serverHolderList);
return (s1.getServer().getName().equals(s2.getServer().getName())) ? 0 : 1;
}).sum();
Assert.assertTrue(((double) notEqual / (double) segmentQueries.size()) < 0.01);
}
use of org.apache.druid.server.coordinator.CachingCostBalancerStrategy in project druid by druid-io.
the class LoadRuleTest method setUp.
@Before
public void setUp() {
EmittingLogger.registerEmitter(EMITTER);
EMITTER.start();
throttler = EasyMock.createMock(ReplicationThrottler.class);
exec = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1));
balancerStrategy = new CostBalancerStrategyFactory().createBalancerStrategy(exec);
cachingCostBalancerStrategy = new CachingCostBalancerStrategy(ClusterCostCache.builder().build(), exec);
mockBalancerStrategy = EasyMock.createMock(BalancerStrategy.class);
}
Aggregations