boolean enabled = Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
ClusterSetup setupTool = new ClusterSetup(zkClient);
setupTool.getClusterManagementTool().enableInstance(clusterName, instanceName, enabled);
} else if (command.equalsIgnoreCase(ClusterSetup.enablePartition)) {
jsonParameters.verifyCommand(ClusterSetup.enablePartition);
boolean enabled = Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));
String[] partitions = jsonParameters.getParameter(JsonParameters.PARTITION).split(";");
String resource = jsonParameters.getParameter(JsonParameters.RESOURCE);
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
ClusterSetup setupTool = new ClusterSetup(zkClient);
setupTool.getClusterManagementTool().enablePartition(enabled, clusterName, instanceName,
resource, Arrays.asList(partitions));
} else if (command.equalsIgnoreCase(ClusterSetup.resetPartition)) {
jsonParameters.verifyCommand(ClusterSetup.resetPartition);
String resource = jsonParameters.getParameter(JsonParameters.RESOURCE);
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
ClusterSetup setupTool = new ClusterSetup(zkClient);
String[] partitionNames =
jsonParameters.getParameter(JsonParameters.PARTITION).split("\\s+");
setupTool.getClusterManagementTool().resetPartition(clusterName, instanceName, resource,
Arrays.asList(partitionNames));
} else if (command.equalsIgnoreCase(ClusterSetup.resetInstance)) {
jsonParameters.verifyCommand(ClusterSetup.resetInstance);
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
ClusterSetup setupTool = new ClusterSetup(zkClient);
setupTool.getClusterManagementTool()
.resetInstance(clusterName, Arrays.asList(instanceName));
} else if (command.equalsIgnoreCase(ClusterSetup.addInstanceTag)) {
jsonParameters.verifyCommand(ClusterSetup.addInstanceTag);
String tag = jsonParameters.getParameter(ClusterSetup.instanceGroupTag);
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
ClusterSetup setupTool = new ClusterSetup(zkClient);
setupTool.getClusterManagementTool().addInstanceTag(clusterName, instanceName, tag);
} else if (command.equalsIgnoreCase(ClusterSetup.removeInstanceTag)) {
jsonParameters.verifyCommand(ClusterSetup.removeInstanceTag);
String tag = jsonParameters.getParameter(ClusterSetup.instanceGroupTag);
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
ClusterSetup setupTool = new ClusterSetup(zkClient);
setupTool.getClusterManagementTool().removeInstanceTag(clusterName, instanceName, tag);
} else {
throw new HelixException("Unsupported command: " + command + ". Should be one of ["
+ ClusterSetup.enableInstance + ", " + ClusterSetup.enablePartition + ", "
+ ClusterSetup.resetInstance + "]");
}