Showing
7 changed files
with
122 additions
and
9 deletions
... | @@ -7,7 +7,7 @@ import java.util.Objects; | ... | @@ -7,7 +7,7 @@ import java.util.Objects; |
7 | import static com.google.common.base.Objects.toStringHelper; | 7 | import static com.google.common.base.Objects.toStringHelper; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | - * Default device model implementation. | 10 | + * Default infrastructure device model implementation. |
11 | */ | 11 | */ |
12 | public class DefaultDevice extends AbstractElement implements Device { | 12 | public class DefaultDevice extends AbstractElement implements Device { |
13 | 13 | ... | ... |
1 | +package org.onlab.onos.net; | ||
2 | + | ||
3 | +import org.onlab.onos.net.link.LinkDescription; | ||
4 | + | ||
5 | +import java.util.Objects; | ||
6 | + | ||
7 | +import static com.google.common.base.Objects.toStringHelper; | ||
8 | + | ||
9 | +/** | ||
10 | + * Default infrastructure link model implementation. | ||
11 | + */ | ||
12 | +public class DefaultLink implements LinkDescription { | ||
13 | + | ||
14 | + private ConnectPoint src; | ||
15 | + private ConnectPoint dst; | ||
16 | + | ||
17 | + /** | ||
18 | + * Creates a link description using the supplied information. | ||
19 | + * | ||
20 | + * @param src link source | ||
21 | + * @param dst link destination | ||
22 | + */ | ||
23 | + public DefaultLink(ConnectPoint src, ConnectPoint dst) { | ||
24 | + this.src = src; | ||
25 | + this.dst = dst; | ||
26 | + } | ||
27 | + | ||
28 | + @Override | ||
29 | + public ConnectPoint src() { | ||
30 | + return src; | ||
31 | + } | ||
32 | + | ||
33 | + @Override | ||
34 | + public ConnectPoint dst() { | ||
35 | + return dst; | ||
36 | + } | ||
37 | + | ||
38 | + | ||
39 | + @Override | ||
40 | + public int hashCode() { | ||
41 | + return Objects.hash(src, dst); | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public boolean equals(Object obj) { | ||
46 | + if (obj instanceof DefaultDevice) { | ||
47 | + final DefaultLink other = (DefaultLink) obj; | ||
48 | + return Objects.equals(this.src, other.src) && | ||
49 | + Objects.equals(this.dst, other.dst); | ||
50 | + } | ||
51 | + return false; | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + public String toString() { | ||
56 | + return toStringHelper(this) | ||
57 | + .add("src", src) | ||
58 | + .add("dst", dst) | ||
59 | + .toString(); | ||
60 | + } | ||
61 | + | ||
62 | +} |
... | @@ -4,7 +4,6 @@ package org.onlab.onos.net; | ... | @@ -4,7 +4,6 @@ package org.onlab.onos.net; |
4 | * Abstraction of a network infrastructure link. | 4 | * Abstraction of a network infrastructure link. |
5 | */ | 5 | */ |
6 | public interface Link extends Provided { | 6 | public interface Link extends Provided { |
7 | -// TODO: Consider extending graph Edge<Element> once the graph module is available | ||
8 | 7 | ||
9 | /** | 8 | /** |
10 | * Coarse representation of the link type. | 9 | * Coarse representation of the link type. | ... | ... |
1 | +package org.onlab.onos.net.link; | ||
2 | + | ||
3 | +import org.onlab.onos.net.ConnectPoint; | ||
4 | + | ||
5 | +/** | ||
6 | + * Default implementation of immutable link description entity. | ||
7 | + */ | ||
8 | +public class DefaultLinkDescription implements LinkDescription { | ||
9 | + | ||
10 | + private ConnectPoint src; | ||
11 | + private ConnectPoint dst; | ||
12 | + | ||
13 | + /** | ||
14 | + * Creates a link description using the supplied information. | ||
15 | + * | ||
16 | + * @param src link source | ||
17 | + * @param dst link destination | ||
18 | + */ | ||
19 | + public DefaultLinkDescription(ConnectPoint src, ConnectPoint dst) { | ||
20 | + this.src = src; | ||
21 | + this.dst = dst; | ||
22 | + } | ||
23 | + | ||
24 | + @Override | ||
25 | + public ConnectPoint src() { | ||
26 | + return src; | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public ConnectPoint dst() { | ||
31 | + return dst; | ||
32 | + } | ||
33 | + | ||
34 | +} |
1 | package org.onlab.onos.net.link; | 1 | package org.onlab.onos.net.link; |
2 | 2 | ||
3 | +import org.onlab.onos.net.ConnectPoint; | ||
4 | + | ||
3 | /** | 5 | /** |
4 | * Describes an infrastructure link. | 6 | * Describes an infrastructure link. |
5 | */ | 7 | */ |
6 | public interface LinkDescription { | 8 | public interface LinkDescription { |
7 | 9 | ||
8 | - // TODO: src, dst connection points, which are pairs of (DeviceId, PortNumber) | 10 | + /** |
9 | - | 11 | + * Returns the link source. |
10 | -// On the north: | 12 | + * |
11 | -// Link = (ConnectPoint src, ConnectPoint dst); | 13 | + * @return links source |
12 | -// ConnectPoint = (DeviceId, PortNumber); | 14 | + */ |
15 | + ConnectPoint src(); | ||
13 | 16 | ||
14 | -// On the south | 17 | + /** |
15 | -// LinkDescription ~ Link | 18 | + * Returns the link destination. |
19 | + * | ||
20 | + * @return links destination | ||
21 | + */ | ||
22 | + ConnectPoint dst(); | ||
16 | 23 | ||
24 | + // Add further link attributes | ||
17 | } | 25 | } | ... | ... |
... | @@ -34,6 +34,8 @@ public class SimpleLinkManager | ... | @@ -34,6 +34,8 @@ public class SimpleLinkManager |
34 | private final AbstractListenerRegistry<LinkEvent, LinkListener> | 34 | private final AbstractListenerRegistry<LinkEvent, LinkListener> |
35 | listenerRegistry = new AbstractListenerRegistry<>(); | 35 | listenerRegistry = new AbstractListenerRegistry<>(); |
36 | 36 | ||
37 | + private final SimpleLinkStore store = new SimpleLinkStore(); | ||
38 | + | ||
37 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 39 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
38 | private EventDeliveryService eventDispatcher; | 40 | private EventDeliveryService eventDispatcher; |
39 | 41 | ... | ... |
-
Please register or login to post a comment