use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.
the class SimpleLinkStore method composeLink.
// Guarded by linkDescs value (=locking each Link)
private Link composeLink(Map<ProviderId, LinkDescription> descs) {
ProviderId primary = getBaseProviderId(descs);
LinkDescription base = descs.get(verifyNotNull(primary));
ConnectPoint src = base.src();
ConnectPoint dst = base.dst();
Type type = base.type();
DefaultAnnotations annotations = DefaultAnnotations.builder().build();
annotations = merge(annotations, base.annotations());
for (Entry<ProviderId, LinkDescription> e : descs.entrySet()) {
if (primary.equals(e.getKey())) {
continue;
}
// TODO: should keep track of Description timestamp
// and only merge conflicting keys when timestamp is newer
// Currently assuming there will never be a key conflict between
// providers
// annotation merging. not so efficient, should revisit later
annotations = merge(annotations, e.getValue().annotations());
}
boolean isDurable = Objects.equals(annotations.value(AnnotationKeys.DURABLE), "true");
return DefaultLink.builder().providerId(primary).src(src).dst(dst).type(type).state(ACTIVE).isExpected(isDurable).annotations(annotations).build();
}
use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.
the class SimpleLinkStore method removeLink.
@Override
public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
final LinkKey key = linkKey(src, dst);
Map<ProviderId, LinkDescription> descs = getOrCreateLinkDescriptions(key);
synchronized (descs) {
Link link = links.remove(key);
descs.clear();
if (link != null) {
srcLinks.remove(link.src().deviceId(), key);
dstLinks.remove(link.dst().deviceId(), key);
return new LinkEvent(LINK_REMOVED, link);
}
return null;
}
}
use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.
the class BasicLinkOperatorTest method testDescOps.
@Test
public void testDescOps() {
LinkDescription desc = BasicLinkOperator.combine(BLC, LD);
assertEquals(String.valueOf(NTIME), desc.annotations().value(AnnotationKeys.LATENCY));
assertEquals("true", desc.annotations().value(AnnotationKeys.DURABLE));
}
use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.
the class ECLinkStore method removeLink.
@Override
public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
final LinkKey linkKey = LinkKey.linkKey(src, dst);
ProviderId primaryProviderId = getBaseProviderId(linkKey);
// Stop if there is no base provider.
if (primaryProviderId == null) {
return null;
}
LinkDescription removedLinkDescription = linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId));
if (removedLinkDescription != null) {
return purgeLinkCache(linkKey);
}
return null;
}
use of org.onosproject.net.link.LinkDescription in project onos by opennetworkinglab.
the class LinkDiscoveryAristaImpl method buildLinkPair.
private static Set<LinkDescription> buildLinkPair(DeviceId localDevId, Port localPort, DeviceId remoteDevId, Port remotePort) {
Set<LinkDescription> linkDescriptions = Sets.newHashSet();
ConnectPoint local = new ConnectPoint(localDevId, localPort.number());
ConnectPoint remote = new ConnectPoint(remoteDevId, remotePort.number());
DefaultAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.LAYER, "ETHERNET").build();
linkDescriptions.add(new DefaultLinkDescription(remote, local, Link.Type.DIRECT, true, annotations));
return linkDescriptions;
}
Aggregations