Search in sources :

Example 36 with StringRepresentation

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;
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) HelixException(org.apache.helix.HelixException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException)

Example 37 with StringRepresentation

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;
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) StringRepresentation(org.restlet.representation.StringRepresentation) Builder(org.apache.helix.PropertyKey.Builder)

Example 38 with StringRepresentation

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;
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException)

Example 39 with StringRepresentation

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;
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException)

Example 40 with StringRepresentation

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;
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException)

Aggregations

StringRepresentation (org.restlet.representation.StringRepresentation)130 HttpVerb (com.linkedin.pinot.common.restlet.swagger.HttpVerb)30 Paths (com.linkedin.pinot.common.restlet.swagger.Paths)30 Summary (com.linkedin.pinot.common.restlet.swagger.Summary)30 IOException (java.io.IOException)30 Tags (com.linkedin.pinot.common.restlet.swagger.Tags)29 ZkClient (org.apache.helix.manager.zk.ZkClient)29 JSONObject (org.json.JSONObject)23 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)19 ZNRecord (org.apache.helix.ZNRecord)17 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)17 JSONException (org.json.JSONException)17 Representation (org.restlet.representation.Representation)15 Responses (com.linkedin.pinot.common.restlet.swagger.Responses)14 HelixException (org.apache.helix.HelixException)12 JSONArray (org.json.JSONArray)12 Builder (org.apache.helix.PropertyKey.Builder)11 Get (org.restlet.resource.Get)10 Post (org.restlet.resource.Post)9 ResourceException (org.restlet.resource.ResourceException)9