use of org.apache.helix.messaging.DefaultMessagingService in project helix by apache.
the class TestResourceThreadpoolSize method testBatchMessageThreadPoolSize.
@Test
public void testBatchMessageThreadPoolSize() throws InterruptedException {
int customizedPoolSize = 5;
_participants[0].getStateMachineEngine().registerStateModelFactory("OnlineOffline", new TestOnlineOfflineStateModelFactory(customizedPoolSize, 2000), "TestFactory");
for (int i = 1; i < _participants.length; i++) {
_participants[i].syncStop();
}
Thread.sleep(2000L);
// Add 10 dbs with batch message enabled. Each db has 10 partitions.
// So it will have 10 batch messages and each batch message has 10 sub messages.
int numberOfDbs = 10;
for (int i = 0; i < numberOfDbs; i++) {
String dbName = "TestDBABatch" + i;
IdealState idealState = new FullAutoModeISBuilder(dbName).setStateModel("OnlineOffline").setStateModelFactoryName("TestFactory").setNumPartitions(10).setNumReplica(1).build();
idealState.setBatchMessageMode(true);
_setupTool.getClusterManagementTool().addResource(CLUSTER_NAME, dbName, idealState);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, dbName, 1);
}
Thread.sleep(2000L);
DefaultMessagingService svc = (DefaultMessagingService) (_participants[0].getMessagingService());
HelixTaskExecutor helixExecutor = svc.getExecutor();
ThreadPoolExecutor executor = (ThreadPoolExecutor) (helixExecutor._batchMessageExecutorService);
Assert.assertNotNull(executor);
Assert.assertTrue(executor.getPoolSize() >= numberOfDbs);
BestPossibleExternalViewVerifier verifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(verifier.verify());
}
Aggregations