blob: 089d0e1d1cba2f91d651b63fc2f7317254a4d02b [file] [log] [blame]
Jonathan Hart472062d2014-04-03 10:56:48 -07001package net.onrc.onos.core.topology;
Jonathan Hart062a2e82014-02-03 09:41:57 -08002
Yuta HIGUCHIfa742842014-07-03 22:35:13 -07003import java.util.Collection;
4
Jonathan Hart062a2e82014-02-03 09:41:57 -08005import net.floodlightcontroller.util.MACAddress;
Yuta HIGUCHIa7f1cdd2014-06-09 15:05:20 -07006import net.onrc.onos.core.topology.web.serializers.TopologySerializer;
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -07007import net.onrc.onos.core.util.Dpid;
8import net.onrc.onos.core.util.PortNumber;
9import net.onrc.onos.core.util.SwitchPort;
Yuta HIGUCHIa7f1cdd2014-06-09 15:05:20 -070010
Ray Milkey0fe43852014-06-05 14:41:46 -070011import org.codehaus.jackson.map.annotate.JsonSerialize;
Jonathan Hart062a2e82014-02-03 09:41:57 -080012
13/**
Jonathan Harte37e4e22014-05-13 19:12:02 -070014 * The northbound interface to the topology. This interface
Jonathan Hart062a2e82014-02-03 09:41:57 -080015 * is presented to the rest of ONOS. It is currently read-only, as we want
16 * only the discovery modules to be allowed to modify the topology.
Jonathan Hart062a2e82014-02-03 09:41:57 -080017 */
Ray Milkey0fe43852014-06-05 14:41:46 -070018@JsonSerialize(using = TopologySerializer.class)
Jonathan Harte37e4e22014-05-13 19:12:02 -070019public interface Topology {
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070020
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080021 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070022 * Gets the switch for a given switch DPID.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080023 *
24 * @param dpid the switch dpid.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080025 * @return the switch if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080026 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070027 public Switch getSwitch(Dpid dpid);
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080028
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080029 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070030 * Gets all switches in the network.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080031 *
32 * @return all switches in the network.
33 */
34 public Iterable<Switch> getSwitches();
Yuta HIGUCHIc6174df2014-02-10 20:44:38 -080035
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080036 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070037 * Gets the port on a switch.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080038 *
Ray Milkey269ffb92014-04-03 14:43:30 -070039 * @param dpid the switch DPID.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080040 * @param number the switch port number.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080041 * @return the switch port if found, otherwise null.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080042 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070043 public Port getPort(Dpid dpid, PortNumber number);
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -080044
45 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070046 * Gets the port on a switch.
47 *
48 * @param port port identifier
49 * @return the switch port if found, otherwise null.
50 */
51 public Port getPort(SwitchPort port);
52
53 /**
Yuta HIGUCHIfa742842014-07-03 22:35:13 -070054 * Gets all ports on a switch specified.
55 *
56 * @param dpid Switch dpid
57 * @return ports.
58 */
59 public Collection<Port> getPorts(Dpid dpid);
60
61 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070062 * Gets the outgoing link from a switch port.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080063 *
Ray Milkey269ffb92014-04-03 14:43:30 -070064 * @param dpid the switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080065 * @param number the switch port number.
66 * @return the outgoing link if found, otherwise null.
67 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070068 public Link getOutgoingLink(Dpid dpid, PortNumber number);
Jonathan Hart25bd53e2014-04-30 23:44:09 -070069
70 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070071 * Gets the outgoing link from a switch port.
72 *
73 * @param port port identifier
74 * @return the switch port if found, otherwise null.
75 */
76 public Link getOutgoingLink(SwitchPort port);
77
78 /**
79 * Gets the incoming link to a switch port.
Jonathan Hart25bd53e2014-04-30 23:44:09 -070080 *
81 * @param dpid the switch DPID.
82 * @param number the switch port number.
83 * @return the incoming link if found, otherwise null.
84 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070085 public Link getIncomingLink(Dpid dpid, PortNumber number);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080086
87 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070088 * Gets the incoming link to a switch port.
89 *
90 * @param port port identifier
91 * @return the switch port if found, otherwise null.
92 */
93 public Link getIncomingLink(SwitchPort port);
94
95 /**
96 * Gets the outgoing link from a switch and a port to another switch and
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080097 * a port.
98 *
Ray Milkey269ffb92014-04-03 14:43:30 -070099 * @param srcDpid the source switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800100 * @param srcNumber the source switch port number.
Ray Milkey269ffb92014-04-03 14:43:30 -0700101 * @param dstDpid the destination switch DPID.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800102 * @param dstNumber the destination switch port number.
103 * @return the outgoing link if found, otherwise null.
104 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700105 public Link getLink(Dpid srcDpid, PortNumber srcNumber,
106 Dpid dstDpid, PortNumber dstNumber);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800107
108 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700109 * Gets all links in the network.
Ray Milkey269ffb92014-04-03 14:43:30 -0700110 * <p/>
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -0800111 * TODO: Not clear if this method is needed. Remove if not used.
112 *
113 * @return all links in the network.
114 */
115 public Iterable<Link> getLinks();
116
117 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700118 * Gets the network device for a given MAC address.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -0800119 *
120 * @param address the MAC address to use.
121 * @return the network device for the MAC address if found, otherwise null.
122 */
123 public Device getDeviceByMac(MACAddress address);
Ray Milkey269ffb92014-04-03 14:43:30 -0700124
Jonathan Hart26f291b2014-02-18 16:57:24 -0800125 /**
Yuta HIGUCHIfa742842014-07-03 22:35:13 -0700126 * Gets all devices in the network.
127 *
128 * @return all devices in the network
129 */
130 public Iterable<Device> getDevices();
131
132 /**
133 * Gets all devices on specified port.
134 *
135 * @param port port which the device is attached
136 * @return all devices attached to the port.
137 */
138 public Collection<Device> getDevices(SwitchPort port);
139
140 /**
Ray Milkey269ffb92014-04-03 14:43:30 -0700141 * Acquire a read lock on the entire topology. The topology will not
142 * change while readers have the lock. Must be released using
Sho SHIMIZUbfe4a452014-06-09 15:18:11 -0700143 * {@link #releaseReadLock()}. This method will block until a read lock is
Jonathan Hart26f291b2014-02-18 16:57:24 -0800144 * available.
145 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -0800146 public void acquireReadLock();
Ray Milkey269ffb92014-04-03 14:43:30 -0700147
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800148 /**
149 * Release the read lock on the topology.
150 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -0800151 public void releaseReadLock();
Jonathan Hart062a2e82014-02-03 09:41:57 -0800152}