use of org.apache.helix.model.builder.ConfigScopeBuilder in project helix by apache.
the class TestConfigThreadpoolSize method TestThreadPoolSizeConfig.
@Test
public void TestThreadPoolSizeConfig() {
String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + 0);
HelixManager manager = _participants[0];
ConfigAccessor accessor = manager.getConfigAccessor();
ConfigScope scope = new ConfigScopeBuilder().forCluster(manager.getClusterName()).forParticipant(instanceName).build();
accessor.set(scope, "TestMsg." + HelixTaskExecutor.MAX_THREADS, "" + 12);
scope = new ConfigScopeBuilder().forCluster(manager.getClusterName()).build();
accessor.set(scope, "TestMsg." + HelixTaskExecutor.MAX_THREADS, "" + 8);
for (int i = 0; i < NODE_NR; i++) {
instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_participants[i].getMessagingService().registerMessageHandlerFactory("TestMsg", new TestMessagingHandlerFactory());
_participants[i].getMessagingService().registerMessageHandlerFactory("TestMsg2", new TestMessagingHandlerFactory2());
}
for (int i = 0; i < NODE_NR; i++) {
instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
DefaultMessagingService svc = (DefaultMessagingService) (_participants[i].getMessagingService());
HelixTaskExecutor helixExecutor = svc.getExecutor();
ThreadPoolExecutor executor = (ThreadPoolExecutor) (helixExecutor._executorMap.get("TestMsg"));
ThreadPoolExecutor executor2 = (ThreadPoolExecutor) (helixExecutor._executorMap.get("TestMsg2"));
if (i != 0) {
Assert.assertEquals(8, executor.getMaximumPoolSize());
} else {
Assert.assertEquals(12, executor.getMaximumPoolSize());
}
Assert.assertEquals(HelixTaskExecutor.DEFAULT_PARALLEL_TASKS, executor2.getMaximumPoolSize());
}
}
Aggregations