Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.perfmon; |
| 2 | |
| 3 | import org.restlet.data.Status; |
| 4 | import org.restlet.resource.Get; |
| 5 | import org.restlet.resource.ServerResource; |
| 6 | import org.slf4j.Logger; |
| 7 | import org.slf4j.LoggerFactory; |
| 8 | |
| 9 | |
| 10 | /** |
| 11 | * Return the performance monitoring data for the get rest api call |
| 12 | * @author subrata |
| 13 | */ |
| 14 | public 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 | } |