Assert.assertEquals(ev.getStateMap("db_11_15").get(hostName), "SLAVE");
}
private void testInstanceOperations() throws Exception
{
HelixDataAccessor accessor;
// drop node should fail as not disabled
String instanceUrl = getInstanceUrl("clusterTest1", "localhost_1232");
deleteUrl(instanceUrl, true);
// disabled node
Map<String, String> paraMap = new HashMap<String, String>();
paraMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.enableInstance);
paraMap.put(JsonParameters.ENABLED, "false");
String response = assertSuccessPostOperation(instanceUrl, paraMap, false);
Assert.assertTrue(response.contains("false"));
// Cannot drop / swap
deleteUrl(instanceUrl, true);
String instancesUrl = getClusterUrl("clusterTest1") + "/instances";
paraMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.swapInstance);
paraMap.put(JsonParameters.OLD_INSTANCE, "localhost_1232");
paraMap.put(JsonParameters.NEW_INSTANCE, "localhost_12320");
response = assertSuccessPostOperation(instancesUrl, paraMap, true);
// disconnect the node
_startCMResultMap.get("localhost_1232")._manager.disconnect();
_startCMResultMap.get("localhost_1232")._thread.interrupt();
// add new node then swap instance
paraMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.addInstance);
paraMap.put(JsonParameters.INSTANCE_NAME, "localhost_12320");
response = assertSuccessPostOperation(instancesUrl, paraMap, false);
Assert.assertTrue(response.contains("localhost_12320"));
// swap instance. The instance get swapped out should not exist anymore
paraMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.swapInstance);
paraMap.put(JsonParameters.OLD_INSTANCE, "localhost_1232");
paraMap.put(JsonParameters.NEW_INSTANCE, "localhost_12320");
response = assertSuccessPostOperation(instancesUrl, paraMap, false);
Assert.assertTrue(response.contains("localhost_12320"));
Assert.assertFalse(response.contains("localhost_1232\""));
accessor = _startCMResultMap.get("localhost_1231")._manager.getHelixDataAccessor();
String path = accessor.keyBuilder().instanceConfig("localhost_1232").getPath();
Assert.assertFalse(_gZkClient.exists(path));
_startCMResultMap.put("localhost_12320",
TestHelper.startDummyProcess(ZK_ADDR,
"clusterTest1",