use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class ECLinkStoreTest method testGetIngressLinks.
@Test
public final void testGetIngressLinks() {
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.getIngressLinks(d2P2);
assertEquals(1, links1.size());
assertLink(linkId1, DIRECT, links1.iterator().next());
Set<Link> links2 = linkStore.getIngressLinks(d1P1);
assertEquals(1, links2.size());
assertLink(linkId2, DIRECT, links2.iterator().next());
}
use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class ECLinkStoreTest 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 LinkProviderServiceAdapter method linkDetected.
@Override
public void linkDetected(LinkDescription linkDescription) {
LinkKey key = LinkKey.linkKey(linkDescription.src(), linkDescription.dst());
discoveredLinkDescriptions.put(key, linkDescription);
DeviceId sDid = linkDescription.src().deviceId();
DeviceId dDid = linkDescription.dst().deviceId();
discoveredLinks.put(sDid, dDid);
}
use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class LabelAllocator method noOptimizeBehavior.
// Implements NONE behavior
private Map<LinkKey, Identifier<?>> noOptimizeBehavior(Set<LinkKey> links, EncapsulationType type) {
// Init step
Map<LinkKey, Identifier<?>> ids = Maps.newHashMap();
Set<Identifier<?>> candidates;
Identifier<?> selected;
// Iterates for each link selecting a label in the candidate set
for (LinkKey link : links) {
// Get candidates set for the current link
candidates = getCandidates(link, type);
// Select a label for the current link
selected = labelSelection.select(candidates);
// If candidates is empty, selected is null
if (selected == null) {
log.warn("No labels for {}", 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 LabelAllocator method minSwapBehavior.
// Implements MIN_SWAP behavior
private Map<LinkKey, Identifier<?>> minSwapBehavior(Set<LinkKey> links, EncapsulationType type) {
// Init step
Map<LinkKey, Identifier<?>> ids = Maps.newHashMap();
Set<Identifier<?>> candidates;
Identifier<?> selected = null;
// Iterates for each link selecting a label in the candidate set
for (LinkKey link : links) {
// Get candidates set for the current link
candidates = getCandidates(link, type);
// If we are in the first link or selected is not available
if (selected == null || !candidates.contains(selected)) {
// Select a label for the current link
selected = labelSelection.select(candidates);
// If candidates is empty, selected is null
if (selected == null) {
log.warn("No labels for {}", link);
return Collections.emptyMap();
}
}
// Selected is associated to link
ids.put(link, selected);
}
return ids;
}
Aggregations