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