Search in sources :

Example 1 with FindOneDirectionPathResult

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();
}
Also used : Node(org.openkilda.pce.model.Node) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) FindOneDirectionPathResult(org.openkilda.pce.model.FindOneDirectionPathResult) Edge(org.openkilda.pce.model.Edge)

Aggregations

UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)1 Edge (org.openkilda.pce.model.Edge)1 FindOneDirectionPathResult (org.openkilda.pce.model.FindOneDirectionPathResult)1 Node (org.openkilda.pce.model.Node)1