blob: 9ea1876e7c2183db40becece8765d719b893f7b2 [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;
6
7public 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}