Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.topology; |
| 2 | |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 3 | import net.floodlightcontroller.core.module.IFloodlightService; |
| 4 | import net.onrc.onos.ofcontroller.util.DataPath; |
| 5 | import net.onrc.onos.ofcontroller.util.SwitchPort; |
| 6 | |
| 7 | /** |
| 8 | * Interface for providing Topology Network Service to other modules. |
| 9 | */ |
| 10 | public interface ITopologyNetService extends IFloodlightService { |
| 11 | /** |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 12 | * Fetch the Switch and Ports info from the Titan Graph |
| 13 | * and return it for fast access during the shortest path |
| 14 | * computation. |
| 15 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 16 | * After fetching the state, method @ref getTopologyShortestPath() |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 17 | * can be used for fast shortest path computation. |
| 18 | * |
| 19 | * Note: There is certain cost to fetch the state, hence it should |
| 20 | * be used only when there is a large number of shortest path |
| 21 | * computations that need to be done on the same topology. |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 22 | * Typically, a single call to @ref newDatabaseTopology() |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 23 | * should be followed by a large number of calls to |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 24 | * method @ref getTopologyShortestPath(). |
| 25 | * After the last @ref getTopologyShortestPath() call, |
| 26 | * method @ref dropTopology() should be used to release |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 27 | * the internal state that is not needed anymore: |
| 28 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 29 | * Topology topology = topologyManager.newDatabaseTopology(); |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 30 | * for (int i = 0; i < 10000; i++) { |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 31 | * dataPath = topologyManager.getTopologyShortestPath(topology, ...); |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 32 | * ... |
| 33 | * } |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 34 | * topologyManager.dropTopology(shortestPathTopo); |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 35 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 36 | * @return the allocated topology handler. |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 37 | */ |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 38 | Topology newDatabaseTopology(); |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 39 | |
| 40 | /** |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 41 | * Release the topology that was populated by |
| 42 | * method @ref newDatabaseTopology(). |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 43 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 44 | * See the documentation for method @ref newDatabaseTopology() |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 45 | * for additional information and usage. |
| 46 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 47 | * @param topology the topology to release. |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 48 | */ |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 49 | void dropTopology(Topology topology); |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Get the shortest path from a source to a destination by |
| 53 | * using the pre-populated local topology state prepared |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 54 | * by method @ref newDatabaseTopology(). |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 55 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 56 | * See the documentation for method @ref newDatabaseTopology() |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 57 | * for additional information and usage. |
| 58 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 59 | * @param topology the topology handler to use. |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 60 | * @param src the source in the shortest path computation. |
| 61 | * @param dest the destination in the shortest path computation. |
| 62 | * @return the data path with the computed shortest path if |
| 63 | * found, otherwise null. |
| 64 | */ |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 65 | DataPath getTopologyShortestPath(Topology topology, |
| 66 | SwitchPort src, SwitchPort dest); |
| 67 | |
| 68 | /** |
| 69 | * Get the shortest path from a source to a destination by using |
| 70 | * the underlying database. |
| 71 | * |
| 72 | * @param src the source in the shortest path computation. |
| 73 | * @param dest the destination in the shortest path computation. |
| 74 | * @return the data path with the computed shortest path if |
| 75 | * found, otherwise null. |
| 76 | */ |
| 77 | DataPath getDatabaseShortestPath(SwitchPort src, SwitchPort dest); |
Pavlin Radoslavov | 1278ac7 | 2013-10-16 04:43:49 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * Test whether a route exists from a source to a destination. |
| 81 | * |
| 82 | * @param src the source node for the test. |
| 83 | * @param dest the destination node for the test. |
| 84 | * @return true if a route exists, otherwise false. |
| 85 | */ |
| 86 | Boolean routeExists(SwitchPort src, SwitchPort dest); |
| 87 | } |