// Also the ideal states and current states
String clusterName = cmd.getOptionValues(listResourceInfo)[0];
String resourceName = cmd.getOptionValues(listResourceInfo)[1];
IdealState idealState =
setupTool.getClusterManagementTool().getResourceIdealState(clusterName, resourceName);
ExternalView externalView =
setupTool.getClusterManagementTool().getResourceExternalView(clusterName, resourceName);
if (idealState != null) {
System.out.println("IdealState for " + resourceName + ":");
System.out.println(new String(new ZNRecordSerializer().serialize(idealState.getRecord())));
} else {
System.out.println("No idealState for " + resourceName);
}
System.out.println();
if (externalView != null) {
System.out.println("ExternalView for " + resourceName + ":");
System.out
.println(new String(new ZNRecordSerializer().serialize(externalView.getRecord())));
} else {
System.out.println("No externalView for " + resourceName);
}
return 0;
} else if (cmd.hasOption(listPartitionInfo)) {
// print out where the partition master / slaves locates
String clusterName = cmd.getOptionValues(listPartitionInfo)[0];
String resourceName = cmd.getOptionValues(listPartitionInfo)[1];
String partitionName = cmd.getOptionValues(listPartitionInfo)[2];
IdealState idealState =
setupTool.getClusterManagementTool().getResourceIdealState(clusterName, resourceName);
ExternalView externalView =
setupTool.getClusterManagementTool().getResourceExternalView(clusterName, resourceName);
if (idealState != null) {
ZNRecord partInfo = new ZNRecord(resourceName + "/" + partitionName);
ZNRecord idealStateRec = idealState.getRecord();
partInfo.setSimpleFields(idealStateRec.getSimpleFields());
if (idealStateRec.getMapField(partitionName) != null) {
partInfo.setMapField(partitionName, idealStateRec.getMapField(partitionName));
}
if (idealStateRec.getListField(partitionName) != null) {
partInfo.setListField(partitionName, idealStateRec.getListField(partitionName));
}
System.out.println("IdealState for " + resourceName + "/" + partitionName + ":");
System.out.println(new String(new ZNRecordSerializer().serialize(partInfo)));
} else {
System.out.println("No idealState for " + resourceName + "/" + partitionName);
}
System.out.println();
if (externalView != null) {
ZNRecord partInfo = new ZNRecord(resourceName + "/" + partitionName);
ZNRecord extViewRec = externalView.getRecord();
partInfo.setSimpleFields(extViewRec.getSimpleFields());
if (extViewRec.getMapField(partitionName) != null) {
partInfo.setMapField(partitionName, extViewRec.getMapField(partitionName));
}
if (extViewRec.getListField(partitionName) != null) {