public void verifyCommand(String command) {
// verify command itself
if (_parameterMap.isEmpty()) {
throw new HelixException("'" + JSON_PARAMETERS + "' in the POST body is empty");
}
if (!_parameterMap.containsKey(MANAGEMENT_COMMAND)) {
throw new HelixException("Missing management paramater '" + MANAGEMENT_COMMAND + "'");
}
if (!_parameterMap.get(MANAGEMENT_COMMAND).equalsIgnoreCase(command)
&& !(CLUSTERSETUP_COMMAND_ALIASES.get(command) != null && CLUSTERSETUP_COMMAND_ALIASES.get(
command).contains(_parameterMap.get(MANAGEMENT_COMMAND)))) {
throw new HelixException(MANAGEMENT_COMMAND + " must be '" + command + "'");
}
// verify command parameters
if (command.equalsIgnoreCase(ClusterSetup.enableInstance)) {
if (!_parameterMap.containsKey(ENABLED)) {
throw new HelixException("Missing Json parameters: '" + ENABLED + "'");
}
} else if (command.equalsIgnoreCase(ClusterSetup.enablePartition)) {
if (!_parameterMap.containsKey(ENABLED)) {
throw new HelixException("Missing Json parameters: '" + ENABLED + "'");
}
if (!_parameterMap.containsKey(PARTITION)) {
throw new HelixException("Missing Json parameters: '" + PARTITION + "'");
}
if (!_parameterMap.containsKey(RESOURCE)) {
throw new HelixException("Missing Json parameters: '" + RESOURCE + "'");
}
} else if (command.equalsIgnoreCase(ClusterSetup.resetPartition)) {
if (!_parameterMap.containsKey(PARTITION)) {
throw new HelixException("Missing Json parameters: '" + PARTITION + "'");
}
if (!_parameterMap.containsKey(RESOURCE)) {
throw new HelixException("Missing Json parameters: '" + RESOURCE + "'");
}
} else if (command.equalsIgnoreCase(ClusterSetup.resetInstance)) {
// nothing
} else if (command.equalsIgnoreCase(ClusterSetup.activateCluster)) {
if (!_parameterMap.containsKey(GRAND_CLUSTER)) {
throw new HelixException("Missing Json parameters: '" + GRAND_CLUSTER + "'");
}
} else if (command.equalsIgnoreCase(ClusterSetup.setConfig)) {
if (!_parameterMap.containsKey(CONFIGS)) {
throw new HelixException("Missing Json parameters: '" + CONFIGS + "'");
}
} else if (command.equalsIgnoreCase(ClusterSetup.removeConfig)) {
if (!_parameterMap.containsKey(CONFIGS)) {
throw new HelixException("Missing Json parameters: '" + CONFIGS + "'");
}
} else if (command.equalsIgnoreCase(ClusterSetup.addInstanceTag)) {
if (!_parameterMap.containsKey(ClusterSetup.instanceGroupTag)) {
throw new HelixException("Missing Json parameters: '" + ClusterSetup.instanceGroupTag + "'");
}
} else if (command.equalsIgnoreCase(ClusterSetup.removeInstanceTag)) {
if (!_parameterMap.containsKey(ClusterSetup.instanceGroupTag)) {
throw new HelixException("Missing Json parameters: '" + ClusterSetup.instanceGroupTag + "'");
}
} else if (command.equalsIgnoreCase(ClusterSetup.addCluster)) {
if (!_parameterMap.containsKey(CLUSTER_NAME)) {
throw new HelixException("Missing Json parameters: '" + CLUSTER_NAME + "'");
}
} else if (command.equalsIgnoreCase(ClusterSetup.addResource)) {
if (!_parameterMap.containsKey(RESOURCE_GROUP_NAME)) {
throw new HelixException("Missing Json paramaters: '" + RESOURCE_GROUP_NAME + "'");
}
if (!_parameterMap.containsKey(PARTITIONS)) {
throw new HelixException("Missing Json paramaters: '" + PARTITIONS + "'");
}
if (!_parameterMap.containsKey(STATE_MODEL_DEF_REF)) {
throw new HelixException("Missing Json paramaters: '" + STATE_MODEL_DEF_REF + "'");
}
}
}