Search in sources :

Example 41 with ConfigAccessor

use of org.apache.helix.ConfigAccessor in project helix by apache.

the class TestDisableResourceMbean method testDisableResourceMonitoring.

@Test
public void testDisableResourceMonitoring() throws Exception {
    final int NUM_PARTICIPANTS = 2;
    String clusterName = TestHelper.getTestClassName() + "_" + TestHelper.getTestMethodName();
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    // Set up cluster
    // participant port
    TestHelper.setupCluster(// participant port
    clusterName, // participant port
    ZK_ADDR, // participant port
    12918, // participant name prefix
    "localhost", // resource name prefix
    "TestDB", // resources
    3, // partitions per resource
    32, // number of nodes
    4, // replicas
    1, // use FULL_AUTO mode to test node tagging
    "MasterSlave", // use FULL_AUTO mode to test node tagging
    RebalanceMode.FULL_AUTO, // do rebalance
    true);
    MockParticipantManager[] participants = new MockParticipantManager[NUM_PARTICIPANTS];
    for (int i = 0; i < NUM_PARTICIPANTS; i++) {
        participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, "localhost_" + (12918 + i));
        participants[i].syncStart();
    }
    ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
    HelixConfigScope resourceScope = new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.RESOURCE).forCluster(clusterName).forResource("TestDB1").build();
    configAccessor.set(resourceScope, ResourceConfig.ResourceConfigProperty.MONITORING_DISABLED.name(), "true");
    resourceScope = new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.RESOURCE).forCluster(clusterName).forResource("TestDB2").build();
    configAccessor.set(resourceScope, ResourceConfig.ResourceConfigProperty.MONITORING_DISABLED.name(), "false");
    ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
    controller.syncStart();
    HelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(clusterName).setZkClient(_gZkClient).build();
    Assert.assertTrue(clusterVerifier.verify());
    // Verify the bean was created for TestDB0, but not for TestDB1.
    Assert.assertTrue(_mbeanServer.isRegistered(getMbeanName("TestDB0", clusterName)));
    Assert.assertFalse(_mbeanServer.isRegistered(getMbeanName("TestDB1", clusterName)));
    Assert.assertTrue(_mbeanServer.isRegistered(getMbeanName("TestDB2", clusterName)));
    controller.syncStop();
    for (MockParticipantManager participant : participants) {
        participant.syncStop();
    }
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) HelixConfigScopeBuilder(org.apache.helix.model.builder.HelixConfigScopeBuilder) HelixConfigScopeBuilder(org.apache.helix.model.builder.HelixConfigScopeBuilder) ConfigAccessor(org.apache.helix.ConfigAccessor) HelixConfigScope(org.apache.helix.model.HelixConfigScope) Date(java.util.Date) Test(org.testng.annotations.Test)

Aggregations

ConfigAccessor (org.apache.helix.ConfigAccessor)41 ClusterConfig (org.apache.helix.model.ClusterConfig)15 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)14 BeforeClass (org.testng.annotations.BeforeClass)14 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)10 ClusterSetup (org.apache.helix.tools.ClusterSetup)9 Date (java.util.Date)7 HelixConfigScope (org.apache.helix.model.HelixConfigScope)7 HelixConfigScopeBuilder (org.apache.helix.model.builder.HelixConfigScopeBuilder)7 Test (org.testng.annotations.Test)7 HelixException (org.apache.helix.HelixException)6 Path (javax.ws.rs.Path)5 BestPossibleExternalViewVerifier (org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier)4 HelixClusterVerifier (org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 GET (javax.ws.rs.GET)3 HelixManager (org.apache.helix.HelixManager)3 ZNRecord (org.apache.helix.ZNRecord)3 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)3