blob: 4a81db4a5a8dbef26556f1cc63a95ec3ed9323e9 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.core.web;
2
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08003import net.floodlightcontroller.util.EventHistory;
HIGUCHI Yutaa56fbde2013-06-17 14:26:05 -07004import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService;
5import net.onrc.onos.ofcontroller.linkdiscovery.internal.EventHistoryTopologySwitch;
6import net.onrc.onos.ofcontroller.linkdiscovery.internal.LinkDiscoveryManager;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08007
8import org.restlet.resource.Get;
9import org.restlet.resource.ServerResource;
10
11/**
12 * @author subrata
13 *
14 */
15public class EventHistoryTopologySwitchResource extends ServerResource {
16
17 @Get("json")
18 public EventHistory<EventHistoryTopologySwitch> handleEvHistReq() {
19
20 // Get the event history count. Last <count> events would be returned
21 String evHistCount = (String)getRequestAttributes().get("count");
22 int count = EventHistory.EV_HISTORY_DEFAULT_SIZE;
23 try {
24 count = Integer.parseInt(evHistCount);
25 }
26 catch(NumberFormatException nFE) {
27 // Invalid input for event count - use default value
28 }
29
30 LinkDiscoveryManager topoManager =
31 (LinkDiscoveryManager)getContext().getAttributes().
32 get(ILinkDiscoveryService.class.getCanonicalName());
33
34 return new EventHistory<EventHistoryTopologySwitch>(
35 topoManager.evHistTopologySwitch, count);
36 }
37}