Jonathan Hart | 472062d | 2014-04-03 10:56:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.topology; |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 2 | |
| 3 | import java.util.Collection; |
Yuta HIGUCHI | a7f1cdd | 2014-06-09 15:05:20 -0700 | [diff] [blame] | 4 | |
| 5 | import net.onrc.onos.core.topology.web.serializers.SwitchSerializer; |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 6 | import net.onrc.onos.core.util.Dpid; |
| 7 | import net.onrc.onos.core.util.PortNumber; |
Yuta HIGUCHI | a7f1cdd | 2014-06-09 15:05:20 -0700 | [diff] [blame] | 8 | |
Pavlin Radoslavov | 1cbfcae | 2014-05-23 17:28:08 -0700 | [diff] [blame] | 9 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 10 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 11 | // 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 HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 13 | /** |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 14 | * Interface of Switch object in the topology. |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 15 | */ |
Pavlin Radoslavov | 1cbfcae | 2014-05-23 17:28:08 -0700 | [diff] [blame] | 16 | @JsonSerialize(using = SwitchSerializer.class) |
Yuta HIGUCHI | 692e68e | 2014-07-09 18:08:02 -0700 | [diff] [blame] | 17 | public interface Switch extends ITopologyElement, StringAttributes { |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Gets the data path ID (dpid) of this switch. |
| 21 | * |
| 22 | * @return data path ID (dpid) |
| 23 | */ |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 24 | public Dpid getDpid(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 25 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Gets all the ports on this switch. |
| 28 | * |
| 29 | * @return Collection of {@link Port} on this switch. |
| 30 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 31 | public Collection<Port> getPorts(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 32 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 33 | /** |
| 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 HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 40 | public Port getPort(PortNumber number); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 41 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 42 | // Graph traversal API |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 43 | |
| 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 51 | public Iterable<Switch> getNeighbors(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 52 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 53 | /** |
| 54 | * Gets all the outgoing links. |
| 55 | * |
| 56 | * @return outgoing {@link Link}s from this switch. |
| 57 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 58 | public Iterable<Link> getOutgoingLinks(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 59 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 60 | /** |
| 61 | * Gets all the incoming links. |
| 62 | * |
| 63 | * @return outgoing {@link Link}s from this switch. |
| 64 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 65 | public Iterable<Link> getIncomingLinks(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 66 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 67 | /** |
| 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 HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 74 | public Link getLinkToNeighbor(Dpid dpid); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 75 | |
| 76 | // XXX Iterable or Collection? |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 77 | /** |
| 78 | * Gets all the devices attached to this switch. |
| 79 | * |
| 80 | * @return {@link Device}s attached to this switch |
| 81 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 82 | public Collection<Device> getDevices(); |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 83 | } |