Search in sources :

Example 21 with LinkKey

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

Example 22 with LinkKey

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;
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) LinkKey(org.onosproject.net.LinkKey) LinkEvent(org.onosproject.net.link.LinkEvent) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink)

Example 23 with LinkKey

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

Example 24 with LinkKey

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

Example 25 with LinkKey

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

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