addInstancesToCluster(controllerClusterName, "controller_900", 2, null);
// start mock nodes
for (int i = 0; i < 6; i++) {
String instanceName = "localhost_123" + i;
MockParticipant participant =
new MockParticipant(_zkaddr, clusterName, instanceName);
participant.syncStart();
participants.put(instanceName, participant);
}
// start controller nodes
for (int i = 0; i < 2; i++) {
String controllerName = "controller_900" + i;
MockMultiClusterController multiClusterController =
new MockMultiClusterController(_zkaddr, controllerClusterName, controllerName);
multiClusterController.syncStart();
multiClusterControllers.put(controllerName, multiClusterController);
}
String clusterUrl = getClusterUrl(clusterName);
// activate cluster
assertSuccessPostOperation(clusterUrl, activateClusterCmd(controllerClusterName, true), false);
boolean verifyResult =
ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
controllerClusterName));
Assert.assertTrue(verifyResult);
verifyResult =
ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(verifyResult);
// deactivate cluster
assertSuccessPostOperation(clusterUrl, activateClusterCmd(controllerClusterName, false), false);
Thread.sleep(6000);
Assert.assertFalse(_zkclient.exists("/" + controllerClusterName + "/IDEALSTATES/"
+ clusterName));
HelixDataAccessor accessor = participants.get("localhost_1231").getHelixDataAccessor();
String path = accessor.keyBuilder().controllerLeader().getPath();
Assert.assertFalse(_zkclient.exists(path));
deleteUrl(clusterUrl, true);
Assert.assertTrue(_zkclient.exists("/" + clusterName));
// leader node should be gone
for (MockParticipant participant : participants.values()) {
participant.syncStop();
}
deleteUrl(clusterUrl, false);
Assert.assertFalse(_zkclient.exists("/" + clusterName));
// clean up
for (MockMultiClusterController controller : multiClusterControllers.values()) {
controller.syncStop();
}
for (MockParticipant participant : participants.values()) {
participant.syncStop();
}
}