use of org.restlet.representation.StringRepresentation in project pinot by linkedin.
the class PinotTenantRestletResource method delete.
@Override
@Delete
public Representation delete() {
StringRepresentation presentation;
try {
final String tenantName = (String) getRequest().getAttributes().get(TENANT_NAME);
final String type = getReference().getQueryAsForm().getValues("type");
presentation = deleteTenant(tenantName, type);
} catch (final Exception e) {
presentation = exceptionToStringRepresentation(e);
LOGGER.error("Caught exception while deleting tenant ", e);
ControllerRestApplication.getControllerMetrics().addMeteredGlobalValue(ControllerMeter.CONTROLLER_TABLE_TENANT_DELETE_ERROR, 1L);
setStatus(Status.SERVER_ERROR_INTERNAL);
}
return presentation;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class WorkflowsResource method get.
@Override
public Representation get() {
StringRepresentation presentation = null;
try {
String clusterName = (String) getRequest().getAttributes().get("clusterName");
presentation = getHostedEntitiesRepresentation(clusterName);
} 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 ZkPathResource method get.
@Override
public Representation get() {
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;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class ClusterResource method get.
/**
* List cluster information
* <p>
* Usage: <code> curl http://{host:port}/clusters/{clusterName}
*/
@Override
public Representation get() {
StringRepresentation presentation = null;
try {
String clusterName = ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
presentation = getClusterRepresentation(clusterName);
} catch (Exception e) {
String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
LOG.error("Exception in get cluster", e);
}
return presentation;
}
use of org.restlet.representation.StringRepresentation in project helix by apache.
the class ClustersResource method getClustersRepresentation.
StringRepresentation getClustersRepresentation() throws JsonGenerationException, JsonMappingException, IOException {
ZkClient zkClient = ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
ClusterSetup setupTool = new ClusterSetup(zkClient);
List<String> clusters = setupTool.getClusterManagementTool().getClusters();
ZNRecord clustersRecord = new ZNRecord("Clusters Summary");
clustersRecord.setListField("clusters", clusters);
StringRepresentation representation = new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(clustersRecord), MediaType.APPLICATION_JSON);
return representation;
}
Aggregations