Skip to content
Snippets Groups Projects
Commit d4b2743e authored by Geddings Barrineau's avatar Geddings Barrineau
Browse files

Added a way to get routes-fast and routes-slow through the REST api.

parent f0ce6eb8
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,34 @@ public interface IRoutingService extends IFloodlightService {
/** Another version of getRoutes that uses Yen's algorithm under the hood. */
public ArrayList<Route> getRoutes(DatapathId srcDpid, DatapathId dstDpid, Integer numOfRoutesToGet);
/**
*
* This function returns K number of routes between a source and destination IF THEY EXIST IN THE ROUTECACHE.
* If the user requests more routes than available, only the routes already stored in memory will be returned.
* This value can be adjusted in floodlightdefault.properties.
*
*
* @param srcDpid: DatapathId of the route source.
* @param dstDpid: DatapathId of the route destination.
* @param numOfRoutesToGet: The number of routes that you want. Must be positive integer.
* @return ArrayList of Routes or null if bad parameters
*/
public ArrayList<Route> getRoutesFast(DatapathId srcDpid, DatapathId dstDpid, Integer numOfRoutesToGet);
/**
*
* This function returns K number of routes between a source and destination. It will attempt to retrieve
* these routes from the routecache. If the user requests more routes than are stored, Yen's algorithm will be
* run using the K value passed in.
*
*
* @param srcDpid: DatapathId of the route source.
* @param dstDpid: DatapathId of the route destination.
* @param numOfRoutesToGet: The number of routes that you want. Must be positive integer.
* @return ArrayList of Routes or null if bad parameters
*/
public ArrayList<Route> getRoutesSlow(DatapathId srcDpid, DatapathId dstDpid, Integer numOfRoutesToGet);
/** Check if a route exists between src and dst, including tunnel links
* in the path.
*/
......
......@@ -631,6 +631,14 @@ public class TopologyManager implements IFloodlightModule, ITopologyService, IRo
return getCurrentInstance().getRoutes(srcDpid, dstDpid, k);
}
public ArrayList<Route> getRoutesFast(DatapathId srcDpid, DatapathId dstDpid, Integer k) {
return getCurrentInstance().getRoutesFast(srcDpid, dstDpid, k);
}
public ArrayList<Route> getRoutesSlow(DatapathId srcDpid, DatapathId dstDpid, Integer k) {
return getCurrentInstance().getRoutesSlow(srcDpid, dstDpid, k);
}
public Map<Link, Integer> getLinkCostMap(boolean tunnelEnabled) {
TopologyInstance ti = getCurrentInstance(tunnelEnabled);
return ti.initLinkCostMap();
......
......@@ -37,13 +37,12 @@ public class RoutesResource extends ServerResource {
(IRoutingService)getContext().getAttributes().
get(IRoutingService.class.getCanonicalName());
String url = getRequest().getResourceRef().toString();
String srcDpid = (String) getRequestAttributes().get("src-dpid");
String dstDpid = (String) getRequestAttributes().get("dst-dpid");
Integer numRoutes = Integer.parseInt((String) getRequestAttributes().get("num-routes"));
log.info("REQUEST1: {}", getRequest().getRootRef().toString());
log.info("REQUEST2: {}", getRequest().getResourceRef().toString());
log.debug("Asking for routes from {} to {}", srcDpid, dstDpid);
log.debug("Asking for {} routes", numRoutes);
......@@ -52,7 +51,13 @@ public class RoutesResource extends ServerResource {
List<Route> results = null;
try {
results = routing.getRoutes(longSrcDpid, longDstDpid, numRoutes);
if (url.contains("fast")) {
results = routing.getRoutesFast(longSrcDpid, longDstDpid, numRoutes);
} else if (url.contains("slow")) {
results = routing.getRoutesSlow(longSrcDpid, longDstDpid, numRoutes);
} else {
results = routing.getRoutes(longSrcDpid, longDstDpid, numRoutes);
}
} catch (Exception e) {
log.warn("{}", e);
log.warn("EXCEPTION: No routes found in request for routes from {} to {}", srcDpid, dstDpid);
......
......@@ -41,6 +41,8 @@ public class TopologyWebRoutable implements RestletRoutable {
router.attach("/blockedports/json", BlockedPortsResource.class);
router.attach("/route/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json", RouteResource.class);
router.attach("/routes/{src-dpid}/{dst-dpid}/{num-routes}/json", RoutesResource.class);
router.attach("/routes-fast/{src-dpid}/{dst-dpid}/{num-routes}/json", RoutesResource.class);
router.attach("/routes-slow/{src-dpid}/{dst-dpid}/{num-routes}/json", RoutesResource.class);
router.attach("/setroutemetric/{metric}/json", RouteMetrics.class);
return router;
......
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