blob: eee37ccc1f7c6934d4021782b5130feba0cf8af8 [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;
Yuta HIGUCHIa7f1cdd2014-06-09 15:05:20 -07004import net.onrc.onos.core.topology.web.serializers.TopologySerializer;
5
Ray Milkey0fe43852014-06-05 14:41:46 -07006import org.codehaus.jackson.map.annotate.JsonSerialize;
Jonathan Hart062a2e82014-02-03 09:41:57 -08007
8/**
Jonathan Harte37e4e22014-05-13 19:12:02 -07009 * The northbound interface to the topology. This interface
Jonathan Hart062a2e82014-02-03 09:41:57 -080010 * is presented to the rest of ONOS. It is currently read-only, as we want
11 * only the discovery modules to be allowed to modify the topology.
Jonathan Hart062a2e82014-02-03 09:41:57 -080012 */
Ray Milkey0fe43852014-06-05 14:41:46 -070013@JsonSerialize(using = TopologySerializer.class)
Jonathan Harte37e4e22014-05-13 19:12:02 -070014public interface Topology {
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080015 /**
16 * Get the switch for a given switch DPID.
17 *
18 * @param dpid the switch dpid.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080019 * @return the switch if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080020 */
21 public Switch getSwitch(Long dpid);
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080022
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080023 /**
24 * Get all switches in the network.
25 *
26 * @return all switches in the network.
27 */
28 public Iterable<Switch> getSwitches();
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080029
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080030 /**
31 * Get the port on a switch.
32 *
Ray Milkey269ffb92014-04-03 14:43:30 -070033 * @param dpid the switch DPID.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080034 * @param number the switch port number.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080035 * @return the switch port if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080036 */
37 public Port getPort(Long dpid, Long number);
38
39 /**
Jonathan Hart25bd53e2014-04-30 23:44:09 -070040 * Get the outgoing link from a switch port.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080041 *
Ray Milkey269ffb92014-04-03 14:43:30 -070042 * @param dpid the switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080043 * @param number the switch port number.
44 * @return the outgoing link if found, otherwise null.
45 */
Jonathan Hart25bd53e2014-04-30 23:44:09 -070046 public Link getOutgoingLink(Long dpid, Long number);
47 // TODO See if we should change <dpid, port_num> pairs to SwitchPort
48
49 /**
50 * Get the incoming link to a switch port.
51 *
52 * @param dpid the switch DPID.
53 * @param number the switch port number.
54 * @return the incoming link if found, otherwise null.
55 */
56 public Link getIncomingLink(Long dpid, Long number);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080057
58 /**
59 * Get the outgoing link from a switch and a port to another switch and
60 * a port.
61 *
Ray Milkey269ffb92014-04-03 14:43:30 -070062 * @param srcDpid the source switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080063 * @param srcNumber the source switch port number.
Ray Milkey269ffb92014-04-03 14:43:30 -070064 * @param dstDpid the destination switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080065 * @param dstNumber the destination switch port number.
66 * @return the outgoing link if found, otherwise null.
67 */
68 public Link getLink(Long srcDpid, Long srcNumber, Long dstDpid,
Ray Milkey269ffb92014-04-03 14:43:30 -070069 Long dstNumber);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080070
71 /**
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080072 * Get all links in the network.
Ray Milkey269ffb92014-04-03 14:43:30 -070073 * <p/>
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080074 * TODO: Not clear if this method is needed. Remove if not used.
75 *
76 * @return all links in the network.
77 */
78 public Iterable<Link> getLinks();
79
80 /**
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080081 * Get the network device for a given MAC address.
82 *
83 * @param address the MAC address to use.
84 * @return the network device for the MAC address if found, otherwise null.
85 */
86 public Device getDeviceByMac(MACAddress address);
Ray Milkey269ffb92014-04-03 14:43:30 -070087
Jonathan Hart26f291b2014-02-18 16:57:24 -080088 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070089 * Acquire a read lock on the entire topology. The topology will not
90 * change while readers have the lock. Must be released using
Sho SHIMIZUbfe4a452014-06-09 15:18:11 -070091 * {@link #releaseReadLock()}. This method will block until a read lock is
Jonathan Hart26f291b2014-02-18 16:57:24 -080092 * available.
93 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -080094 public void acquireReadLock();
Ray Milkey269ffb92014-04-03 14:43:30 -070095
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080096 /**
97 * Release the read lock on the topology.
98 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -080099 public void releaseReadLock();
TeruU65bc5ff2014-04-23 22:22:32 -0700100
101 public Iterable<Device> getDevices();
Jonathan Hart062a2e82014-02-03 09:41:57 -0800102}