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
{
throw new HelixException("Unsupported command: " + command