use of org.platformlayer.metrics.model.MetricDataStream in project platformlayer by platformlayer.
the class GetMetric method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
MetricDataStream dataStream = (MetricDataStream) o;
try {
MetricToJsonVisitor visitor = new MetricToJsonVisitor(writer);
dataStream.accept(visitor);
visitor.close();
} catch (IOException e) {
throw new IllegalArgumentException("Error formatting results", e);
}
}
use of org.platformlayer.metrics.model.MetricDataStream in project platformlayer by platformlayer.
the class GetMetric method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
PlatformLayerClient client = getPlatformLayerClient();
MetricQuery query = new MetricQuery();
query.item = getContext().pathToItem(getProject(), path);
if (filters != null) {
query.filters.addAll(filters);
}
if (projections != null) {
query.projections.addAll(projections);
}
query.setFlatten(flatten);
MetricDataStream dataStream = client.getMetric(query);
return dataStream;
}
use of org.platformlayer.metrics.model.MetricDataStream in project platformlayer by platformlayer.
the class HttpPlatformLayerClient method getMetric.
@Override
public MetricDataStream getMetric(MetricQuery query) throws PlatformLayerClientException {
String relativePath = buildRelativePath(query.item) + "/metrics";
StreamingResponse response = doRequest(HttpMethod.POST, relativePath, StreamingResponse.class, Format.JSON, query, Format.XML);
MetricDataStream dataStream;
try {
dataStream = JsonMetricDataStream.build(response.getResponseStream());
// Don't close yet
response = null;
} catch (IOException e) {
throw new PlatformLayerClientException("Error parsing returned data", e);
} finally {
Closeables.closeQuietly(response);
}
return dataStream;
}
Aggregations