blob: 297c44efadd41c89f11966630dea644e97e632e1 [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 {
Yuta HIGUCHI6ac8d182013-10-22 15:24:56 -070015 protected final static Logger logger = LoggerFactory.getLogger(PerfMonDataResource.class);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080016
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}