(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
ClusterSetup setupTool = new ClusterSetup(zkClient);
List<String> instances =
setupTool.getClusterManagementTool().getInstancesInCluster(clusterName);
ZNRecord clusterSummayRecord = new ZNRecord("Cluster Summary");
clusterSummayRecord.setListField("participants", instances);
List<String> resources =
setupTool.getClusterManagementTool().getResourcesInCluster(clusterName);
clusterSummayRecord.setListField("resources", resources);
List<String> models =
setupTool.getClusterManagementTool().getStateModelDefs(clusterName);
clusterSummayRecord.setListField("stateModelDefs", models);
HelixDataAccessor accessor =
ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
Builder keyBuilder = accessor.keyBuilder();
LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
if (leader != null)
{
clusterSummayRecord.setSimpleField("LEADER", leader.getInstanceName());
}
else
{
clusterSummayRecord.setSimpleField("LEADER", "");
}
StringRepresentation representation =
new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(clusterSummayRecord),
MediaType.APPLICATION_JSON);