blob: 74991c8a897b75a3478eec65271f86520a54e515 [file] [log] [blame]
tom80c0e5e2014-09-08 18:08:58 -07001package org.onlab.onos.net;
2
3import org.onlab.onos.net.provider.ProviderId;
4
5import static com.google.common.base.Preconditions.checkArgument;
6
7/**
8 * Default edge link model implementation.
9 */
10public 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
toma1d16b62014-10-02 23:45:11 -070021 * @param isIngress true to indicate host-to-network direction; false
tom80c0e5e2014-09-08 18:08:58 -070022 * for network-to-host direction
toma1d16b62014-10-02 23:45:11 -070023 * @param annotations optional key/value annotations
tom80c0e5e2014-09-08 18:08:58 -070024 */
25 public DefaultEdgeLink(ProviderId providerId, ConnectPoint hostPoint,
tomf5d85d42014-10-02 05:27:56 -070026 HostLocation hostLocation, boolean isIngress,
27 Annotations... annotations) {
tomcbefa232014-09-16 14:17:20 -070028 super(providerId, isIngress ? hostPoint : hostLocation,
tomf5d85d42014-10-02 05:27:56 -070029 isIngress ? hostLocation : hostPoint, Type.EDGE, annotations);
tom80c0e5e2014-09-08 18:08:58 -070030 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
tom568581d2014-09-08 20:13:36 -070042 public HostLocation hostLocation() {
tom80c0e5e2014-09-08 18:08:58 -070043 return hostLocation;
44 }
toma1d16b62014-10-02 23:45:11 -070045
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 }
tom80c0e5e2014-09-08 18:08:58 -070061}