tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net; |
| 2 | |
| 3 | import org.onlab.onos.net.provider.ProviderId; |
| 4 | |
| 5 | import static com.google.common.base.Preconditions.checkArgument; |
| 6 | |
| 7 | /** |
| 8 | * Default edge link model implementation. |
| 9 | */ |
| 10 | public class DefaultEdgeLink extends DefaultLink implements EdgeLink { |
| 11 | |
| 12 | private final HostId hostId; |
| 13 | private final HostLocation hostLocation; |
| 14 | |
| 15 | /** |
| 16 | * Creates an edge link using the supplied information. |
| 17 | * |
| 18 | * @param providerId provider identity |
| 19 | * @param hostPoint host-side connection point |
| 20 | * @param hostLocation location where host attaches to the network |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame^] | 21 | * @param isIngress true to indicate host-to-network direction; false |
tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 22 | * for network-to-host direction |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame^] | 23 | * @param annotations optional key/value annotations |
tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 24 | */ |
| 25 | public DefaultEdgeLink(ProviderId providerId, ConnectPoint hostPoint, |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 26 | HostLocation hostLocation, boolean isIngress, |
| 27 | Annotations... annotations) { |
tom | cbefa23 | 2014-09-16 14:17:20 -0700 | [diff] [blame] | 28 | super(providerId, isIngress ? hostPoint : hostLocation, |
tom | f5d85d4 | 2014-10-02 05:27:56 -0700 | [diff] [blame] | 29 | isIngress ? hostLocation : hostPoint, Type.EDGE, annotations); |
tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 30 | checkArgument(hostPoint.elementId() instanceof HostId, |
| 31 | "Host point does not refer to a host ID"); |
| 32 | this.hostId = (HostId) hostPoint.elementId(); |
| 33 | this.hostLocation = hostLocation; |
| 34 | } |
| 35 | |
| 36 | @Override |
| 37 | public HostId hostId() { |
| 38 | return hostId; |
| 39 | } |
| 40 | |
| 41 | @Override |
tom | 568581d | 2014-09-08 20:13:36 -0700 | [diff] [blame] | 42 | public HostLocation hostLocation() { |
tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 43 | return hostLocation; |
| 44 | } |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame^] | 45 | |
| 46 | /** |
| 47 | * Creates a phantom edge link, to an unspecified end-station. This link |
| 48 | * does not represent any actually discovered link stored in the system. |
| 49 | * |
| 50 | * @param edgePort network edge port |
| 51 | * @param isIngress true to indicate host-to-network direction; false |
| 52 | * for network-to-host direction |
| 53 | * @return new phantom edge link |
| 54 | */ |
| 55 | public static DefaultEdgeLink createEdgeLink(HostLocation edgePort, |
| 56 | boolean isIngress) { |
| 57 | return new DefaultEdgeLink(ProviderId.NONE, |
| 58 | new ConnectPoint(HostId.NONE, PortNumber.P0), |
| 59 | edgePort, isIngress); |
| 60 | } |
tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 61 | } |