JsonParameters jsonParameters = new JsonParameters(entity);
String command = jsonParameters.getCommand();
if (command == null)
{
throw new HelixException("Could NOT find 'command' in parameterMap: " + jsonParameters._parameterMap);
}
else if (command.equalsIgnoreCase(ClusterSetup.activateCluster)
|| JsonParameters.CLUSTERSETUP_COMMAND_ALIASES.get(ClusterSetup.activateCluster)
.contains(command))
{
jsonParameters.verifyCommand(ClusterSetup.activateCluster);
boolean enabled = true;
if (jsonParameters.getParameter(JsonParameters.ENABLED) != null)
{
enabled =
Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));
}
String grandCluster = jsonParameters.getParameter(JsonParameters.GRAND_CLUSTER);
setupTool.activateCluster(clusterName, grandCluster, enabled);
}
else if (command.equalsIgnoreCase(ClusterSetup.expandCluster))
{
setupTool.expandCluster(clusterName);
}
else
{
throw new HelixException("Unsupported command: " + command
+ ". Should be one of [" + ClusterSetup.activateCluster + ", "
+ ClusterSetup.expandCluster + "]");
}
getResponse().setEntity(getClusterRepresentation(clusterName));
getResponse().setStatus(Status.SUCCESS_OK);