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 | |
| 7 | public class PerfMonToggleResource extends ServerResource { |
| 8 | |
| 9 | @Get("json") |
| 10 | public String retrieve() { |
| 11 | IPktInProcessingTimeService pktinProcTime = |
| 12 | (IPktInProcessingTimeService)getContext().getAttributes(). |
| 13 | get(IPktInProcessingTimeService.class.getCanonicalName()); |
| 14 | |
| 15 | String param = ((String)getRequestAttributes().get("perfmonstate")).toLowerCase(); |
| 16 | if (param.equals("reset")) { |
| 17 | pktinProcTime.getCtb().reset(); |
| 18 | } else { |
| 19 | if (param.equals("enable") || param.equals("true")) { |
| 20 | pktinProcTime.setEnabled(true); |
| 21 | } else if (param.equals("disable") || param.equals("false")) { |
| 22 | pktinProcTime.setEnabled(false); |
| 23 | } |
| 24 | } |
| 25 | setStatus(Status.SUCCESS_OK, "OK"); |
| 26 | return "{ \"enabled\" : " + pktinProcTime.isEnabled() + " }"; |
| 27 | } |
| 28 | } |