blob: f57de38ff2ebd1c84f2f978dd72c17ef7d4d34b3 [file] [log] [blame]
Jonathan Hart472062d2014-04-03 10:56:48 -07001package net.onrc.onos.core.topology;
Jonathan Hart062a2e82014-02-03 09:41:57 -08002
3import java.util.Collection;
Yuta HIGUCHIa7f1cdd2014-06-09 15:05:20 -07004
5import net.onrc.onos.core.topology.web.serializers.SwitchSerializer;
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -07006import net.onrc.onos.core.util.Dpid;
7import net.onrc.onos.core.util.PortNumber;
Yuta HIGUCHIa7f1cdd2014-06-09 15:05:20 -07008
Pavlin Radoslavov1cbfcae2014-05-23 17:28:08 -07009import org.codehaus.jackson.map.annotate.JsonSerialize;
Jonathan Hart062a2e82014-02-03 09:41:57 -080010
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070011// TOOD Everything returned by these interfaces must be either Unmodifiable view,
12// immutable object, or a copy of the original "SB" In-memory Topology.
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080013/**
Jonathan Harte37e4e22014-05-13 19:12:02 -070014 * Interface of Switch object in the topology.
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080015 */
Pavlin Radoslavov1cbfcae2014-05-23 17:28:08 -070016@JsonSerialize(using = SwitchSerializer.class)
Yuta HIGUCHIdb1b8302014-06-26 10:50:39 -070017public interface Switch extends StringAttributes {
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070018
19 /**
20 * Gets the data path ID (dpid) of this switch.
21 *
22 * @return data path ID (dpid)
23 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070024 public Dpid getDpid();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080025
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070026 /**
27 * Gets all the ports on this switch.
28 *
29 * @return Collection of {@link Port} on this switch.
30 */
Ray Milkey269ffb92014-04-03 14:43:30 -070031 public Collection<Port> getPorts();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080032
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070033 /**
34 * Gets a port on switch by port number.
35 *
36 * @param number port number
37 * @return {@link Port} with {@code number} on this switch, or {@code null}
38 * if this switch did not have a port for specified port number
39 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070040 public Port getPort(PortNumber number);
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080041
Ray Milkey269ffb92014-04-03 14:43:30 -070042 // Graph traversal API
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070043
44 // XXX What is the Definition of neighbor? Link exist in both direction or
45 // one-way is sufficient to be a neighbor, etc.
46 /**
47 * Gets all the neighbor switches.
48 *
49 * @return neighbor switches
50 */
Ray Milkey269ffb92014-04-03 14:43:30 -070051 public Iterable<Switch> getNeighbors();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080052
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070053 /**
54 * Gets all the outgoing links.
55 *
56 * @return outgoing {@link Link}s from this switch.
57 */
Ray Milkey269ffb92014-04-03 14:43:30 -070058 public Iterable<Link> getOutgoingLinks();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080059
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070060 /**
61 * Gets all the incoming links.
62 *
63 * @return outgoing {@link Link}s from this switch.
64 */
Ray Milkey269ffb92014-04-03 14:43:30 -070065 public Iterable<Link> getIncomingLinks();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080066
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070067 /**
68 * Gets outgoing link to specified neighbor switch specified by dpid.
69 *
70 * @param dpid data path ID of neighbor switch.
71 * @return {@link Link} to neighbor switch {@code dpid} or {@code null} if
72 * link does not exist.
73 */
Yuta HIGUCHI8f3dfa32014-06-25 00:14:25 -070074 public Link getLinkToNeighbor(Dpid dpid);
Ray Milkey269ffb92014-04-03 14:43:30 -070075
76 // XXX Iterable or Collection?
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070077 /**
78 * Gets all the devices attached to this switch.
79 *
80 * @return {@link Device}s attached to this switch
81 */
Ray Milkey269ffb92014-04-03 14:43:30 -070082 public Collection<Device> getDevices();
Jonathan Hart062a2e82014-02-03 09:41:57 -080083}