{
Builder keyBuilder = new PropertyKey.Builder(clusterName);
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
ZNRecord record = null;
LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
if (leader != null)
{
record = leader.getRecord();
}
else
{
record = new ZNRecord("");
DateFormat formatter = new SimpleDateFormat("yyyyMMdd-HHmmss.SSSSSS");
String time = formatter.format(new Date());
Map<String, String> contentMap = new TreeMap<String, String>();
contentMap.put("AdditionalInfo", "No leader exists");
record.setMapField(Level.HELIX_INFO + "-" + time, contentMap);
}
boolean paused = (accessor.getProperty(keyBuilder.pause()) == null ? false : true);
record.setSimpleField(PropertyType.PAUSE.toString(), "" + paused);
String retVal = ClusterRepresentationUtil.ZNRecordToJson(record);
StringRepresentation representation =
new StringRepresentation(retVal, MediaType.APPLICATION_JSON);