Jonathan Hart | 472062d | 2014-04-03 10:56:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.topology; |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 2 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 3 | import net.floodlightcontroller.util.MACAddress; |
| 4 | |
| 5 | /** |
| 6 | * The northbound interface to the topology network graph. This interface |
| 7 | * is presented to the rest of ONOS. It is currently read-only, as we want |
| 8 | * only the discovery modules to be allowed to modify the topology. |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 9 | */ |
| 10 | public interface NetworkGraph { |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 11 | /** |
| 12 | * Get the switch for a given switch DPID. |
| 13 | * |
| 14 | * @param dpid the switch dpid. |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 15 | * @return the switch if found, otherwise null. |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 16 | */ |
| 17 | public Switch getSwitch(Long dpid); |
Yuta HIGUCHI | c6174df | 2014-02-10 20:44:38 -0800 | [diff] [blame] | 18 | |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 19 | /** |
| 20 | * Get all switches in the network. |
| 21 | * |
| 22 | * @return all switches in the network. |
| 23 | */ |
| 24 | public Iterable<Switch> getSwitches(); |
Yuta HIGUCHI | c6174df | 2014-02-10 20:44:38 -0800 | [diff] [blame] | 25 | |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 26 | /** |
| 27 | * Get the port on a switch. |
| 28 | * |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 29 | * @param dpid the switch DPID. |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 30 | * @param number the switch port number. |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 31 | * @return the switch port if found, otherwise null. |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 32 | */ |
| 33 | public Port getPort(Long dpid, Long number); |
| 34 | |
| 35 | /** |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 36 | * Get the outgoing link for a switch and a port. |
| 37 | * |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 38 | * @param dpid the switch DPID. |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 39 | * @param number the switch port number. |
| 40 | * @return the outgoing link if found, otherwise null. |
| 41 | */ |
| 42 | public Link getLink(Long dpid, Long number); |
| 43 | |
| 44 | /** |
| 45 | * Get the outgoing link from a switch and a port to another switch and |
| 46 | * a port. |
| 47 | * |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 48 | * @param srcDpid the source switch DPID. |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 49 | * @param srcNumber the source switch port number. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 50 | * @param dstDpid the destination switch DPID. |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 51 | * @param dstNumber the destination switch port number. |
| 52 | * @return the outgoing link if found, otherwise null. |
| 53 | */ |
| 54 | public Link getLink(Long srcDpid, Long srcNumber, Long dstDpid, |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 55 | Long dstNumber); |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 56 | |
| 57 | /** |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 58 | * Get all links in the network. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 59 | * <p/> |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 60 | * TODO: Not clear if this method is needed. Remove if not used. |
| 61 | * |
| 62 | * @return all links in the network. |
| 63 | */ |
| 64 | public Iterable<Link> getLinks(); |
| 65 | |
| 66 | /** |
Pavlin Radoslavov | 06df22a | 2014-02-18 19:16:27 -0800 | [diff] [blame] | 67 | * Get the network device for a given MAC address. |
| 68 | * |
| 69 | * @param address the MAC address to use. |
| 70 | * @return the network device for the MAC address if found, otherwise null. |
| 71 | */ |
| 72 | public Device getDeviceByMac(MACAddress address); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 73 | |
Jonathan Hart | 26f291b | 2014-02-18 16:57:24 -0800 | [diff] [blame] | 74 | /** |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 75 | * Acquire a read lock on the entire topology. The topology will not |
| 76 | * change while readers have the lock. Must be released using |
Pavlin Radoslavov | 8ffb8bf | 2014-02-20 15:34:26 -0800 | [diff] [blame] | 77 | * {@link releaseReadLock()}. This method will block until a read lock is |
Jonathan Hart | 26f291b | 2014-02-18 16:57:24 -0800 | [diff] [blame] | 78 | * available. |
| 79 | */ |
Pavlin Radoslavov | 8ffb8bf | 2014-02-20 15:34:26 -0800 | [diff] [blame] | 80 | public void acquireReadLock(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 81 | |
Pavlin Radoslavov | 7c8f69a | 2014-02-19 19:01:45 -0800 | [diff] [blame] | 82 | /** |
| 83 | * Release the read lock on the topology. |
| 84 | */ |
Pavlin Radoslavov | 8ffb8bf | 2014-02-20 15:34:26 -0800 | [diff] [blame] | 85 | public void releaseReadLock(); |
TeruU | 65bc5ff | 2014-04-23 22:22:32 -0700 | [diff] [blame^] | 86 | |
| 87 | public Iterable<Device> getDevices(); |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 88 | } |