Search in sources :

Example 6 with ElementId

use of org.onosproject.net.ElementId in project onos by opennetworkinglab.

the class ComparatorsTest method testElementIdComparator.

@Test
public void testElementIdComparator() {
    ElementId elementid1 = new ElementId() {
    };
    ElementId elementid2 = elementid1;
    ElementId elementid3 = new ElementId() {
    };
    while (elementid1 == elementid3) {
        elementid3 = new ElementId() {
        };
    }
    assertTrue(0 == ELEMENT_ID_COMPARATOR.compare(elementid1, elementid2));
    assertFalse(0 == ELEMENT_ID_COMPARATOR.compare(elementid3, elementid1));
}
Also used : ElementId(org.onosproject.net.ElementId) Test(org.junit.Test)

Example 7 with ElementId

use of org.onosproject.net.ElementId in project onos by opennetworkinglab.

the class MockLinkService method addLink.

public void addLink(String device, long port, String device2, long port2) {
    ElementId d1;
    if (device.charAt(0) == 'H') {
        device = device.substring(1, device.length());
        d1 = HostId.hostId(device);
    } else {
        d1 = DeviceId.deviceId(device);
    }
    ElementId d2;
    if (device2.charAt(0) == 'H') {
        d2 = HostId.hostId(device2.substring(1, device2.length()));
    } else {
        d2 = DeviceId.deviceId(device2);
    }
    ConnectPoint src = new ConnectPoint(d1, PortNumber.portNumber(port));
    ConnectPoint dst = new ConnectPoint(d2, PortNumber.portNumber(port2));
    Link curLink;
    curLink = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).build();
    links.add(curLink);
    if (d1 instanceof DeviceId && d2 instanceof DeviceId) {
        TopologyVertex v1 = () -> (DeviceId) d1, v2 = () -> (DeviceId) d2;
        createdGraph.addVertex(v1);
        createdGraph.addVertex(v2);
        createdGraph.addEdge(new TopologyEdge() {

            @Override
            public Link link() {
                return curLink;
            }

            @Override
            public TopologyVertex src() {
                return v1;
            }

            @Override
            public TopologyVertex dst() {
                return v2;
            }
        });
    }
}
Also used : TopologyVertex(org.onosproject.net.topology.TopologyVertex) DeviceId(org.onosproject.net.DeviceId) ConnectPoint(org.onosproject.net.ConnectPoint) TopologyEdge(org.onosproject.net.topology.TopologyEdge) ElementId(org.onosproject.net.ElementId) DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link)

Aggregations

ElementId (org.onosproject.net.ElementId)7 ConnectPoint (org.onosproject.net.ConnectPoint)6 PortNumber (org.onosproject.net.PortNumber)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Test (org.junit.Test)1 DefaultLink (org.onosproject.net.DefaultLink)1 DeviceId (org.onosproject.net.DeviceId)1 Link (org.onosproject.net.Link)1 TopologyEdge (org.onosproject.net.topology.TopologyEdge)1 TopologyVertex (org.onosproject.net.topology.TopologyVertex)1 TapiResolver (org.onosproject.odtn.TapiResolver)1 TapiNepRef (org.onosproject.odtn.utils.tapi.TapiNepRef)1 TapiNodeRef (org.onosproject.odtn.utils.tapi.TapiNodeRef)1 Activate (org.osgi.service.component.annotations.Activate)1