blob: 365b00df2038d65ec47c3b6ab6bf6e908605a0da [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;
Pavlin Radoslavov1cbfcae2014-05-23 17:28:08 -07004import net.onrc.onos.core.topology.serializers.SwitchSerializer;
5import org.codehaus.jackson.map.annotate.JsonSerialize;
Jonathan Hart062a2e82014-02-03 09:41:57 -08006
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -07007// TOOD Everything returned by these interfaces must be either Unmodifiable view,
8// immutable object, or a copy of the original "SB" In-memory Topology.
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -08009/**
Jonathan Harte37e4e22014-05-13 19:12:02 -070010 * Interface of Switch object in the topology.
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080011 */
Pavlin Radoslavov1cbfcae2014-05-23 17:28:08 -070012@JsonSerialize(using = SwitchSerializer.class)
Jonathan Hart062a2e82014-02-03 09:41:57 -080013public interface Switch {
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070014
15 /**
16 * Gets the data path ID (dpid) of this switch.
17 *
18 * @return data path ID (dpid)
19 */
Ray Milkey269ffb92014-04-03 14:43:30 -070020 public Long getDpid();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080021
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070022 /**
23 * Gets all the ports on this switch.
24 *
25 * @return Collection of {@link Port} on this switch.
26 */
Ray Milkey269ffb92014-04-03 14:43:30 -070027 public Collection<Port> getPorts();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080028
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070029 /**
30 * Gets a port on switch by port number.
31 *
32 * @param number port number
33 * @return {@link Port} with {@code number} on this switch, or {@code null}
34 * if this switch did not have a port for specified port number
35 */
Ray Milkey269ffb92014-04-03 14:43:30 -070036 public Port getPort(Long number);
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080037
Ray Milkey269ffb92014-04-03 14:43:30 -070038 // Graph traversal API
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070039
40 // XXX What is the Definition of neighbor? Link exist in both direction or
41 // one-way is sufficient to be a neighbor, etc.
42 /**
43 * Gets all the neighbor switches.
44 *
45 * @return neighbor switches
46 */
Ray Milkey269ffb92014-04-03 14:43:30 -070047 public Iterable<Switch> getNeighbors();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080048
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070049 /**
50 * Gets all the outgoing links.
51 *
52 * @return outgoing {@link Link}s from this switch.
53 */
Ray Milkey269ffb92014-04-03 14:43:30 -070054 public Iterable<Link> getOutgoingLinks();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080055
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070056 /**
57 * Gets all the incoming links.
58 *
59 * @return outgoing {@link Link}s from this switch.
60 */
Ray Milkey269ffb92014-04-03 14:43:30 -070061 public Iterable<Link> getIncomingLinks();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080062
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070063 /**
64 * Gets outgoing link to specified neighbor switch specified by dpid.
65 *
66 * @param dpid data path ID of neighbor switch.
67 * @return {@link Link} to neighbor switch {@code dpid} or {@code null} if
68 * link does not exist.
69 */
Ray Milkey269ffb92014-04-03 14:43:30 -070070 public Link getLinkToNeighbor(Long dpid);
71
72 // XXX Iterable or Collection?
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070073 /**
74 * Gets all the devices attached to this switch.
75 *
76 * @return {@link Device}s attached to this switch
77 */
Ray Milkey269ffb92014-04-03 14:43:30 -070078 public Collection<Device> getDevices();
Jonathan Hart062a2e82014-02-03 09:41:57 -080079}