use of org.onosproject.segmentrouting.SRLinkWeigher in project trellis-control by opennetworkinglab.
the class DefaultL2TunnelHandler method getPath.
/**
* Returns the path betwwen two connect points.
*
* @param srcCp source connect point
* @param dstCp destination connect point
* @return the path
*/
private List<Link> getPath(ConnectPoint srcCp, ConnectPoint dstCp) {
// use SRLinkWeigher to avoid pair links, and also
// avoid going from the spine to the leaf and to the
// spine again, we need to have the leaf as CP1 here.
LinkWeigher srLw = new SRLinkWeigher(srManager, srcCp.deviceId(), new HashSet<Link>());
Set<Path> paths = srManager.topologyService.getPaths(srManager.topologyService.currentTopology(), srcCp.deviceId(), dstCp.deviceId(), srLw);
log.debug("Paths obtained from topology service {}", paths);
// We randomly pick a path.
if (paths.isEmpty()) {
return null;
}
int size = paths.size();
int index = RandomUtils.nextInt(0, size);
List<Link> result = Iterables.get(paths, index).links();
log.debug("Randomly picked a path {}", result);
return result;
}
use of org.onosproject.segmentrouting.SRLinkWeigher in project trellis-control by opennetworkinglab.
the class McastUtils method getPaths.
/**
* Gets path from src to dst computed using the custom link weigher.
*
* @param src source device ID
* @param dst destination device ID
* @param linksToEnforce links to be enforced
* @return list of paths from src to dst
*/
List<Path> getPaths(DeviceId src, DeviceId dst, Set<Link> linksToEnforce) {
final Topology currentTopology = topologyService.currentTopology();
final LinkWeigher linkWeigher = new SRLinkWeigher(srManager, src, linksToEnforce);
List<Path> allPaths = Lists.newArrayList(topologyService.getPaths(currentTopology, src, dst, linkWeigher));
log.trace("{} path(s) found from {} to {}", allPaths.size(), src, dst);
return allPaths;
}
Aggregations