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()));
}
Aggregations