}
@Override
public Representation represent(Variant variant)
{
StringRepresentation presentation = null;
String zkPath = getZKPath();
try
{
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
ZNRecord result = readZkDataStatAndChild(zkPath, zkClient);
presentation =
new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(result),
MediaType.APPLICATION_JSON);
}
catch (Exception e)
{
String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
LOG.error("Error in read zkPath: " + zkPath, e);
}
return presentation;