Search in sources :

Example 16 with FindPathResult

use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.

the class InMemoryPathComputer method getPath.

private GetPathsResult getPath(AvailableNetwork network, Flow flow, PathComputationStrategy strategy) throws UnroutableFlowException {
    if (flow.isOneSwitchFlow()) {
        log.info("No path computation for one-switch flow");
        SwitchId singleSwitchId = flow.getSrcSwitchId();
        return GetPathsResult.builder().forward(convertToPath(singleSwitchId, singleSwitchId, emptyList())).reverse(convertToPath(singleSwitchId, singleSwitchId, emptyList())).backUpPathComputationWayUsed(false).build();
    }
    WeightFunction weightFunction = getWeightFunctionByStrategy(strategy);
    FindPathResult findPathResult;
    try {
        findPathResult = findPathInNetwork(flow, network, weightFunction, strategy);
    } catch (UnroutableFlowException e) {
        String message = format("Failed to find path with requested bandwidth=%s: %s", flow.isIgnoreBandwidth() ? " ignored" : flow.getBandwidth(), e.getMessage());
        throw new UnroutableFlowException(message, e, flow.getFlowId(), flow.isIgnoreBandwidth());
    }
    return convertToGetPathsResult(flow.getSrcSwitchId(), flow.getDestSwitchId(), findPathResult, strategy, flow.getPathComputationStrategy());
}
Also used : WeightFunction(org.openkilda.pce.model.WeightFunction) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) FindPathResult(org.openkilda.pce.model.FindPathResult) SwitchId(org.openkilda.model.SwitchId)

Aggregations

FindPathResult (org.openkilda.pce.model.FindPathResult)16 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AvailableNetwork (org.openkilda.pce.impl.AvailableNetwork)5 SwitchId (org.openkilda.model.SwitchId)4 UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)1 Edge (org.openkilda.pce.model.Edge)1 WeightFunction (org.openkilda.pce.model.WeightFunction)1