Search in sources :

Example 6 with DefaultMessagingService

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());
}
Also used : DefaultMessagingService(org.apache.helix.messaging.DefaultMessagingService) HelixConfigScopeBuilder(org.apache.helix.model.builder.HelixConfigScopeBuilder) FullAutoModeISBuilder(org.apache.helix.model.builder.FullAutoModeISBuilder) FullAutoModeISBuilder(org.apache.helix.model.builder.FullAutoModeISBuilder) BestPossibleExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) IdealState(org.apache.helix.model.IdealState) Test(org.testng.annotations.Test)

Aggregations

ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)6 DefaultMessagingService (org.apache.helix.messaging.DefaultMessagingService)6 Test (org.testng.annotations.Test)5 IdealState (org.apache.helix.model.IdealState)3 FullAutoModeISBuilder (org.apache.helix.model.builder.FullAutoModeISBuilder)3 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)2 ClusterStateVerifier (org.apache.helix.tools.ClusterStateVerifier)2 ConfigAccessor (org.apache.helix.ConfigAccessor)1 HelixManager (org.apache.helix.HelixManager)1 ConfigScope (org.apache.helix.model.ConfigScope)1 ConfigScopeBuilder (org.apache.helix.model.builder.ConfigScopeBuilder)1 HelixConfigScopeBuilder (org.apache.helix.model.builder.HelixConfigScopeBuilder)1 BestPossibleExternalViewVerifier (org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier)1