Search in sources :

Example 6 with ConfigScope

use of org.apache.helix.model.ConfigScope 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());
    }
}
Also used : HelixManager(org.apache.helix.HelixManager) ConfigScope(org.apache.helix.model.ConfigScope) DefaultMessagingService(org.apache.helix.messaging.DefaultMessagingService) ConfigAccessor(org.apache.helix.ConfigAccessor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ConfigScopeBuilder(org.apache.helix.model.builder.ConfigScopeBuilder) Test(org.testng.annotations.Test)

Aggregations

ConfigScope (org.apache.helix.model.ConfigScope)6 ConfigScopeBuilder (org.apache.helix.model.builder.ConfigScopeBuilder)6 Test (org.testng.annotations.Test)4 ConfigAccessor (org.apache.helix.ConfigAccessor)3 Date (java.util.Date)2 HelixManager (org.apache.helix.HelixManager)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 HelixDataAccessor (org.apache.helix.HelixDataAccessor)1 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)1 ZKHelixAdmin (org.apache.helix.manager.zk.ZKHelixAdmin)1 ZKHelixManager (org.apache.helix.manager.zk.ZKHelixManager)1 DefaultMessagingService (org.apache.helix.messaging.DefaultMessagingService)1 InstanceConfig (org.apache.helix.model.InstanceConfig)1