use of org.apache.helix.messaging.DefaultMessagingService in project helix by apache.
the class TestResourceThreadpoolSize method TestThreadPoolSizeConfig.
@Test
public void TestThreadPoolSizeConfig() {
setResourceThreadPoolSize("NextDB", 12);
_setupTool.addResourceToCluster(CLUSTER_NAME, "NextDB", 64, STATE_MODEL);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, "NextDB", 3);
boolean result = ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, CLUSTER_NAME));
Assert.assertTrue(result);
long taskcount = 0;
for (int i = 0; i < NODE_NR; i++) {
DefaultMessagingService svc = (DefaultMessagingService) (_participants[i].getMessagingService());
HelixTaskExecutor helixExecutor = svc.getExecutor();
ThreadPoolExecutor executor = (ThreadPoolExecutor) (helixExecutor._executorMap.get(MessageType.STATE_TRANSITION + "." + "NextDB"));
Assert.assertEquals(12, executor.getMaximumPoolSize());
taskcount += executor.getCompletedTaskCount();
Assert.assertTrue(executor.getCompletedTaskCount() > 0);
}
Assert.assertEquals(taskcount, 64 * 4);
}
use of org.apache.helix.messaging.DefaultMessagingService in project helix by apache.
the class TestResourceThreadpoolSize method TestPerStateTransitionTypeThreadPool.
@Test
public void TestPerStateTransitionTypeThreadPool() throws InterruptedException {
String MASTER_SLAVE = "MasterSlave";
int customizedPoolSize = 22;
for (MockParticipantManager participant : _participants) {
participant.getStateMachineEngine().registerStateModelFactory(MASTER_SLAVE, new TestMasterSlaveStateModelFactory(customizedPoolSize), TEST_FACTORY);
}
// add db with customized thread pool
IdealState idealState = new FullAutoModeISBuilder(WorkflowGenerator.DEFAULT_TGT_DB + "4").setStateModel(MASTER_SLAVE).setStateModelFactoryName(TEST_FACTORY).setNumPartitions(10).setNumReplica(1).build();
_setupTool.getClusterManagementTool().addResource(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "4", idealState);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "4", 1);
Thread.sleep(2000);
// Verify OFFLINE -> SLAVE and SLAVE -> MASTER have different threadpool size.
for (int i = 0; i < NODE_NR; i++) {
DefaultMessagingService svc = (DefaultMessagingService) (_participants[i].getMessagingService());
HelixTaskExecutor helixExecutor = svc.getExecutor();
ThreadPoolExecutor executorOfflineToSlave = (ThreadPoolExecutor) (helixExecutor._executorMap.get(MessageType.STATE_TRANSITION + "." + WorkflowGenerator.DEFAULT_TGT_DB + "4" + "." + OFFLINE_TO_SLAVE));
Assert.assertEquals(customizedPoolSize, executorOfflineToSlave.getMaximumPoolSize());
ThreadPoolExecutor executorSlaveToMaster = (ThreadPoolExecutor) (helixExecutor._executorMap.get(MessageType.STATE_TRANSITION + "." + WorkflowGenerator.DEFAULT_TGT_DB + "4" + "." + SLAVE_TO_MASTER));
Assert.assertEquals(customizedPoolSize + 5, executorSlaveToMaster.getMaximumPoolSize());
}
}
use of org.apache.helix.messaging.DefaultMessagingService in project helix by apache.
the class TestResourceThreadpoolSize method TestCustomizedResourceThreadPool.
@Test
public void TestCustomizedResourceThreadPool() {
int customizedPoolSize = 7;
int configuredPoolSize = 9;
for (MockParticipantManager participant : _participants) {
participant.getStateMachineEngine().registerStateModelFactory(ONLINE_OFFLINE, new TestOnlineOfflineStateModelFactory(customizedPoolSize, 0), TEST_FACTORY);
}
// add db with default thread pool
_setupTool.addResourceToCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "1", 64, STATE_MODEL);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "1", 3);
// add db with customized thread pool
IdealState idealState = new FullAutoModeISBuilder(WorkflowGenerator.DEFAULT_TGT_DB + "2").setStateModel(ONLINE_OFFLINE).setStateModelFactoryName(TEST_FACTORY).setNumPartitions(10).setNumReplica(1).build();
_setupTool.getClusterManagementTool().addResource(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "2", idealState);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "2", 1);
// add db with configured pool size
idealState = new FullAutoModeISBuilder(WorkflowGenerator.DEFAULT_TGT_DB + "3").setStateModel(ONLINE_OFFLINE).setStateModelFactoryName(TEST_FACTORY).setNumPartitions(10).setNumReplica(1).build();
_setupTool.getClusterManagementTool().addResource(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "3", idealState);
setResourceThreadPoolSize(WorkflowGenerator.DEFAULT_TGT_DB + "3", configuredPoolSize);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "3", 1);
boolean result = ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, CLUSTER_NAME));
Assert.assertTrue(result);
for (int i = 0; i < NODE_NR; i++) {
DefaultMessagingService svc = (DefaultMessagingService) (_participants[i].getMessagingService());
HelixTaskExecutor helixExecutor = svc.getExecutor();
ThreadPoolExecutor executor = (ThreadPoolExecutor) (helixExecutor._executorMap.get(MessageType.STATE_TRANSITION + "." + WorkflowGenerator.DEFAULT_TGT_DB + "1"));
Assert.assertNull(executor);
executor = (ThreadPoolExecutor) (helixExecutor._executorMap.get(MessageType.STATE_TRANSITION + "." + WorkflowGenerator.DEFAULT_TGT_DB + "2"));
Assert.assertEquals(customizedPoolSize, executor.getMaximumPoolSize());
executor = (ThreadPoolExecutor) (helixExecutor._executorMap.get(MessageType.STATE_TRANSITION + "." + WorkflowGenerator.DEFAULT_TGT_DB + "3"));
Assert.assertEquals(configuredPoolSize, executor.getMaximumPoolSize());
}
}
use of org.apache.helix.messaging.DefaultMessagingService in project helix by apache.
the class TestBatchMessageModeConfigs method verify.
private void verify() {
DefaultMessagingService svc = (DefaultMessagingService) (_participants[0].getMessagingService());
HelixTaskExecutor helixExecutor = svc.getExecutor();
ThreadPoolExecutor executor = (ThreadPoolExecutor) (helixExecutor._batchMessageExecutorService);
Assert.assertNotNull(executor);
Assert.assertTrue(executor.getPoolSize() > 0);
}
use of org.apache.helix.messaging.DefaultMessagingService 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