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