blob: 9a4bf8cee81b3ad1ea24a3cf812e8ad4a580744d [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;
6
Pavlin Radoslavov1cbfcae2014-05-23 17:28:08 -07007import org.codehaus.jackson.map.annotate.JsonSerialize;
Jonathan Hart062a2e82014-02-03 09:41:57 -08008
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -07009// TOOD Everything returned by these interfaces must be either Unmodifiable view,
10// immutable object, or a copy of the original "SB" In-memory Topology.
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080011/**
Jonathan Harte37e4e22014-05-13 19:12:02 -070012 * Interface of Switch object in the topology.
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080013 */
Pavlin Radoslavov1cbfcae2014-05-23 17:28:08 -070014@JsonSerialize(using = SwitchSerializer.class)
Yuta HIGUCHIdb1b8302014-06-26 10:50:39 -070015public interface Switch extends StringAttributes {
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070016
17 /**
18 * Gets the data path ID (dpid) of this switch.
19 *
20 * @return data path ID (dpid)
21 */
Ray Milkey269ffb92014-04-03 14:43:30 -070022 public Long getDpid();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080023
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070024 /**
25 * Gets all the ports on this switch.
26 *
27 * @return Collection of {@link Port} on this switch.
28 */
Ray Milkey269ffb92014-04-03 14:43:30 -070029 public Collection<Port> getPorts();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080030
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070031 /**
32 * Gets a port on switch by port number.
33 *
34 * @param number port number
35 * @return {@link Port} with {@code number} on this switch, or {@code null}
36 * if this switch did not have a port for specified port number
37 */
Ray Milkey269ffb92014-04-03 14:43:30 -070038 public Port getPort(Long number);
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080039
Ray Milkey269ffb92014-04-03 14:43:30 -070040 // Graph traversal API
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070041
42 // XXX What is the Definition of neighbor? Link exist in both direction or
43 // one-way is sufficient to be a neighbor, etc.
44 /**
45 * Gets all the neighbor switches.
46 *
47 * @return neighbor switches
48 */
Ray Milkey269ffb92014-04-03 14:43:30 -070049 public Iterable<Switch> getNeighbors();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080050
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070051 /**
52 * Gets all the outgoing links.
53 *
54 * @return outgoing {@link Link}s from this switch.
55 */
Ray Milkey269ffb92014-04-03 14:43:30 -070056 public Iterable<Link> getOutgoingLinks();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080057
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070058 /**
59 * Gets all the incoming links.
60 *
61 * @return outgoing {@link Link}s from this switch.
62 */
Ray Milkey269ffb92014-04-03 14:43:30 -070063 public Iterable<Link> getIncomingLinks();
Yuta HIGUCHI181d34d2014-02-05 15:05:46 -080064
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070065 /**
66 * Gets outgoing link to specified neighbor switch specified by dpid.
67 *
68 * @param dpid data path ID of neighbor switch.
69 * @return {@link Link} to neighbor switch {@code dpid} or {@code null} if
70 * link does not exist.
71 */
Ray Milkey269ffb92014-04-03 14:43:30 -070072 public Link getLinkToNeighbor(Long dpid);
73
74 // XXX Iterable or Collection?
Yuta HIGUCHIce4a06b2014-04-25 19:37:57 -070075 /**
76 * Gets all the devices attached to this switch.
77 *
78 * @return {@link Device}s attached to this switch
79 */
Ray Milkey269ffb92014-04-03 14:43:30 -070080 public Collection<Device> getDevices();
Jonathan Hart062a2e82014-02-03 09:41:57 -080081}