Renamed interface
net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoRouteService
to
net.onrc.onos.ofcontroller.topology.ITopologyNetService
NOTE: There is already Floodlight interface ITopologyService, hence
here we use the name ITopologyNetService.
In the future, Floodlight ITopologyService should be removed, and
ITopologyNetService renamed to ITopologyService.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/topology/ITopologyNetService.java b/src/main/java/net/onrc/onos/ofcontroller/topology/ITopologyNetService.java
new file mode 100644
index 0000000..bd0ca38
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/topology/ITopologyNetService.java
@@ -0,0 +1,90 @@
+package net.onrc.onos.ofcontroller.topology;
+
+import java.util.Map;
+
+import net.floodlightcontroller.core.module.IFloodlightService;
+import net.onrc.onos.ofcontroller.util.DataPath;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
+
+/**
+ * Interface for providing Topology Network Service to other modules.
+ */
+public interface ITopologyNetService extends IFloodlightService {
+ /**
+ * Get the shortest path from a source to a destination.
+ *
+ * @param src the source in the shortest path computation.
+ * @param dest the destination in the shortest path computation.
+ * @return the data path with the computed shortest path if
+ * found, otherwise null.
+ */
+ DataPath getShortestPath(SwitchPort src, SwitchPort dest);
+
+ /**
+ * Fetch the Switch and Ports info from the Titan Graph
+ * and return it for fast access during the shortest path
+ * computation.
+ *
+ * After fetching the state, method @ref getTopoShortestPath()
+ * can be used for fast shortest path computation.
+ *
+ * Note: There is certain cost to fetch the state, hence it should
+ * be used only when there is a large number of shortest path
+ * computations that need to be done on the same topology.
+ * Typically, a single call to @ref prepareShortestPathTopo()
+ * should be followed by a large number of calls to
+ * method @ref getTopoShortestPath().
+ * After the last @ref getTopoShortestPath() call,
+ * method @ref dropShortestPathTopo() should be used to release
+ * the internal state that is not needed anymore:
+ *
+ * Map<Long, ?> shortestPathTopo;
+ * shortestPathTopo = prepareShortestPathTopo();
+ * for (int i = 0; i < 10000; i++) {
+ * dataPath = getTopoShortestPath(shortestPathTopo, ...);
+ * ...
+ * }
+ * dropShortestPathTopo(shortestPathTopo);
+ *
+ * @return the Shortest Path info handler stored in a map.
+ */
+ Map<Long, ?> prepareShortestPathTopo();
+
+ /**
+ * Release the state that was populated by
+ * method @ref prepareShortestPathTopo().
+ *
+ * See the documentation for method @ref prepareShortestPathTopo()
+ * for additional information and usage.
+ *
+ * @param shortestPathTopo the Shortest Path info handler to release.
+ */
+ void dropShortestPathTopo(Map<Long, ?> shortestPathTopo);
+
+ /**
+ * Get the shortest path from a source to a destination by
+ * using the pre-populated local topology state prepared
+ * by method @ref prepareShortestPathTopo().
+ *
+ * See the documentation for method @ref prepareShortestPathTopo()
+ * for additional information and usage.
+ *
+ * @param shortestPathTopo the Shortest Path info handler
+ * to use.
+ * @param src the source in the shortest path computation.
+ * @param dest the destination in the shortest path computation.
+ * @return the data path with the computed shortest path if
+ * found, otherwise null.
+ */
+ DataPath getTopoShortestPath(Map<Long, ?> shortestPathTopo,
+ SwitchPort src, SwitchPort dest);
+
+ /**
+ * Test whether a route exists from a source to a destination.
+ *
+ * @param src the source node for the test.
+ * @param dest the destination node for the test.
+ * @return true if a route exists, otherwise false.
+ */
+ Boolean routeExists(SwitchPort src, SwitchPort dest);
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/topology/TopologyManager.java b/src/main/java/net/onrc/onos/ofcontroller/topology/TopologyManager.java
index c0a5e57..545128d 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/topology/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/topology/TopologyManager.java
@@ -11,7 +11,6 @@
import net.onrc.onos.graph.GraphDBOperation;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
-import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoRouteService;
import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
import net.onrc.onos.ofcontroller.util.DataPath;
import net.onrc.onos.ofcontroller.util.Dpid;
@@ -87,9 +86,9 @@
};
/**
- * A class for implementing Topology Route Service.
+ * A class for implementing Topology Network Service.
*/
-public class TopologyManager implements ITopoRouteService {
+public class TopologyManager implements ITopologyNetService {
/** The logger. */
private static Logger log = LoggerFactory.getLogger(TopologyManager.class);
diff --git a/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java b/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
index c596547..a730719 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
@@ -1,6 +1,6 @@
package net.onrc.onos.ofcontroller.topology.web;
-import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoRouteService;
+import net.onrc.onos.ofcontroller.topology.ITopologyNetService;
import net.onrc.onos.ofcontroller.topology.TopologyManager;
import net.onrc.onos.ofcontroller.util.DataPath;
import net.onrc.onos.ofcontroller.util.Dpid;
@@ -18,9 +18,9 @@
@Get("json")
public DataPath retrieve() {
- ITopoRouteService topoRouteService = new TopologyManager("");
- if (topoRouteService == null) {
- log.debug("Topology Route Service not found");
+ ITopologyNetService topologyNetService = new TopologyManager("");
+ if (topologyNetService == null) {
+ log.debug("Topology Net Service not found");
return null;
}
@@ -37,8 +37,8 @@
Port dstPort = new Port(Short.parseShort(dstPortStr));
DataPath result =
- topoRouteService.getShortestPath(new SwitchPort(srcDpid, srcPort),
- new SwitchPort(dstDpid, dstPort));
+ topologyNetService.getShortestPath(new SwitchPort(srcDpid, srcPort),
+ new SwitchPort(dstDpid, dstPort));
if (result != null) {
return result;
} else {