Search in sources :

Example 41 with Path

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

the class PathManagerTest method infraToInfra.

@Test
public void infraToInfra() {
    DeviceId src = did("src");
    DeviceId dst = did("dst");
    fakeTopoMgr.paths.add(createPath("src", "middle", "dst"));
    Set<Path> paths = service.getPaths(src, dst);
    validatePaths(paths, 1, 2, src, dst);
    validatePaths(service.getKShortestPaths(src, dst).collect(Collectors.toSet()), 1, 2, src, dst);
}
Also used : Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) Test(org.junit.Test)

Example 42 with Path

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

the class TopologyManagerTest method onDemandPath.

@Test
public void onDemandPath() {
    submitTopologyGraph();
    Topology topology = service.currentTopology();
    LinkWeigher weight = new LinkWeigherAdapter(3.3);
    Set<Path> paths = service.getPaths(topology, did("a"), did("c"), weight);
    assertEquals("wrong path count", 2, paths.size());
    Path path = paths.iterator().next();
    assertEquals("wrong path length", 2, path.links().size());
    assertEquals("wrong path cost", ScalarWeight.toWeight(6.6), path.weight());
}
Also used : LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) Path(org.onosproject.net.Path) LinkWeigher(org.onosproject.net.topology.LinkWeigher) Topology(org.onosproject.net.topology.Topology) Test(org.junit.Test)

Example 43 with Path

use of org.onosproject.net.Path 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 44 with Path

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

the class DefaultTopology method getPaths.

/**
 * Computes on-demand the set of shortest paths between source and
 * destination devices, the set of returned paths will be no more than,
 * maxPaths in size.  The first {@code maxPaths} paths will be returned
 * maintaining any ordering guarantees provided by the underlying
 * (default or if no default is specified {@link DijkstraGraphSearch})
 * search. If returning all paths of a given length would exceed
 * {@code maxPaths} a subset of paths of that length will be returned,
 * which paths will be returned depends on the currently specified
 * {@code GraphPathSearch}. See {@link #setDefaultGraphPathSearch}.
 *
 * @param src      source device
 * @param dst      destination device
 * @param weigher  link weight function
 * @param maxPaths maximum number of paths
 * @return set of shortest paths
 */
public Set<Path> getPaths(DeviceId src, DeviceId dst, LinkWeigher weigher, int maxPaths) {
    DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
    DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
    Set<TopologyVertex> vertices = graph.getVertexes();
    if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
        // src or dst not part of the current graph
        return ImmutableSet.of();
    }
    GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = graphPathSearch().search(graph, srcV, dstV, weigher, maxPaths);
    ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
    for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
        builder.add(networkPath(path));
    }
    return builder.build();
}
Also used : DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) Path(org.onosproject.net.Path) DefaultPath(org.onosproject.net.DefaultPath) DisjointPath(org.onosproject.net.DisjointPath) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyVertex(org.onosproject.net.topology.TopologyVertex) ImmutableSet(com.google.common.collect.ImmutableSet) DefaultTopologyVertex(org.onosproject.net.topology.DefaultTopologyVertex) TopologyEdge(org.onosproject.net.topology.TopologyEdge) GraphPathSearch(org.onlab.graph.GraphPathSearch)

Example 45 with Path

use of org.onosproject.net.Path 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

Path (org.onosproject.net.Path)60 DeviceId (org.onosproject.net.DeviceId)27 DefaultPath (org.onosproject.net.DefaultPath)24 Link (org.onosproject.net.Link)23 DisjointPath (org.onosproject.net.DisjointPath)22 ConnectPoint (org.onosproject.net.ConnectPoint)18 Test (org.junit.Test)16 ImmutableSet (com.google.common.collect.ImmutableSet)12 ArrayList (java.util.ArrayList)11 List (java.util.List)11 Set (java.util.Set)11 Collectors (java.util.stream.Collectors)10 DefaultLink (org.onosproject.net.DefaultLink)10 Intent (org.onosproject.net.intent.Intent)10 Collections (java.util.Collections)9 Topology (org.onosproject.net.topology.Topology)8 Logger (org.slf4j.Logger)8 Stream (java.util.stream.Stream)7 ScalarWeight (org.onlab.graph.ScalarWeight)7 HostId (org.onosproject.net.HostId)7