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; |
Pavlin Radoslavov | 1cbfcae | 2014-05-23 17:28:08 -0700 | [diff] [blame] | 4 | import net.onrc.onos.core.topology.serializers.SwitchSerializer; |
| 5 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 6 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 7 | // 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 HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 9 | /** |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 10 | * Interface of Switch object in the topology. |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 11 | */ |
Pavlin Radoslavov | 1cbfcae | 2014-05-23 17:28:08 -0700 | [diff] [blame] | 12 | @JsonSerialize(using = SwitchSerializer.class) |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 13 | public interface Switch { |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 14 | |
| 15 | /** |
| 16 | * Gets the data path ID (dpid) of this switch. |
| 17 | * |
| 18 | * @return data path ID (dpid) |
| 19 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 20 | public Long getDpid(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 21 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Gets all the ports on this switch. |
| 24 | * |
| 25 | * @return Collection of {@link Port} on this switch. |
| 26 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 27 | public Collection<Port> getPorts(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 28 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 29 | /** |
| 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 36 | public Port getPort(Long number); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 37 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 38 | // Graph traversal API |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 39 | |
| 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 47 | public Iterable<Switch> getNeighbors(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 48 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 49 | /** |
| 50 | * Gets all the outgoing links. |
| 51 | * |
| 52 | * @return outgoing {@link Link}s from this switch. |
| 53 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 54 | public Iterable<Link> getOutgoingLinks(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 55 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 56 | /** |
| 57 | * Gets all the incoming links. |
| 58 | * |
| 59 | * @return outgoing {@link Link}s from this switch. |
| 60 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 61 | public Iterable<Link> getIncomingLinks(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 62 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 63 | /** |
| 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 Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 70 | public Link getLinkToNeighbor(Long dpid); |
| 71 | |
| 72 | // XXX Iterable or Collection? |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 73 | /** |
| 74 | * Gets all the devices attached to this switch. |
| 75 | * |
| 76 | * @return {@link Device}s attached to this switch |
| 77 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 78 | public Collection<Device> getDevices(); |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 79 | } |