diff --git a/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologyClusterResource.java b/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologyClusterResource.java index 282d44ef13d7321610a7d3abd80d74198d0e6bc0..5531e68e7eb6d92a0f694794e75a8dd945459798 100644 --- a/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologyClusterResource.java +++ b/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologyClusterResource.java @@ -1,5 +1,6 @@ package net.floodlightcontroller.core.web; +import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService; import net.floodlightcontroller.linkdiscovery.internal.EventHistoryTopologyCluster; import net.floodlightcontroller.linkdiscovery.internal.LinkDiscoveryManager; import net.floodlightcontroller.util.EventHistory; @@ -27,7 +28,8 @@ public class EventHistoryTopologyClusterResource extends ServerResource { } LinkDiscoveryManager topoManager = - (LinkDiscoveryManager)getContext().getAttributes().get("topology"); + (LinkDiscoveryManager)getContext().getAttributes(). + get(ILinkDiscoveryService.class.getCanonicalName()); return new EventHistory<EventHistoryTopologyCluster>( topoManager.evHistTopologyCluster, count); diff --git a/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologyLinkResource.java b/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologyLinkResource.java index 5e8949277de8bf031244410fb06f7fddb7c59f6f..99ce49429c1456c1278d01a7504a1112bdef2d72 100644 --- a/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologyLinkResource.java +++ b/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologyLinkResource.java @@ -1,5 +1,6 @@ package net.floodlightcontroller.core.web; +import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService; import net.floodlightcontroller.linkdiscovery.internal.EventHistoryTopologyLink; import net.floodlightcontroller.linkdiscovery.internal.LinkDiscoveryManager; import net.floodlightcontroller.util.EventHistory; @@ -27,7 +28,8 @@ public class EventHistoryTopologyLinkResource extends ServerResource { } LinkDiscoveryManager topoManager = - (LinkDiscoveryManager)getContext().getAttributes().get("topology"); + (LinkDiscoveryManager)getContext().getAttributes(). + get(ILinkDiscoveryService.class.getCanonicalName()); return new EventHistory<EventHistoryTopologyLink>( topoManager.evHistTopologyLink, count); diff --git a/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologySwitchResource.java b/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologySwitchResource.java index 683b63fff05332d6a938bb1652596a72b76e10eb..1c95e2c6bbdb414fdea4fd34e9d027081d9f5c2f 100644 --- a/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologySwitchResource.java +++ b/src/main/java/net/floodlightcontroller/core/web/EventHistoryTopologySwitchResource.java @@ -1,5 +1,6 @@ package net.floodlightcontroller.core.web; +import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService; import net.floodlightcontroller.linkdiscovery.internal.EventHistoryTopologySwitch; import net.floodlightcontroller.linkdiscovery.internal.LinkDiscoveryManager; import net.floodlightcontroller.util.EventHistory; @@ -27,7 +28,8 @@ public class EventHistoryTopologySwitchResource extends ServerResource { } LinkDiscoveryManager topoManager = - (LinkDiscoveryManager)getContext().getAttributes().get("topology"); + (LinkDiscoveryManager)getContext().getAttributes(). + get(ILinkDiscoveryService.class.getCanonicalName()); return new EventHistory<EventHistoryTopologySwitch>( topoManager.evHistTopologySwitch, count); diff --git a/src/main/java/net/floodlightcontroller/util/EventHistory.java b/src/main/java/net/floodlightcontroller/util/EventHistory.java index d83630d4cfdbfdbb2439724679394af9ff7014b6..69031ba9effe1121d3303373af94fd829a2c26ed 100644 --- a/src/main/java/net/floodlightcontroller/util/EventHistory.java +++ b/src/main/java/net/floodlightcontroller/util/EventHistory.java @@ -90,6 +90,11 @@ public class EventHistory<T> { // Copy constructor - copy latest k items of the event history public EventHistory(EventHistory<T> eventHist, int latestK) { + + if (eventHist == null) { + description = "No event found"; + return; + } int curSize = (eventHist.full)?eventHist.event_history_size: eventHist.current_index; int size = (latestK < curSize)?latestK:curSize;