Search in sources :

Example 11 with DisjointPath

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

the class VirtualNetworkTopologyManagerTest method testGetDisjointPaths.

/**
 * Test getDisjointPaths() methods.
 */
@Test
public void testGetDisjointPaths() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
    // test the getDisjointPaths() method.
    Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id());
    assertNotNull("The paths should not be null.", paths);
    assertEquals("The paths size did not match.", 1, paths.size());
    // test the getDisjointPaths() method using a weight.
    LinkWeigher weight = new LinkWeigherAdapter(1.0);
    Set<DisjointPath> paths1 = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), weight);
    assertNotNull("The paths should not be null.", paths1);
    assertEquals("The paths size did not match.", 1, paths1.size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) LinkWeigher(org.onosproject.net.topology.LinkWeigher) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) DisjointPath(org.onosproject.net.DisjointPath) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 12 with DisjointPath

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

the class VirtualNetworkTopologyManagerTest method testGetDisjointPathsUsingNullDstDeviceId.

/**
 * Test getDisjointPaths() methods using a null dst device identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetDisjointPathsUsingNullDstDeviceId() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
    // test the getDisjointPaths() method using a null dst device identifier.
    Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) DisjointPath(org.onosproject.net.DisjointPath) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 13 with DisjointPath

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

the class AbstractPathServiceTest method checkDisjointPaths.

private void checkDisjointPaths(Set<DisjointPath> paths) {
    assertThat(paths, notNullValue());
    assertThat(paths, hasSize(1));
    Path path = paths.iterator().next();
    checkPathValues(path);
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath)

Example 14 with DisjointPath

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

the class AbstractPathService method edgeToEdgePathD.

// Produces a direct edge-to-edge path.
private DisjointPath edgeToEdgePathD(EdgeLink srcLink, EdgeLink dstLink, DisjointPath path, LinkWeigher weigher) {
    Path primary = null;
    Path backup = null;
    if (path != null) {
        primary = path.primary();
        backup = path.backup();
    }
    if (backup == null) {
        return new DefaultDisjointPath(PID, (DefaultPath) edgeToEdgePath(srcLink, dstLink, primary, weigher));
    }
    return new DefaultDisjointPath(PID, (DefaultPath) edgeToEdgePath(srcLink, dstLink, primary, weigher), (DefaultPath) edgeToEdgePath(srcLink, dstLink, backup, weigher));
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath)

Example 15 with DisjointPath

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

the class VirtualNetworkPathManagerTest method testGetPathsOnNonEmptyVnet.

/**
 * Tests getPaths(), getDisjointPaths()
 * on a non-empty virtual network.
 */
@Test
public void testGetPathsOnNonEmptyVnet() {
    VirtualNetwork vnet = setupVnet();
    PathService pathService = manager.get(vnet.id(), PathService.class);
    // src and dest are in vnet and are connected by a virtual link
    Set<Path> paths = pathService.getPaths(DID1, DID3);
    validatePaths(paths, 1, 1, DID1, DID3, 1.0);
    LinkWeigher linkWeight = new LinkWeigherAdapter(2.0);
    paths = pathService.getPaths(DID1, DID3, linkWeight);
    validatePaths(paths, 1, 1, DID1, DID3, 2.0);
    Set<DisjointPath> disjointPaths = pathService.getDisjointPaths(DID1, DID3);
    validatePaths(disjointPaths, 1, 1, DID1, DID3, 1.0);
    disjointPaths = pathService.getDisjointPaths(DID1, DID3, linkWeight);
    validatePaths(disjointPaths, 1, 1, DID1, DID3, 2.0);
    // src and dest are in vnet but are not connected
    paths = pathService.getPaths(DID4, DID3);
    assertEquals("incorrect path count", 0, paths.size());
    disjointPaths = pathService.getDisjointPaths(DID4, DID3);
    assertEquals("incorrect path count", 0, disjointPaths.size());
    // src is in vnet, but dest is not in vnet.
    DeviceId nonExistentDeviceId = DeviceId.deviceId("nonExistentDevice");
    paths = pathService.getPaths(DID2, nonExistentDeviceId);
    assertEquals("incorrect path count", 0, paths.size());
    disjointPaths = pathService.getDisjointPaths(DID2, nonExistentDeviceId);
    assertEquals("incorrect path count", 0, disjointPaths.size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) PathService(org.onosproject.net.topology.PathService) LinkWeigher(org.onosproject.net.topology.LinkWeigher) DeviceId(org.onosproject.net.DeviceId) DisjointPath(org.onosproject.net.DisjointPath) Test(org.junit.Test)

Aggregations

DisjointPath (org.onosproject.net.DisjointPath)19 Test (org.junit.Test)7 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)7 Path (org.onosproject.net.Path)7 DefaultDisjointPath (org.onosproject.net.DefaultDisjointPath)6 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)5 Topology (org.onosproject.net.topology.Topology)5 TopologyService (org.onosproject.net.topology.TopologyService)5 DefaultPath (org.onosproject.net.DefaultPath)4 DeviceId (org.onosproject.net.DeviceId)4 EdgeLink (org.onosproject.net.EdgeLink)3 Link (org.onosproject.net.Link)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 ArrayList (java.util.ArrayList)2 GraphPathSearch (org.onlab.graph.GraphPathSearch)2 DefaultEdgeLink (org.onosproject.net.DefaultEdgeLink)2 Intent (org.onosproject.net.intent.Intent)2 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)2 DefaultTopologyVertex (org.onosproject.net.topology.DefaultTopologyVertex)2 LinkWeigher (org.onosproject.net.topology.LinkWeigher)2