blob: 3b90f89ec6f42459c382f85b360499a8b6ebd062 [file] [log] [blame]
Jonathan Hart472062d2014-04-03 10:56:48 -07001package net.onrc.onos.core.topology;
Jonathan Hart062a2e82014-02-03 09:41:57 -08002
Jonathan Hart062a2e82014-02-03 09:41:57 -08003import net.floodlightcontroller.util.MACAddress;
4
5/**
Jonathan Harte37e4e22014-05-13 19:12:02 -07006 * The northbound interface to the topology. This interface
Jonathan Hart062a2e82014-02-03 09:41:57 -08007 * 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 Hart062a2e82014-02-03 09:41:57 -08009 */
Jonathan Harte37e4e22014-05-13 19:12:02 -070010public interface Topology {
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080011 /**
12 * Get the switch for a given switch DPID.
13 *
14 * @param dpid the switch dpid.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080015 * @return the switch if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080016 */
17 public Switch getSwitch(Long dpid);
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080018
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080019 /**
20 * Get all switches in the network.
21 *
22 * @return all switches in the network.
23 */
24 public Iterable<Switch> getSwitches();
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080025
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080026 /**
27 * Get the port on a switch.
28 *
Ray Milkey269ffb92014-04-03 14:43:30 -070029 * @param dpid the switch DPID.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080030 * @param number the switch port number.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080031 * @return the switch port if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080032 */
33 public Port getPort(Long dpid, Long number);
34
35 /**
Jonathan Hart25bd53e2014-04-30 23:44:09 -070036 * Get the outgoing link from a switch port.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080037 *
Ray Milkey269ffb92014-04-03 14:43:30 -070038 * @param dpid the switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080039 * @param number the switch port number.
40 * @return the outgoing link if found, otherwise null.
41 */
Jonathan Hart25bd53e2014-04-30 23:44:09 -070042 public Link getOutgoingLink(Long dpid, Long number);
43 // TODO See if we should change <dpid, port_num> pairs to SwitchPort
44
45 /**
46 * Get the incoming link to a switch port.
47 *
48 * @param dpid the switch DPID.
49 * @param number the switch port number.
50 * @return the incoming link if found, otherwise null.
51 */
52 public Link getIncomingLink(Long dpid, Long number);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080053
54 /**
55 * Get the outgoing link from a switch and a port to another switch and
56 * a port.
57 *
Ray Milkey269ffb92014-04-03 14:43:30 -070058 * @param srcDpid the source switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080059 * @param srcNumber the source switch port number.
Ray Milkey269ffb92014-04-03 14:43:30 -070060 * @param dstDpid the destination switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080061 * @param dstNumber the destination switch port number.
62 * @return the outgoing link if found, otherwise null.
63 */
64 public Link getLink(Long srcDpid, Long srcNumber, Long dstDpid,
Ray Milkey269ffb92014-04-03 14:43:30 -070065 Long dstNumber);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080066
67 /**
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080068 * Get all links in the network.
Ray Milkey269ffb92014-04-03 14:43:30 -070069 * <p/>
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080070 * TODO: Not clear if this method is needed. Remove if not used.
71 *
72 * @return all links in the network.
73 */
74 public Iterable<Link> getLinks();
75
76 /**
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080077 * Get the network device for a given MAC address.
78 *
79 * @param address the MAC address to use.
80 * @return the network device for the MAC address if found, otherwise null.
81 */
82 public Device getDeviceByMac(MACAddress address);
Ray Milkey269ffb92014-04-03 14:43:30 -070083
Jonathan Hart26f291b2014-02-18 16:57:24 -080084 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070085 * Acquire a read lock on the entire topology. The topology will not
86 * change while readers have the lock. Must be released using
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -080087 * {@link releaseReadLock()}. This method will block until a read lock is
Jonathan Hart26f291b2014-02-18 16:57:24 -080088 * available.
89 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -080090 public void acquireReadLock();
Ray Milkey269ffb92014-04-03 14:43:30 -070091
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080092 /**
93 * Release the read lock on the topology.
94 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -080095 public void releaseReadLock();
TeruU65bc5ff2014-04-23 22:22:32 -070096
97 public Iterable<Device> getDevices();
Jonathan Hart062a2e82014-02-03 09:41:57 -080098}