Skip to content
Snippets Groups Projects
Commit 22cdfaeb authored by kwanggithub's avatar kwanggithub
Browse files

- Add getRoutes() to IRoutingService, dummy getRoutes() to TopologyManager -...

- Add getRoutes() to IRoutingService, dummy getRoutes() to TopologyManager - update Link to be comparable/sortable - add routeCount to Route - add cookie to RouteId - make NodeDist protected
parent fca68b2c
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,8 @@
package net.floodlightcontroller.routing;
import java.util.ArrayList;
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.routing.Route;
......@@ -37,6 +39,9 @@ public interface IRoutingService extends IFloodlightService {
long dstId, short dstPort,
boolean tunnelEnabled);
/** return all routes, if available */
public ArrayList<Route> getRoutes(long longSrcDpid, long longDstDpid, boolean tunnelEnabled);
/** Check if a route exists between src and dst, including tunnel links
* in the path.
*/
......@@ -46,4 +51,5 @@ public interface IRoutingService extends IFloodlightService {
* or not have tunnels as part of the path.
*/
public boolean routeExists(long src, long dst, boolean tunnelEnabled);
}
\ No newline at end of file
......@@ -24,7 +24,7 @@ import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.openflow.util.HexString;
public class Link {
public class Link implements Comparable<Link> {
private long src;
private short srcPort;
private long dst;
......@@ -118,5 +118,20 @@ public class Link {
HexString.toHexString(this.dst) + "|" +
(this.dstPort & 0xffff) );
}
@Override
public int compareTo(Link a) {
// compare link based on natural ordering - src id, src port, dst id, dst port
if (this.getSrc() != a.getSrc())
return (int) (this.getSrc() - a.getSrc());
if (this.getSrcPort() != a.getSrcPort())
return (int) (this.getSrc() - a.getSrc());
if (this.getDst() != a.getDst())
return (int) (this.getDst() - a.getDst());
return (int) (this.getDstPort() - a.getDstPort());
}
}
......@@ -30,17 +30,20 @@ import net.floodlightcontroller.topology.NodePortTuple;
public class Route implements Comparable<Route> {
protected RouteId id;
protected List<NodePortTuple> switchPorts;
protected int routeCount;
public Route(RouteId id, List<NodePortTuple> switchPorts) {
super();
this.id = id;
this.switchPorts = switchPorts;
this.routeCount = 0; // useful if multipath routing available
}
public Route(Long src, Long dst) {
super();
this.id = new RouteId(src, dst);
this.switchPorts = new ArrayList<NodePortTuple>();
this.routeCount = 0;
}
/**
......@@ -71,6 +74,20 @@ public class Route implements Comparable<Route> {
this.switchPorts = switchPorts;
}
/**
* @param routeCount routeCount set by (ECMP) buildRoute method
*/
public void setRouteCount(int routeCount) {
this.routeCount = routeCount;
}
/**
* @return routeCount return routeCount set by (ECMP) buildRoute method
*/
public int getRouteCount() {
return routeCount;
}
@Override
public int hashCode() {
final int prime = 5791;
......
......@@ -27,11 +27,20 @@ import org.openflow.util.HexString;
public class RouteId implements Cloneable, Comparable<RouteId> {
protected Long src;
protected Long dst;
protected long cookie;
public RouteId(Long src, Long dst) {
super();
this.src = src;
this.dst = dst;
this.cookie = 0;
}
public RouteId(Long src, Long dst, long cookie) {
super();
this.src = src;
this.dst = dst;
this.cookie = cookie;
}
public Long getSrc() {
......@@ -50,13 +59,24 @@ public class RouteId implements Cloneable, Comparable<RouteId> {
this.dst = dst;
}
public long getCookie() {
return cookie;
}
public void setCookie(int cookie) {
this.cookie = cookie;
}
@Override
public int hashCode() {
final int prime = 2417;
int result = 1;
Long result = new Long(1);
result = prime * result + ((dst == null) ? 0 : dst.hashCode());
result = prime * result + ((src == null) ? 0 : src.hashCode());
return result;
result = prime * result + cookie;
// To cope with long cookie, use Long to compute hash then use Long's
// built-in hash to produce int hash code
return result.hashCode();
}
@Override
......
......@@ -421,7 +421,7 @@ public class TopologyInstance {
return broadcastDomainPorts.contains(npt);
}
class NodeDist implements Comparable<NodeDist> {
protected class NodeDist implements Comparable<NodeDist> {
private Long node;
public Long getNode() {
return node;
......
......@@ -529,7 +529,7 @@ public class TopologyManager implements
TopologyInstance ti = getCurrentInstance(tunnelEnabled);
return ti.getRoute(src, srcPort, dst, dstPort);
}
@Override
public boolean routeExists(long src, long dst) {
return routeExists(src, dst, true);
......@@ -1263,4 +1263,15 @@ public class TopologyManager implements
ports.addAll(ofpList);
return ports;
}
@Override
public ArrayList<Route> getRoutes(long srcDpid, long dstDpid,
boolean tunnelEnabled) {
// Floodlight supports single path routing now
// return single path now
ArrayList<Route> result=new ArrayList<Route>();
result.add(getRoute(srcDpid, dstDpid, tunnelEnabled));
return result;
}
}
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