use of com.ning.metrics.meteo.publishers.ResourceListener in project meteo by pierre.
the class StreamResource method getSamplesByRoute.
/**
* Get the data points associated with a field in an Esper query.
* For this to work, you need to add ResourceListener as a publisher and configure it in a stream:
* {
* "name": "Jansky",
* "type": "com.ning.metrics.meteo.publishers.ResourceListener",
* "@class": "com.ning.metrics.meteo.publishers.ResourcePublisherConfig"
* }
*
* @param callback Javascript callback
* @param stream Stream name
* @param attribute the SQL alias of an Esper query
* @return jsonp representation of the data points in memory
*/
@GET
@Path("/{stream}/{attribute}")
@Produces(MediaType.APPLICATION_JSON)
public Response getSamplesByRoute(@QueryParam("callback") @DefaultValue("callback") final String callback, @PathParam("stream") final String stream, @PathParam("attribute") final String attribute) {
Cache<Object, Object> samplesCache = null;
final ResourceListener resourceListener = (ResourceListener) compiler.getPublisherInstances().get(stream);
if (resourceListener != null) {
final Map<String, Cache<Object, Object>> samples = resourceListener.getSamplesCache();
samplesCache = samples.get(attribute);
}
return buildJsonpResponse(attribute, samplesCache, callback);
}
Aggregations