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);
}
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());
}
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));
}
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();
}
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());
}
Aggregations