use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class LabelAllocator method suggestedIdentifierBehavior.
// Implements suggestedIdentifier behavior
private Map<LinkKey, Identifier<?>> suggestedIdentifierBehavior(Set<LinkKey> links, EncapsulationType type, Identifier<?> suggested) {
// Init step
Map<LinkKey, Identifier<?>> ids = Maps.newHashMap();
Set<Identifier<?>> candidates;
Identifier<?> selected = null;
// Select the suggested if available on the whole path
for (LinkKey link : links) {
// Get candidates set for the current link
candidates = getCandidates(link, type);
// Otherwise select an other label for the current link
if (candidates.contains(suggested)) {
selected = suggested;
} else {
// If candidates is empty or does not contain suggested
log.warn("Suggested label {} is not available on link {}", suggested, link);
return Collections.emptyMap();
}
// Selected is associated to link
ids.put(link, selected);
}
return ids;
}
use of org.onosproject.net.LinkKey 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.LinkKey in project onos by opennetworkinglab.
the class SimpleLinkStoreTest method testGetEgressLinks.
@Test
public final void testGetEgressLinks() {
final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1);
LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3));
putLink(linkId1, DIRECT);
putLink(linkId2, DIRECT);
putLink(linkId3, DIRECT);
// DID1,P1 => DID2,P2
// DID2,P2 => DID1,P1
// DID1,P2 => DID2,P3
Set<Link> links1 = linkStore.getEgressLinks(d1P1);
assertEquals(1, links1.size());
assertLink(linkId1, DIRECT, links1.iterator().next());
Set<Link> links2 = linkStore.getEgressLinks(d2P2);
assertEquals(1, links2.size());
assertLink(linkId2, DIRECT, links2.iterator().next());
}
use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class SimpleLinkStoreTest method testDurableToNonDurable.
@Test
public void testDurableToNonDurable() {
final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
putLink(linkId1, DIRECT, DA1);
assertTrue("should be be durable", linkStore.getLink(d1P1, d2P2).isExpected());
putLink(linkId1, DIRECT, NDA1);
assertFalse("should not be durable", linkStore.getLink(d1P1, d2P2).isExpected());
}
use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class SimpleLinkStoreTest method testGetLinks.
@Test
public final void testGetLinks() {
assertEquals("initialy empty", 0, Iterables.size(linkStore.getLinks()));
LinkKey linkId1 = LinkKey.linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2));
LinkKey linkId2 = LinkKey.linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1));
putLink(linkId1, DIRECT);
putLink(linkId2, DIRECT);
putLink(linkId1, DIRECT);
assertEquals("expecting 2 unique link", 2, Iterables.size(linkStore.getLinks()));
Map<LinkKey, Link> links = new HashMap<>();
for (Link link : linkStore.getLinks()) {
links.put(LinkKey.linkKey(link), link);
}
assertLink(linkId1, DIRECT, links.get(linkId1));
assertLink(linkId2, DIRECT, links.get(linkId2));
}
Aggregations