use of org.restlet.representation.StringRepresentation in project helix by apache.
the class CurrentStatesResource method getInstanceCurrentStatesRepresentation.
StringRepresentation getInstanceCurrentStatesRepresentation(String clusterName, String instanceName) throws JsonGenerationException, JsonMappingException, IOException {
ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
;
String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);
String message = ClusterRepresentationUtil.getInstancePropertyNameListAsString(zkClient, clusterName, instanceName, PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON);
StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON);
return representation;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class ErrorsResource method getInstanceErrorsRepresentation.
StringRepresentation getInstanceErrorsRepresentation(String clusterName, String instanceName) throws JsonGenerationException, JsonMappingException, IOException {
ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
;
String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);
String message = ClusterRepresentationUtil.getInstancePropertyNameListAsString(zkClient, clusterName, instanceName, PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON);
StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON);
return representation;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class ExternalViewResource method get.
@Override
public Representation get() {
StringRepresentation presentation = null;
try {
String clusterName = ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
String resourceName = ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.RESOURCE_NAME);
presentation = getExternalViewRepresentation(clusterName, resourceName);
} catch (Exception e) {
String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
LOG.error("Exception in get externalView", e);
}
return presentation;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class ExternalViewResource method getExternalViewRepresentation.
StringRepresentation getExternalViewRepresentation(String clusterName, String resourceName) throws JsonGenerationException, JsonMappingException, IOException {
Builder keyBuilder = new PropertyKey.Builder(clusterName);
ZkClient zkclient = ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.RAW_ZKCLIENT);
String extViewStr = ResourceUtil.readZkAsBytes(zkclient, keyBuilder.externalView(resourceName));
StringRepresentation representation = new StringRepresentation(extViewStr, MediaType.APPLICATION_JSON);
return representation;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class IdealStateResource method get.
/**
* Get ideal state
* <p>
* Usage:
* <code>curl http://{host:port}/clusters/{clusterName}/resourceGroups/{resourceName}/idealState
*/
@Override
public Representation get() {
StringRepresentation presentation = null;
try {
String clusterName = ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
String resourceName = ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.RESOURCE_NAME);
presentation = getIdealStateRepresentation(clusterName, resourceName);
} catch (Exception e) {
String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
LOG.error("Exception in get idealState", e);
}
return presentation;
}
Aggregations