Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.core; |
| 2 | |
| 3 | import java.util.List; |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 4 | import java.util.Map; |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 5 | |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 6 | import net.floodlightcontroller.core.module.IFloodlightService; |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 7 | import net.floodlightcontroller.core.INetMapTopologyObjects.IDeviceObject; |
| 8 | import net.floodlightcontroller.core.INetMapTopologyObjects.IPortObject; |
Pankaj Berde | 1e2f731 | 2013-02-15 08:25:31 -0800 | [diff] [blame] | 9 | import net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject; |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 10 | import net.floodlightcontroller.routing.Link; |
| 11 | import net.floodlightcontroller.topology.NodePortTuple; |
Pavlin Radoslavov | f83aa44 | 2013-02-26 14:09:01 -0800 | [diff] [blame] | 12 | import net.floodlightcontroller.util.DataPath; |
| 13 | import net.floodlightcontroller.util.SwitchPort; |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 14 | |
| 15 | public interface INetMapTopologyService extends INetMapService { |
| 16 | |
| 17 | public interface ITopoSwitchService { |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 18 | Iterable<ISwitchObject> getActiveSwitches(); |
| 19 | Iterable<ISwitchObject> getAllSwitches(); |
| 20 | Iterable<ISwitchObject> getInactiveSwitches(); |
| 21 | Iterable<IPortObject> getPortsOnSwitch(String dpid); |
| 22 | IPortObject getPortOnSwitch(String dpid, short port_num); |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 23 | void close(); |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 24 | |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | public interface ITopoLinkService { |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 28 | List<Link> getActiveLinks(); |
| 29 | List<Link> getLinksOnSwitch(String dpid); |
Pankaj Berde | 1519309 | 2013-03-21 17:30:14 -0700 | [diff] [blame] | 30 | void close(); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 31 | } |
| 32 | public interface ITopoDeviceService { |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 33 | Iterable<IDeviceObject> getActiveDevices(); |
| 34 | Iterable<IDeviceObject> getDevicesOnSwitch(String dpid); |
| 35 | Iterable<IDeviceObject> getDevicesOnSwitch(String dpid, short port_num); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 36 | } |
| 37 | |
Pavlin Radoslavov | d7d8b79 | 2013-02-22 10:24:38 -0800 | [diff] [blame] | 38 | public interface ITopoRouteService extends IFloodlightService { |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 39 | /** |
| 40 | * Get the shortest path from a source to a destination. |
| 41 | * |
| 42 | * @param src the source in the shortest path computation. |
| 43 | * @param dest the destination in the shortest path computation. |
| 44 | * @return the data path with the computed shortest path if |
| 45 | * found, otherwise null. |
| 46 | */ |
Pavlin Radoslavov | f83aa44 | 2013-02-26 14:09:01 -0800 | [diff] [blame] | 47 | DataPath getShortestPath(SwitchPort src, SwitchPort dest); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * Fetch the Switch and Ports info from the Titan Graph |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 51 | * and return it for fast access during the shortest path |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 52 | * computation. |
| 53 | * |
| 54 | * After fetching the state, method @ref getTopoShortestPath() |
| 55 | * can be used for fast shortest path computation. |
| 56 | * |
| 57 | * Note: There is certain cost to fetch the state, hence it should |
| 58 | * be used only when there is a large number of shortest path |
| 59 | * computations that need to be done on the same topology. |
| 60 | * Typically, a single call to @ref prepareShortestPathTopo() |
| 61 | * should be followed by a large number of calls to |
| 62 | * method @ref getTopoShortestPath(). |
| 63 | * After the last @ref getTopoShortestPath() call, |
| 64 | * method @ref dropShortestPathTopo() should be used to release |
| 65 | * the internal state that is not needed anymore: |
| 66 | * |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 67 | * Map<Long, ?> shortestPathTopo; |
| 68 | * shortestPathTopo = prepareShortestPathTopo(); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 69 | * for (int i = 0; i < 10000; i++) { |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 70 | * dataPath = getTopoShortestPath(shortestPathTopo, ...); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 71 | * ... |
| 72 | * } |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 73 | * dropShortestPathTopo(shortestPathTopo); |
| 74 | * |
| 75 | * @return the Shortest Path info handler stored in a map. |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 76 | */ |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 77 | Map<Long, ?> prepareShortestPathTopo(); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * Release the state that was populated by |
| 81 | * method @ref prepareShortestPathTopo(). |
| 82 | * |
| 83 | * See the documentation for method @ref prepareShortestPathTopo() |
| 84 | * for additional information and usage. |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 85 | * |
| 86 | * @shortestPathTopo the Shortest Path info handler to release. |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 87 | */ |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 88 | void dropShortestPathTopo(Map<Long, ?> shortestPathTopo); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Get the shortest path from a source to a destination by |
| 92 | * using the pre-populated local topology state prepared |
| 93 | * by method @ref prepareShortestPathTopo(). |
| 94 | * |
| 95 | * See the documentation for method @ref prepareShortestPathTopo() |
| 96 | * for additional information and usage. |
| 97 | * |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 98 | * @paran shortestPathTopoHandler the Shortest Path info handler |
| 99 | * to use. |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 100 | * @param src the source in the shortest path computation. |
| 101 | * @param dest the destination in the shortest path computation. |
| 102 | * @return the data path with the computed shortest path if |
| 103 | * found, otherwise null. |
| 104 | */ |
Pavlin Radoslavov | 9556b14 | 2013-05-20 21:49:04 +0000 | [diff] [blame] | 105 | DataPath getTopoShortestPath(Map<Long, ?> shortestPathTopo, |
| 106 | SwitchPort src, SwitchPort dest); |
Pavlin Radoslavov | a5f167b | 2013-03-21 11:39:27 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Test whether a route exists from a source to a destination. |
| 110 | * |
| 111 | * @param src the source node for the test. |
| 112 | * @param dest the destination node for the test. |
| 113 | * @return true if a route exists, otherwise false. |
| 114 | */ |
Pavlin Radoslavov | f83aa44 | 2013-02-26 14:09:01 -0800 | [diff] [blame] | 115 | Boolean routeExists(SwitchPort src, SwitchPort dest); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | public interface ITopoFlowService { |
Pankaj Berde | 2497e54 | 2013-02-19 18:51:24 -0800 | [diff] [blame] | 119 | Boolean flowExists(NodePortTuple src, NodePortTuple dest); |
| 120 | List<NodePortTuple> getShortestFlowPath(NodePortTuple src, NodePortTuple dest); |
Pankaj Berde | d1259e8 | 2013-01-23 14:10:00 -0800 | [diff] [blame] | 121 | |
| 122 | } |
| 123 | } |