use of org.openkilda.pce.model.FindOneDirectionPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinder method findPath.
private FindPathResult findPath(AvailableNetwork network, SwitchId startSwitchId, SwitchId endSwitchId, Supplier<FindOneDirectionPathResult> getPath) throws UnroutableFlowException {
Node start = network.getSwitch(startSwitchId);
Node end = network.getSwitch(endSwitchId);
if (start == null || end == null) {
throw new UnroutableFlowException(format("Switch %s doesn't have links with enough bandwidth", start == null ? startSwitchId : endSwitchId));
}
FindOneDirectionPathResult pathFindResult = getPath.get();
List<Edge> forwardPath = pathFindResult.getFoundPath();
if (forwardPath.isEmpty()) {
throw new UnroutableFlowException(format("Can't find a path from %s to %s", start, end));
}
List<Edge> reversePath = getReversePath(end, start, forwardPath);
if (reversePath.isEmpty()) {
throw new UnroutableFlowException(format("Can't find a reverse path from %s to %s. Forward path : %s", end, start, StringUtils.join(forwardPath, ", ")));
}
return FindPathResult.builder().foundPath(Pair.of(forwardPath, reversePath)).backUpPathComputationWayUsed(pathFindResult.isBackUpPathComputationWayUsed()).build();
}
Aggregations