Pavlin Radoslavov | e1b37bc | 2013-10-16 03:57:06 -0700 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.topology; |
Pavlin Radoslavov | 382b22a | 2013-01-28 09:24:04 -0800 | [diff] [blame] | 2 | |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 3 | import java.util.ArrayList; |
| 4 | import java.util.Collection; |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 5 | import java.util.HashMap; |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 6 | import java.util.Map; |
Pavlin Radoslavov | 382b22a | 2013-01-28 09:24:04 -0800 | [diff] [blame] | 7 | |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 8 | import net.floodlightcontroller.core.IFloodlightProviderService; |
| 9 | import net.floodlightcontroller.core.module.FloodlightModuleContext; |
| 10 | import net.floodlightcontroller.core.module.FloodlightModuleException; |
| 11 | import net.floodlightcontroller.core.module.IFloodlightModule; |
| 12 | import net.floodlightcontroller.core.module.IFloodlightService; |
| 13 | |
| 14 | import net.onrc.onos.datagrid.IDatagridService; |
Pankaj Berde | 38646d6 | 2013-06-21 11:34:04 -0700 | [diff] [blame] | 15 | import net.onrc.onos.graph.GraphDBOperation; |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 16 | import net.onrc.onos.ofcontroller.floodlightlistener.INetworkGraphService; |
HIGUCHI Yuta | 356086e | 2013-06-12 15:21:19 -0700 | [diff] [blame] | 17 | import net.onrc.onos.ofcontroller.util.DataPath; |
Pavlin Radoslavov | 3ecd41e | 2013-10-29 14:29:30 -0700 | [diff] [blame] | 18 | import net.onrc.onos.ofcontroller.util.FlowEntry; |
| 19 | import net.onrc.onos.ofcontroller.util.FlowPath; |
| 20 | import net.onrc.onos.ofcontroller.util.Port; |
HIGUCHI Yuta | 356086e | 2013-06-12 15:21:19 -0700 | [diff] [blame] | 21 | import net.onrc.onos.ofcontroller.util.SwitchPort; |
Pavlin Radoslavov | 382b22a | 2013-01-28 09:24:04 -0800 | [diff] [blame] | 22 | |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 23 | import org.slf4j.Logger; |
| 24 | import org.slf4j.LoggerFactory; |
Pavlin Radoslavov | 382b22a | 2013-01-28 09:24:04 -0800 | [diff] [blame] | 25 | |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 26 | /** |
Yuta HIGUCHI | e1038fb | 2013-10-30 15:35:18 -0700 | [diff] [blame] | 27 | * A class for obtaining Topology Snapshot |
| 28 | * and PathComputation. |
| 29 | * |
| 30 | * TODO: PathComputation part should be refactored out to separate class. |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 31 | */ |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 32 | public class TopologyManager implements IFloodlightModule, |
| 33 | ITopologyNetService { |
Yuta HIGUCHI | 6ac8d18 | 2013-10-22 15:24:56 -0700 | [diff] [blame] | 34 | private final static Logger log = LoggerFactory.getLogger(TopologyManager.class); |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 35 | protected IFloodlightProviderService floodlightProvider; |
| 36 | |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 37 | protected GraphDBOperation dbHandler; |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 38 | |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 39 | |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 40 | /** |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 41 | * Default constructor. |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 42 | */ |
Pavlin Radoslavov | e1b37bc | 2013-10-16 03:57:06 -0700 | [diff] [blame] | 43 | public TopologyManager() { |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 44 | } |
| 45 | |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 46 | /** |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 47 | * Constructor for given database configuration file. |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 48 | * |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 49 | * @param config the database configuration file to use for |
| 50 | * the initialization. |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 51 | */ |
Pavlin Radoslavov | e1b37bc | 2013-10-16 03:57:06 -0700 | [diff] [blame] | 52 | public TopologyManager(String config) { |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 53 | this.init(config); |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 54 | } |
| 55 | |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 56 | /** |
Pavlin Radoslavov | 0367d35 | 2013-10-19 11:04:43 -0700 | [diff] [blame] | 57 | * Constructor for a given database operation handler. |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 58 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 59 | * @param dbHandler the database operation handler to use for the |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 60 | * initialization. |
| 61 | */ |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 62 | public TopologyManager(GraphDBOperation dbHandler) { |
| 63 | this.dbHandler = dbHandler; |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | /** |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 67 | * Init the module. |
| 68 | * |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 69 | * @param config the database configuration file to use for |
| 70 | * the initialization. |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 71 | */ |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 72 | public void init(String config) { |
| 73 | try { |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 74 | dbHandler = new GraphDBOperation(config); |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 75 | } catch (Exception e) { |
| 76 | log.error(e.getMessage()); |
| 77 | } |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 78 | } |
| 79 | |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 80 | /** |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 81 | * Shutdown the Topology Manager operation. |
| 82 | */ |
| 83 | public void finalize() { |
| 84 | close(); |
| 85 | } |
| 86 | |
| 87 | /** |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 88 | * Close the service. It will close the corresponding database connection. |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 89 | */ |
Pavlin Radoslavov | ddd01ba | 2013-07-03 15:40:44 -0700 | [diff] [blame] | 90 | public void close() { |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 91 | dbHandler.close(); |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 92 | } |
Pavlin Radoslavov | 382b22a | 2013-01-28 09:24:04 -0800 | [diff] [blame] | 93 | |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 94 | /** |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 95 | * Get the collection of offered module services. |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 96 | * |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 97 | * @return the collection of offered module services. |
Pavlin Radoslavov | c5d2fbc | 2013-06-27 18:15:56 -0700 | [diff] [blame] | 98 | */ |
Pavlin Radoslavov | 5d8d77e | 2013-10-18 18:49:25 -0700 | [diff] [blame] | 99 | @Override |
| 100 | public Collection<Class<? extends IFloodlightService>> getModuleServices() { |
| 101 | Collection<Class<? extends IFloodlightService>> l = |
| 102 | new ArrayList<Class<? extends IFloodlightService>>(); |
| 103 | l.add(ITopologyNetService.class); |
| 104 | return l; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Get the collection of implemented services. |
| 109 | * |
| 110 | * @return the collection of implemented services. |
| 111 | */ |
| 112 | @Override |
| 113 | public Map<Class<? extends IFloodlightService>, IFloodlightService> |
| 114 | getServiceImpls() { |
| 115 | Map<Class<? extends IFloodlightService>, |
| 116 | IFloodlightService> m = |
| 117 | new HashMap<Class<? extends IFloodlightService>, |
| 118 | IFloodlightService>(); |
| 119 | m.put(ITopologyNetService.class, this); |
| 120 | return m; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Get the collection of modules this module depends on. |
| 125 | * |
| 126 | * @return the collection of modules this module depends on. |
| 127 | */ |
| 128 | @Override |
| 129 | public Collection<Class<? extends IFloodlightService>> |
| 130 | getModuleDependencies() { |
| 131 | Collection<Class<? extends IFloodlightService>> l = |
| 132 | new ArrayList<Class<? extends IFloodlightService>>(); |
| 133 | l.add(IFloodlightProviderService.class); |
| 134 | l.add(INetworkGraphService.class); |
| 135 | l.add(IDatagridService.class); |
| 136 | return l; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Initialize the module. |
| 141 | * |
| 142 | * @param context the module context to use for the initialization. |
| 143 | */ |
| 144 | @Override |
| 145 | public void init(FloodlightModuleContext context) |
| 146 | throws FloodlightModuleException { |
| 147 | floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class); |
| 148 | |
| 149 | String conf = ""; |
| 150 | this.init(conf); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Startup module operation. |
| 155 | * |
| 156 | * @param context the module context to use for the startup. |
| 157 | */ |
| 158 | @Override |
| 159 | public void startUp(FloodlightModuleContext context) { |
| 160 | |
Pavlin Radoslavov | cec899a | 2013-06-27 15:47:50 -0700 | [diff] [blame] | 161 | } |
Pavlin Radoslavov | 382b22a | 2013-01-28 09:24:04 -0800 | [diff] [blame] | 162 | |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 163 | /** |
| 164 | * Fetch the Switch and Ports info from the Titan Graph |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 165 | * and return it for fast access during the shortest path |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 166 | * computation. |
| 167 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 168 | * After fetching the state, method @ref getTopologyShortestPath() |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 169 | * can be used for fast shortest path computation. |
| 170 | * |
| 171 | * Note: There is certain cost to fetch the state, hence it should |
| 172 | * be used only when there is a large number of shortest path |
| 173 | * computations that need to be done on the same topology. |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 174 | * Typically, a single call to @ref newDatabaseTopology() |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 175 | * should be followed by a large number of calls to |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 176 | * method @ref getTopologyShortestPath(). |
| 177 | * After the last @ref getTopologyShortestPath() call, |
| 178 | * method @ref dropTopology() should be used to release |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 179 | * the internal state that is not needed anymore: |
| 180 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 181 | * Topology topology = topologyManager.newDatabaseTopology(); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 182 | * for (int i = 0; i < 10000; i++) { |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 183 | * dataPath = topologyManager.getTopologyShortestPath(topology, ...); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 184 | * ... |
| 185 | * } |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 186 | * topologyManager.dropTopology(shortestPathTopo); |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 187 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 188 | * @return the allocated topology handler. |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 189 | */ |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 190 | public Topology newDatabaseTopology() { |
| 191 | Topology topology = new Topology(); |
| 192 | topology.readFromDatabase(dbHandler); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 193 | |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 194 | return topology; |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /** |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 198 | * Release the topology that was populated by |
| 199 | * method @ref newDatabaseTopology(). |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 200 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 201 | * See the documentation for method @ref newDatabaseTopology() |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 202 | * for additional information and usage. |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 203 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 204 | * @param topology the topology to release. |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 205 | */ |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 206 | public void dropTopology(Topology topology) { |
| 207 | topology = null; |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /** |
Pavlin Radoslavov | 3ecd41e | 2013-10-29 14:29:30 -0700 | [diff] [blame] | 211 | * Compute the network path for a Flow. |
| 212 | * |
| 213 | * @param topology the topology handler to use. |
| 214 | * @param flowPath the Flow to compute the network path for. |
| 215 | * @return the data path with the computed path if found, otherwise null. |
| 216 | */ |
| 217 | public static DataPath computeNetworkPath(Topology topology, |
| 218 | FlowPath flowPath) { |
| 219 | // |
| 220 | // Compute the network path based on the desired Flow Path type |
| 221 | // |
| 222 | switch (flowPath.flowPathType()) { |
| 223 | case FP_TYPE_SHORTEST_PATH: { |
| 224 | SwitchPort src = flowPath.dataPath().srcPort(); |
| 225 | SwitchPort dest = flowPath.dataPath().dstPort(); |
| 226 | return ShortestPath.getTopologyShortestPath(topology, src, dest); |
| 227 | } |
| 228 | case FP_TYPE_EXPLICIT_PATH: |
| 229 | return flowPath.dataPath(); |
Naoki Shiota | e2f4da7 | 2013-12-09 16:34:17 -0800 | [diff] [blame] | 230 | default: |
| 231 | return null; |
Pavlin Radoslavov | 3ecd41e | 2013-10-29 14:29:30 -0700 | [diff] [blame] | 232 | } |
Pavlin Radoslavov | 3ecd41e | 2013-10-29 14:29:30 -0700 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | /** |
| 236 | * Test whether two Flow Entries represent same points in a data path. |
| 237 | * |
| 238 | * NOTE: Two Flow Entries represent same points in a data path if |
| 239 | * the Switch DPID, incoming port and outgoing port are same. |
| 240 | * |
| 241 | * NOTE: This method is specialized for shortest-path unicast paths, |
| 242 | * and probably should be moved somewhere else. |
| 243 | * |
| 244 | * @param oldFlowEntry the first Flow Entry to compare. |
| 245 | * @param newFlowEntry the second Flow Entry to compare. |
| 246 | * @return true if the two Flow Entries represent same points in a |
| 247 | * data path, otherwise false. |
| 248 | */ |
| 249 | public static boolean isSameFlowEntryDataPath(FlowEntry oldFlowEntry, |
| 250 | FlowEntry newFlowEntry) { |
| 251 | // Test the DPID |
| 252 | if (oldFlowEntry.dpid().value() != newFlowEntry.dpid().value()) |
| 253 | return false; |
| 254 | |
| 255 | // Test the inPort |
| 256 | do { |
| 257 | Port oldPort = oldFlowEntry.inPort(); |
| 258 | Port newPort = newFlowEntry.inPort(); |
| 259 | if ((oldPort != null) && (newPort != null) && |
| 260 | (oldPort.value() == newPort.value())) { |
| 261 | break; |
| 262 | } |
| 263 | if ((oldPort == null) && (newPort == null)) |
| 264 | break; |
| 265 | return false; // inPort is different |
| 266 | } while (false); |
| 267 | |
| 268 | // Test the outPort |
| 269 | do { |
| 270 | Port oldPort = oldFlowEntry.outPort(); |
| 271 | Port newPort = newFlowEntry.outPort(); |
| 272 | if ((oldPort != null) && (newPort != null) && |
| 273 | (oldPort.value() == newPort.value())) { |
| 274 | break; |
| 275 | } |
| 276 | if ((oldPort == null) && (newPort == null)) |
| 277 | break; |
| 278 | return false; // outPort is different |
| 279 | } while (false); |
| 280 | |
| 281 | return true; |
| 282 | } |
| 283 | |
| 284 | /** |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 285 | * Get the shortest path from a source to a destination by |
| 286 | * using the pre-populated local topology state prepared |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 287 | * by method @ref newDatabaseTopology(). |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 288 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 289 | * See the documentation for method @ref newDatabaseTopology() |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 290 | * for additional information and usage. |
| 291 | * |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 292 | * @param topology the topology handler to use. |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 293 | * @param src the source in the shortest path computation. |
| 294 | * @param dest the destination in the shortest path computation. |
| 295 | * @return the data path with the computed shortest path if |
| 296 | * found, otherwise null. |
| 297 | */ |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 298 | public DataPath getTopologyShortestPath(Topology topology, |
| 299 | SwitchPort src, SwitchPort dest) { |
| 300 | return ShortestPath.getTopologyShortestPath(topology, src, dest); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | /** |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 304 | * Get the shortest path from a source to a destination by using |
| 305 | * the underlying database. |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 306 | * |
| 307 | * @param src the source in the shortest path computation. |
| 308 | * @param dest the destination in the shortest path computation. |
| 309 | * @return the data path with the computed shortest path if |
| 310 | * found, otherwise null. |
| 311 | */ |
Pavlin Radoslavov | f34c290 | 2013-02-22 10:33:34 -0800 | [diff] [blame] | 312 | @Override |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 313 | public DataPath getDatabaseShortestPath(SwitchPort src, SwitchPort dest) { |
| 314 | return ShortestPath.getDatabaseShortestPath(dbHandler, src, dest); |
Pavlin Radoslavov | f34c290 | 2013-02-22 10:33:34 -0800 | [diff] [blame] | 315 | } |
| 316 | |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 317 | /** |
| 318 | * Test whether a route exists from a source to a destination. |
| 319 | * |
| 320 | * @param src the source node for the test. |
| 321 | * @param dest the destination node for the test. |
| 322 | * @return true if a route exists, otherwise false. |
| 323 | */ |
Pavlin Radoslavov | f34c290 | 2013-02-22 10:33:34 -0800 | [diff] [blame] | 324 | @Override |
Pavlin Radoslavov | f83aa44 | 2013-02-26 14:09:01 -0800 | [diff] [blame] | 325 | public Boolean routeExists(SwitchPort src, SwitchPort dest) { |
Pavlin Radoslavov | 15954d4 | 2013-10-19 15:29:04 -0700 | [diff] [blame] | 326 | DataPath dataPath = getDatabaseShortestPath(src, dest); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 327 | return (dataPath != null); |
Pavlin Radoslavov | f34c290 | 2013-02-22 10:33:34 -0800 | [diff] [blame] | 328 | } |
Pavlin Radoslavov | 382b22a | 2013-01-28 09:24:04 -0800 | [diff] [blame] | 329 | } |