Search in sources :

Example 16 with LinkKey

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());
}
Also used : LinkKey(org.onosproject.net.LinkKey) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) Test(org.junit.Test)

Example 17 with LinkKey

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());
}
Also used : LinkKey(org.onosproject.net.LinkKey) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) Test(org.junit.Test)

Example 18 with LinkKey

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);
}
Also used : LinkKey(org.onosproject.net.LinkKey) DeviceId(org.onosproject.net.DeviceId)

Example 19 with LinkKey

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;
}
Also used : LinkKey(org.onosproject.net.LinkKey) Identifier(org.onlab.util.Identifier)

Example 20 with LinkKey

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;
}
Also used : LinkKey(org.onosproject.net.LinkKey) Identifier(org.onlab.util.Identifier)

Aggregations

LinkKey (org.onosproject.net.LinkKey)61 Test (org.junit.Test)34 ConnectPoint (org.onosproject.net.ConnectPoint)31 Link (org.onosproject.net.Link)23 Identifier (org.onlab.util.Identifier)14 DeviceId (org.onosproject.net.DeviceId)9 Set (java.util.Set)7 MplsLabel (org.onlab.packet.MplsLabel)7 VlanId (org.onlab.packet.VlanId)7 LinkDescription (org.onosproject.net.link.LinkDescription)7 LinkEvent (org.onosproject.net.link.LinkEvent)7 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)6 ProviderId (org.onosproject.net.provider.ProviderId)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 FirstFitSelection (org.onosproject.net.resource.impl.LabelAllocator.FirstFitSelection)5 RandomSelection (org.onosproject.net.resource.impl.LabelAllocator.RandomSelection)5 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)4 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)4 BasicLinkConfig (org.onosproject.net.config.basics.BasicLinkConfig)4