use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestPartitionMovementThrottle method testResourceThrottleWithDelayRebalancer.
@Test(dependsOnMethods = { "testResourceThrottle" })
public void testResourceThrottleWithDelayRebalancer() throws Exception {
// start a few participants
for (int i = 0; i < NODE_NR - 2; i++) {
_participants[i].syncStart();
}
int partition = 10;
int replica = 3;
int minActiveReplica = 2;
int delay = 100;
for (int i = 0; i < 5; i++) {
String dbName = "TestDB-" + i;
IdealState is = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, dbName);
if (is != null) {
System.err.println(dbName + "exists!");
is.setReplicas(String.valueOf(replica));
is.setMinActiveReplicas(minActiveReplica);
if (delay > 0) {
is.setRebalanceDelay(delay);
}
is.setRebalancerClassName(DelayedAutoRebalancer.class.getName());
_setupTool.getClusterManagementTool().setResourceIdealState(CLUSTER_NAME, dbName, is);
} else {
createResourceWithDelayedRebalance(CLUSTER_NAME, dbName, STATE_MODEL, partition, replica, minActiveReplica, delay);
}
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, dbName, _replica);
_dbs.add(dbName);
}
HelixClusterVerifier _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
Assert.assertTrue(_clusterVerifier.verify());
DelayedTransition.setDelay(20);
DelayedTransition.enableThrottleRecord();
// add 2 nodes
for (int i = NODE_NR - 2; i < NODE_NR; i++) {
_participants[i].syncStart();
}
Assert.assertTrue(_clusterVerifier.verify());
for (String db : _dbs) {
validateThrottle(DelayedTransition.getResourcePatitionTransitionTimes(), db, 2);
}
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.
the class TestClusterVerifier method testResourceSubset.
@Test
public void testResourceSubset() throws InterruptedException {
String testDB = "resource-testDB";
_setupTool.addResourceToCluster(_clusterName, testDB, 1, BuiltInStateModelDefinitions.MasterSlave.name(), RebalanceMode.SEMI_AUTO.toString());
IdealState idealState = _admin.getResourceIdealState(_clusterName, testDB);
idealState.setReplicas(Integer.toString(2));
idealState.getRecord().setListField(testDB + "_0", Arrays.asList(_participants[1].getInstanceName(), _participants[2].getInstanceName()));
_admin.setResourceIdealState(_clusterName, testDB, idealState);
// Ensure that this passes even when one resource is down
_admin.enableInstance(_clusterName, "localhost_12918", false);
Thread.sleep(1000);
_admin.enableCluster(_clusterName, false);
_admin.enableInstance(_clusterName, "localhost_12918", true);
HelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).setResources(Sets.newHashSet(testDB)).build();
Assert.assertTrue(verifier.verify());
verifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).setResources(Sets.newHashSet(testDB)).build();
Assert.assertTrue(verifier.verify());
// But the full cluster verification should fail
verifier = new BestPossibleExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
Assert.assertFalse(verifier.verify(3000));
verifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
Assert.assertFalse(verifier.verify(3000));
_admin.enableCluster(_clusterName, true);
}
use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier 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