blob: c43708d9e8a05c8583bc1da8079c705b5c1d726b [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.perfmon;
2
3import org.restlet.data.Status;
4import org.restlet.resource.Get;
5import org.restlet.resource.ServerResource;
6import org.slf4j.Logger;
7import org.slf4j.LoggerFactory;
8
9
10/**
11 * Return the performance monitoring data for the get rest api call
12 * @author subrata
13 */
14public class PerfMonDataResource extends ServerResource {
15 protected static Logger logger = LoggerFactory.getLogger(PerfMonDataResource.class);
16
17 @Get("json")
18 public CumulativeTimeBucket handleApiQuery() {
19 IPktInProcessingTimeService pktinProcTime =
20 (IPktInProcessingTimeService)getContext().getAttributes().
21 get(IPktInProcessingTimeService.class.getCanonicalName());
22
23 setStatus(Status.SUCCESS_OK, "OK");
24 // Allocate output object
25 if (pktinProcTime.isEnabled()) {
26 CumulativeTimeBucket ctb = pktinProcTime.getCtb();
27 ctb.computeAverages();
28 return ctb;
29 }
30
31 return null;
32 }
33}