use of org.restlet.representation.StringRepresentation in project helix by apache.
the class StateModelResource method get.
@Override
public Representation get() {
StringRepresentation presentation = null;
try {
String clusterName = (String) getRequest().getAttributes().get("clusterName");
String modelName = (String) getRequest().getAttributes().get("modelName");
presentation = getStateModelRepresentation(clusterName, modelName);
} catch (Exception e) {
String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
LOG.error("", e);
}
return presentation;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class StatusUpdateResource method getInstanceStatusUpdateRepresentation.
StringRepresentation getInstanceStatusUpdateRepresentation(String clusterName, String instanceName, String resourceGroup) throws JsonGenerationException, JsonMappingException, IOException {
ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);
Builder keyBuilder = new PropertyKey.Builder(clusterName);
String message = ClusterRepresentationUtil.getInstancePropertiesAsString(zkClient, clusterName, keyBuilder.stateTransitionStatus(instanceName, instanceSessionId, resourceGroup), // + resourceGroup,
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 StatusUpdateResource method get.
@Override
public Representation get() {
StringRepresentation presentation = null;
try {
String clusterName = (String) getRequest().getAttributes().get("clusterName");
String instanceName = (String) getRequest().getAttributes().get("instanceName");
String resourceGroup = (String) getRequest().getAttributes().get("resourceName");
presentation = getInstanceStatusUpdateRepresentation(clusterName, instanceName, resourceGroup);
} catch (Exception e) {
String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
LOG.error("", e);
}
return presentation;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class ControllerStatusUpdateResource method get.
@Override
public Representation get() {
StringRepresentation presentation = null;
try {
String zkServer = (String) getContext().getAttributes().get(RestAdminApplication.ZKSERVERADDRESS);
String clusterName = (String) getRequest().getAttributes().get("clusterName");
String messageType = (String) getRequest().getAttributes().get("MessageType");
String messageId = (String) getRequest().getAttributes().get("MessageId");
// TODO: need pass sessionId to this represent()
String sessionId = (String) getRequest().getAttributes().get("SessionId");
presentation = getControllerStatusUpdateRepresentation(zkServer, clusterName, sessionId, messageType, messageId);
} catch (Exception e) {
String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
LOG.error("", e);
}
return presentation;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class CurrentStatesResource method get.
public Representation get() {
StringRepresentation presentation = null;
try {
String clusterName = (String) getRequest().getAttributes().get("clusterName");
String instanceName = (String) getRequest().getAttributes().get("instanceName");
presentation = getInstanceCurrentStatesRepresentation(clusterName, instanceName);
} catch (Exception e) {
String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
LOG.error("", e);
}
return presentation;
}
Aggregations