Skip to content
Snippets Groups Projects
Commit 2cc9107c authored by abat's avatar abat
Browse files

Merge into master from pull request #43:

Extra checks to event history in REST API. (https://github.com/floodlight/floodlight/pull/43)
parents a0250d80 f99efa12
No related branches found
No related tags found
No related merge requests found
......@@ -42,15 +42,32 @@ public class FloodlightModuleContext implements IFloodlightModuleContext {
IFloodlightService s = serviceMap.get(service);
return (T)s;
}
/**
* Gets all the loaded services
* @return The colleciton of loaded services
*/
@Override
public Collection<Class<? extends IFloodlightService>> getAllServices() {
return serviceMap.keySet();
}
/**
* Gets the configuration parameter map for a module
* @param module The module to get the configuration map for, usually yourself
* @return A map containing all the configuration parameters for the module, may be empty
*/
@Override
public Map<String, String> getConfigParams(IFloodlightModule module) {
return configParams.get(module.getClass());
Map<String, String> retMap = configParams.get(module.getClass());
if (retMap == null) {
// Return an empty map if none exists so the module does not
// need to null check the map
retMap = new HashMap<String, String>();
configParams.put(module.getClass(), retMap);
}
return retMap;
}
/**
......
......@@ -10,12 +10,17 @@ import net.floodlightcontroller.util.EventHistory;
import org.restlet.resource.ServerResource;
import org.restlet.resource.Get;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author subrata
*
*/
public class EventHistoryAttachmentPointResource extends ServerResource {
// TODO - Move this to the DeviceManager Rest API
protected static Logger log =
LoggerFactory.getLogger(EventHistoryAttachmentPointResource.class);
/***
* Event History Names:
* (a) attachment-point
......@@ -42,11 +47,18 @@ public class EventHistoryAttachmentPointResource extends ServerResource {
// Invalid input for event count - use default value
}
DeviceManagerImpl deviceManager =
(DeviceManagerImpl)getContext().getAttributes().
get(IDeviceManagerService.class.getCanonicalName());
try {
DeviceManagerImpl deviceManager =
(DeviceManagerImpl)getContext().getAttributes().
get(IDeviceManagerService.class.getCanonicalName());
if (deviceManager != null) {
return new EventHistory<EventHistoryAttachmentPoint>(
deviceManager.evHistDevMgrAttachPt, count);
}
} catch (ClassCastException e) {
log.error(e.toString());
}
return new EventHistory<EventHistoryAttachmentPoint>(
deviceManager.evHistDevMgrAttachPt, count);
return null;
}
}
......@@ -10,17 +10,20 @@ import net.floodlightcontroller.util.EventHistory;
import org.openflow.protocol.OFMatch;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author subrata
*
*/
public class EventHistoryPacketInResource extends ServerResource {
// TODO - Move this to the DeviceManager rest API
protected static Logger log =
LoggerFactory.getLogger(EventHistoryPacketInResource.class);
@Get("json")
public EventHistory<OFMatch> handleEvHistReq() {
EventHistory<OFMatch> ofm = null;
// Get the count (number of latest events requested), zero means all
String evHistCount = (String)getRequestAttributes().get("count");
int count = EventHistory.EV_HISTORY_DEFAULT_SIZE;
......@@ -31,12 +34,19 @@ public class EventHistoryPacketInResource extends ServerResource {
// Invalid input for event count - use default value
}
DeviceManagerImpl deviceManager =
(DeviceManagerImpl)getContext().getAttributes().
get(IDeviceManagerService.class.getCanonicalName());
ofm = new EventHistory<OFMatch>(deviceManager.evHistDevMgrPktIn,count);
return ofm;
try {
DeviceManagerImpl deviceManager =
(DeviceManagerImpl)getContext().getAttributes().
get(IDeviceManagerService.class.getCanonicalName());
if (deviceManager != null) {
return new EventHistory<OFMatch>(deviceManager.evHistDevMgrPktIn,count);
}
} catch (ClassCastException e) {
log.error(e.toString());
}
return null;
}
}
......@@ -7,12 +7,17 @@ import net.floodlightcontroller.util.EventHistory;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author subrata
*
*/
public class EventHistoryTopologyClusterResource extends ServerResource {
// TODO - Move this to the LinkDiscovery rest API
protected static Logger log =
LoggerFactory.getLogger(EventHistoryTopologyClusterResource.class);
@Get("json")
public EventHistory<EventHistoryTopologyCluster> handleEvHistReq() {
......@@ -27,11 +32,18 @@ public class EventHistoryTopologyClusterResource extends ServerResource {
// Invalid input for event count - use default value
}
LinkDiscoveryManager topoManager =
(LinkDiscoveryManager)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
return new EventHistory<EventHistoryTopologyCluster>(
topoManager.evHistTopologyCluster, count);
try {
LinkDiscoveryManager topoManager =
(LinkDiscoveryManager)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
if (topoManager != null) {
return new EventHistory<EventHistoryTopologyCluster>(
topoManager.evHistTopologyCluster, count);
}
} catch (ClassCastException e) {
log.error(e.toString());
}
return null;
}
}
......@@ -7,12 +7,17 @@ import net.floodlightcontroller.util.EventHistory;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author subrata
*
*/
public class EventHistoryTopologyLinkResource extends ServerResource {
// TODO - Move this to the DeviceManager Rest API
protected static Logger log =
LoggerFactory.getLogger(EventHistoryTopologyLinkResource.class);
@Get("json")
public EventHistory<EventHistoryTopologyLink> handleEvHistReq() {
......@@ -27,11 +32,18 @@ public class EventHistoryTopologyLinkResource extends ServerResource {
// Invalid input for event count - use default value
}
LinkDiscoveryManager topoManager =
(LinkDiscoveryManager)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
return new EventHistory<EventHistoryTopologyLink>(
topoManager.evHistTopologyLink, count);
try {
LinkDiscoveryManager topoManager =
(LinkDiscoveryManager)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
if (topoManager != null) {
return new EventHistory<EventHistoryTopologyLink>(
topoManager.evHistTopologyLink, count);
}
} catch (ClassCastException e) {
log.error(e.toString());
}
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment