blob: 844507dde037e9226fc455292b59484da7e785f2 [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;
Ray Milkey0fe43852014-06-05 14:41:46 -07004import net.onrc.onos.core.topology.serializers.TopologySerializer;
5import org.codehaus.jackson.map.annotate.JsonSerialize;
Jonathan Hart062a2e82014-02-03 09:41:57 -08006
7/**
Jonathan Harte37e4e22014-05-13 19:12:02 -07008 * The northbound interface to the topology. This interface
Jonathan Hart062a2e82014-02-03 09:41:57 -08009 * is presented to the rest of ONOS. It is currently read-only, as we want
10 * only the discovery modules to be allowed to modify the topology.
Jonathan Hart062a2e82014-02-03 09:41:57 -080011 */
Ray Milkey0fe43852014-06-05 14:41:46 -070012@JsonSerialize(using = TopologySerializer.class)
Jonathan Harte37e4e22014-05-13 19:12:02 -070013public interface Topology {
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080014 /**
15 * Get the switch for a given switch DPID.
16 *
17 * @param dpid the switch dpid.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080018 * @return the switch if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080019 */
20 public Switch getSwitch(Long dpid);
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080021
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080022 /**
23 * Get all switches in the network.
24 *
25 * @return all switches in the network.
26 */
27 public Iterable<Switch> getSwitches();
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080028
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080029 /**
30 * Get the port on a switch.
31 *
Ray Milkey269ffb92014-04-03 14:43:30 -070032 * @param dpid the switch DPID.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080033 * @param number the switch port number.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080034 * @return the switch port if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080035 */
36 public Port getPort(Long dpid, Long number);
37
38 /**
Jonathan Hart25bd53e2014-04-30 23:44:09 -070039 * Get the outgoing link from a switch port.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080040 *
Ray Milkey269ffb92014-04-03 14:43:30 -070041 * @param dpid the switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080042 * @param number the switch port number.
43 * @return the outgoing link if found, otherwise null.
44 */
Jonathan Hart25bd53e2014-04-30 23:44:09 -070045 public Link getOutgoingLink(Long dpid, Long number);
46 // TODO See if we should change <dpid, port_num> pairs to SwitchPort
47
48 /**
49 * Get the incoming link to a switch port.
50 *
51 * @param dpid the switch DPID.
52 * @param number the switch port number.
53 * @return the incoming link if found, otherwise null.
54 */
55 public Link getIncomingLink(Long dpid, Long number);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080056
57 /**
58 * Get the outgoing link from a switch and a port to another switch and
59 * a port.
60 *
Ray Milkey269ffb92014-04-03 14:43:30 -070061 * @param srcDpid the source switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080062 * @param srcNumber the source switch port number.
Ray Milkey269ffb92014-04-03 14:43:30 -070063 * @param dstDpid the destination switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080064 * @param dstNumber the destination switch port number.
65 * @return the outgoing link if found, otherwise null.
66 */
67 public Link getLink(Long srcDpid, Long srcNumber, Long dstDpid,
Ray Milkey269ffb92014-04-03 14:43:30 -070068 Long dstNumber);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080069
70 /**
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080071 * Get all links in the network.
Ray Milkey269ffb92014-04-03 14:43:30 -070072 * <p/>
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080073 * TODO: Not clear if this method is needed. Remove if not used.
74 *
75 * @return all links in the network.
76 */
77 public Iterable<Link> getLinks();
78
79 /**
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080080 * Get the network device for a given MAC address.
81 *
82 * @param address the MAC address to use.
83 * @return the network device for the MAC address if found, otherwise null.
84 */
85 public Device getDeviceByMac(MACAddress address);
Ray Milkey269ffb92014-04-03 14:43:30 -070086
Jonathan Hart26f291b2014-02-18 16:57:24 -080087 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070088 * Acquire a read lock on the entire topology. The topology will not
89 * change while readers have the lock. Must be released using
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -080090 * {@link releaseReadLock()}. This method will block until a read lock is
Jonathan Hart26f291b2014-02-18 16:57:24 -080091 * available.
92 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -080093 public void acquireReadLock();
Ray Milkey269ffb92014-04-03 14:43:30 -070094
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080095 /**
96 * Release the read lock on the topology.
97 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -080098 public void releaseReadLock();
TeruU65bc5ff2014-04-23 22:22:32 -070099
100 public Iterable<Device> getDevices();
Jonathan Hart062a2e82014-02-03 09:41:57 -0800101}