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 | |
Yuta HIGUCHI | 8313f0b | 2014-07-09 16:36:03 -0700 | [diff] [blame] | 3 | import java.util.Collection; |
| 4 | |
Yuta HIGUCHI | a7f1cdd | 2014-06-09 15:05:20 -0700 | [diff] [blame] | 5 | import net.onrc.onos.core.topology.web.serializers.PortSerializer; |
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; |
Jonathan Hart | 25bd53e | 2014-04-30 23:44:09 -0700 | [diff] [blame] | 8 | import net.onrc.onos.core.util.SwitchPort; |
Yuta HIGUCHI | a7f1cdd | 2014-06-09 15:05:20 -0700 | [diff] [blame] | 9 | |
Pavlin Radoslavov | 1cbfcae | 2014-05-23 17:28:08 -0700 | [diff] [blame] | 10 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
Jonathan Hart | 25bd53e | 2014-04-30 23:44:09 -0700 | [diff] [blame] | 11 | |
| 12 | //TODO Everything returned by these interfaces must be either Unmodifiable view, |
| 13 | //immutable object, or a copy of the original "SB" In-memory Topology. |
| 14 | |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 15 | /** |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 16 | * Interface of Port object in the topology. |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 17 | */ |
Pavlin Radoslavov | 1cbfcae | 2014-05-23 17:28:08 -0700 | [diff] [blame] | 18 | @JsonSerialize(using = PortSerializer.class) |
Yuta HIGUCHI | 692e68e | 2014-07-09 18:08:02 -0700 | [diff] [blame] | 19 | public interface Port extends ITopologyElement, StringAttributes { |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Gets the data path ID (dpid) of the switch, which this port is on. |
| 23 | * |
| 24 | * @return data path ID (dpid) |
| 25 | */ |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 26 | public Dpid getDpid(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 27 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 28 | /** |
| 29 | * Gets the port number of this port. |
| 30 | * |
| 31 | * @return port number |
| 32 | */ |
Yuta HIGUCHI | 8f3dfa3 | 2014-06-25 00:14:25 -0700 | [diff] [blame] | 33 | public PortNumber getNumber(); |
Yuta HIGUCHI | 181d34d | 2014-02-05 15:05:46 -0800 | [diff] [blame] | 34 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 35 | /** |
Jonathan Hart | 25bd53e | 2014-04-30 23:44:09 -0700 | [diff] [blame] | 36 | * Gets a {@link SwitchPort} that represents this Port's dpid and port |
| 37 | * number. |
| 38 | * |
| 39 | * @return a SwitchPort representing the Port |
| 40 | */ |
| 41 | public SwitchPort asSwitchPort(); |
| 42 | |
| 43 | /** |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 44 | * Gets the hardware address of this port. |
| 45 | * <p/> |
| 46 | * TODO Not implemented yet. |
| 47 | * TODO Should return value type be Long? |
| 48 | * |
| 49 | * @return hardware address |
| 50 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 51 | public Long getHardwareAddress(); |
Yuta HIGUCHI | 4bfdd53 | 2014-02-07 13:47:36 -0800 | [diff] [blame] | 52 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 53 | /** |
| 54 | * Description of this port. |
| 55 | * <p/> |
| 56 | * TODO Not implemented yet. |
| 57 | * |
| 58 | * @return description of this port |
| 59 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 60 | public String getDescription(); |
| 61 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 62 | /** |
| 63 | * Gets the parent switch. |
| 64 | * |
| 65 | * @return {@link Switch} instance |
| 66 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 67 | public Switch getSwitch(); |
| 68 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 69 | /** |
| 70 | * Gets the outgoing link from this port. |
Yuta HIGUCHI | 8313f0b | 2014-07-09 16:36:03 -0700 | [diff] [blame] | 71 | * <p/> |
| 72 | * FIXME As a temporary workaround, it will look for type "packet" and |
| 73 | * returns it if found, else return whichever link is found first. |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 74 | * |
| 75 | * @return {@link Link} if there exist a outgoing link from this, |
| 76 | * {@code null} otherwise. |
| 77 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 78 | public Link getOutgoingLink(); |
| 79 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 80 | /** |
Yuta HIGUCHI | 8313f0b | 2014-07-09 16:36:03 -0700 | [diff] [blame] | 81 | * Gets the outgoing link from this port. |
| 82 | * |
| 83 | * @param type type of the link |
| 84 | * @return {@link Link} if there exist a outgoing link from this, |
| 85 | * {@code null} otherwise. |
| 86 | */ |
| 87 | public Link getOutgoingLink(String type); |
| 88 | |
| 89 | /** |
| 90 | * Gets all the outgoing links from this port. |
| 91 | * |
| 92 | * @return Collection of {@link Link}s |
| 93 | */ |
| 94 | public Collection<Link> getOutgoingLinks(); |
| 95 | |
| 96 | /** |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 97 | * Gets the incoming link to this port. |
Yuta HIGUCHI | 8313f0b | 2014-07-09 16:36:03 -0700 | [diff] [blame] | 98 | * <p/> |
| 99 | * FIXME As a temporary workaround, it will look for type "packet" and |
| 100 | * returns it if found, else return whichever link is found first. |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 101 | * |
| 102 | * @return {@link Link} if there exist a incoming link to this, {@code null} |
| 103 | * otherwise. |
| 104 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 105 | public Link getIncomingLink(); |
| 106 | |
Yuta HIGUCHI | 8313f0b | 2014-07-09 16:36:03 -0700 | [diff] [blame] | 107 | /** |
| 108 | * Gets the incoming link to this port. |
| 109 | * |
| 110 | * @param type type of the link |
| 111 | * @return {@link Link} if there exist a incoming link to this, {@code null} |
| 112 | * otherwise. |
| 113 | */ |
| 114 | public Link getIncomingLink(String type); |
| 115 | |
| 116 | /** |
| 117 | * Gets all the incoming links to this port. |
| 118 | * |
| 119 | * @return Collection of {@link Link}s |
| 120 | */ |
| 121 | public Collection<Link> getIncomingLinks(); |
| 122 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 123 | // XXX Iterable or Collection? |
| 124 | /** |
| 125 | * Gets all the devices attached to this port. |
| 126 | * |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame^] | 127 | * @return {@link Host}s attached to this port |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 128 | */ |
Yuta HIGUCHI | bfc77f0 | 2014-07-14 22:50:25 -0700 | [diff] [blame^] | 129 | public Iterable<Host> getHosts(); |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 130 | } |