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