blob: 4e1b61e7e65da3412accb2ec57f1b10d49cfd53c [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.
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -070040 * @param portNumber 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 HIGUCHIcd14dda2014-07-24 09:57:22 -070043 public Port getPort(Dpid dpid, PortNumber portNumber);
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.
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -070063 * <p/>
64 * FIXME As a temporary workaround, it will look for type "packet" and
65 * returns it if found, else return whichever link is found first.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080066 *
Ray Milkey269ffb92014-04-03 14:43:30 -070067 * @param dpid the switch DPID.
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -070068 * @param portNumber the switch port number.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -080069 * @return the outgoing link if found, otherwise null.
70 */
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -070071 public Link getOutgoingLink(Dpid dpid, PortNumber portNumber);
Jonathan Hart25bd53e2014-04-30 23:44:09 -070072
73 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070074 * Gets the outgoing link from a switch port.
75 *
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -070076 * @param dpid the switch DPID.
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -070077 * @param portNumber the switch port number.
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -070078 * @param type type of the link
79 * @return the outgoing link if found, otherwise null.
80 */
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -070081 public Link getOutgoingLink(Dpid dpid, PortNumber portNumber, String type);
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -070082
83 /**
84 * Gets the outgoing link from a switch port.
85 * <p/>
86 * FIXME As a temporary workaround, it will look for type "packet" and
87 * returns it if found, else return whichever link is found first.
88 *
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070089 * @param port port identifier
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -070090 * @return the outgoing link if found, otherwise null.
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070091 */
92 public Link getOutgoingLink(SwitchPort port);
93
94 /**
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -070095 * Gets the outgoing link from a switch port.
96 *
97 * @param port port identifier
98 * @param type type of the link
99 * @return the outgoing link if found, otherwise null.
100 */
101 public Link getOutgoingLink(SwitchPort port, String type);
102
103 /**
104 * Gets all the outgoing link from a switch port.
105 *
106 * @param port port identifier
107 * @return outgoing links
108 */
109 public Collection<Link> getOutgoingLinks(SwitchPort port);
110
111 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700112 * Gets the incoming link to a switch port.
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700113 * <p/>
114 * FIXME As a temporary workaround, it will look for type "packet" and
115 * returns it if found, else return whichever link is found first.
Jonathan Hart25bd53e2014-04-30 23:44:09 -0700116 *
117 * @param dpid the switch DPID.
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700118 * @param portNumber the switch port number.
Jonathan Hart25bd53e2014-04-30 23:44:09 -0700119 * @return the incoming link if found, otherwise null.
120 */
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700121 public Link getIncomingLink(Dpid dpid, PortNumber portNumber);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800122
123 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700124 * Gets the incoming link to a switch port.
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700125 * <p/>
126 * FIXME As a temporary workaround, it will look for type "packet" and
127 * returns it if found, else return whichever link is found first.
128 *
129 * @param dpid the switch DPID.
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700130 * @param portNumber the switch port number.
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700131 * @param type type of the link
132 * @return the incoming link if found, otherwise null.
133 */
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700134 public Link getIncomingLink(Dpid dpid, PortNumber portNumber, String type);
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700135
136
137 /**
138 * Gets the incoming link to a switch port.
139 * <p/>
140 * FIXME As a temporary workaround, it will look for type "packet" and
141 * returns it if found, else return whichever link is found first.
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700142 *
143 * @param port port identifier
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700144 * @return the incoming link if found, otherwise null.
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700145 */
146 public Link getIncomingLink(SwitchPort port);
147
148 /**
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700149 * Gets the incoming link to a switch port.
150 *
151 * @param port port identifier
152 * @param type type of the link
153 * @return the incoming link if found, otherwise null.
154 */
155 public Link getIncomingLink(SwitchPort port, String type);
156
157 /**
158 * Gets all the incoming link from a switch port.
159 *
160 * @param port port identifier
161 * @return incoming links
162 */
163 public Collection<Link> getIncomingLinks(SwitchPort port);
164
165 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700166 * Gets the outgoing link from a switch and a port to another switch and
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800167 * a port.
168 *
Ray Milkey269ffb92014-04-03 14:43:30 -0700169 * @param srcDpid the source switch DPID.
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700170 * @param srcPortNumber the source switch port number.
Ray Milkey269ffb92014-04-03 14:43:30 -0700171 * @param dstDpid the destination switch DPID.
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700172 * @param dstPortNumber the destination switch port number.
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800173 * @return the outgoing link if found, otherwise null.
174 */
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700175 public Link getLink(Dpid srcDpid, PortNumber srcPortNumber,
176 Dpid dstDpid, PortNumber dstPortNumber);
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800177
178 /**
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700179 * Gets the outgoing link from a switch and a port to another switch and
180 * a port.
181 *
182 * @param srcDpid the source switch DPID.
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700183 * @param srcPortNumber the source switch port number.
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700184 * @param dstDpid the destination switch DPID.
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700185 * @param dstPortNumber the destination switch port number.
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700186 * @param type type of the link
187 * @return the outgoing link if found, otherwise null.
188 */
Yuta HIGUCHIcd14dda2014-07-24 09:57:22 -0700189 public Link getLink(Dpid srcDpid, PortNumber srcPortNumber,
190 Dpid dstDpid, PortNumber dstPortNumber,
Yuta HIGUCHI8313f0b2014-07-09 16:36:03 -0700191 String type);
192
193 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700194 * Gets all links in the network.
Ray Milkey269ffb92014-04-03 14:43:30 -0700195 * <p/>
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -0800196 *
197 * @return all links in the network.
198 */
199 public Iterable<Link> getLinks();
200
201 /**
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -0700202 * Gets the network device for a given MAC address.
Pavlin Radoslavov06df22a2014-02-18 19:16:27 -0800203 *
204 * @param address the MAC address to use.
205 * @return the network device for the MAC address if found, otherwise null.
206 */
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -0700207 public Host getHostByMac(MACAddress address);
Ray Milkey269ffb92014-04-03 14:43:30 -0700208
Jonathan Hart26f291b2014-02-18 16:57:24 -0800209 /**
Yuta HIGUCHIfa742842014-07-03 22:35:13 -0700210 * Gets all devices in the network.
211 *
212 * @return all devices in the network
213 */
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -0700214 public Iterable<Host> getHosts();
Yuta HIGUCHIfa742842014-07-03 22:35:13 -0700215
216 /**
217 * Gets all devices on specified port.
218 *
219 * @param port port which the device is attached
220 * @return all devices attached to the port.
221 */
Yuta HIGUCHIbfc77f02014-07-14 22:50:25 -0700222 public Collection<Host> getHosts(SwitchPort port);
Yuta HIGUCHIfa742842014-07-03 22:35:13 -0700223
224 /**
Ray Milkey269ffb92014-04-03 14:43:30 -0700225 * Acquire a read lock on the entire topology. The topology will not
226 * change while readers have the lock. Must be released using
Sho SHIMIZUbfe4a452014-06-09 15:18:11 -0700227 * {@link #releaseReadLock()}. This method will block until a read lock is
Jonathan Hart26f291b2014-02-18 16:57:24 -0800228 * available.
229 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -0800230 public void acquireReadLock();
Ray Milkey269ffb92014-04-03 14:43:30 -0700231
Pavlin Radoslavov7c8f69a2014-02-19 19:01:45 -0800232 /**
233 * Release the read lock on the topology.
234 */
Pavlin Radoslavov8ffb8bf2014-02-20 15:34:26 -0800235 public void releaseReadLock();
Jonathan Hart062a2e82014-02-03 09:41:57 -0800236}