use of org.openkilda.pce.exception.UnroutableFlowException in project open-kilda by telstra.
the class YFlowUpdateServiceTest method shouldFailIfNoPathAvailableForFirstSubFlow.
@Test
public void shouldFailIfNoPathAvailableForFirstSubFlow() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
// given
YFlowRequest request = createYFlow();
request.setMaximumBandwidth(2000L);
request.getSubFlows().get(0).setEndpoint(newFirstEndpoint);
request.getSubFlows().get(1).setEndpoint(newSecondEndpoint);
when(pathComputer.getPath(buildFlowIdArgumentMatch("test_flow_1"), any())).thenThrow(new UnroutableFlowException(injectedErrorMessage));
preparePathComputationForUpdate("test_flow_2", buildNewSecondSubFlowPathPair(), buildSecondSubFlowPathPair());
prepareYPointComputation(SWITCH_SHARED, SWITCH_NEW_FIRST_EP, SWITCH_NEW_SECOND_EP, SWITCH_TRANSIT);
// when
processUpdateRequestAndSpeakerCommands(request);
verifyNorthboundErrorResponse(yFlowUpdateHubCarrier, ErrorType.NOT_FOUND);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
YFlow flow = getYFlow(request.getYFlowId());
assertEquals(1000L, flow.getMaximumBandwidth());
Set<SwitchId> expectedEndpointSwitchIds = Stream.of(SWITCH_FIRST_EP, SWITCH_SECOND_EP).collect(Collectors.toSet());
Set<SwitchId> actualEndpointSwitchIds = flow.getSubFlows().stream().map(YSubFlow::getEndpointSwitchId).collect(Collectors.toSet());
assertEquals(expectedEndpointSwitchIds, actualEndpointSwitchIds);
}
use of org.openkilda.pce.exception.UnroutableFlowException in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateFlowIfNoPathAvailable.
@Test
public void shouldFailUpdateFlowIfNoPathAvailable() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
Flow origin = makeFlow();
when(pathComputer.getPath(makeFlowArgumentMatch(origin.getFlowId()), anyCollection())).thenThrow(new UnroutableFlowException(injectedErrorMessage));
FlowRequest request = makeRequest().flowId(origin.getFlowId()).bandwidth(origin.getBandwidth() + 1).build();
Flow result = testExpectedFailure(request, origin, ErrorType.NOT_FOUND);
Assert.assertEquals(origin.getBandwidth(), result.getBandwidth());
verify(pathComputer, times(11)).getPath(makeFlowArgumentMatch(origin.getFlowId()), any());
}
use of org.openkilda.pce.exception.UnroutableFlowException in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldFailRerouteFlowIfNoPathAvailable.
@Test
public void shouldFailRerouteFlowIfNoPathAvailable() throws RecoverableException, UnroutableFlowException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), new UnroutableFlowException(injectedErrorMessage));
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
testExpectedFailure(dummyRequestKey, request, commandContext, origin, FlowStatus.DOWN, ErrorType.NOT_FOUND);
verify(pathComputer, times(11)).getPath(makeFlowArgumentMatch(origin.getFlowId()), any());
}
use of org.openkilda.pce.exception.UnroutableFlowException 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());
}
use of org.openkilda.pce.exception.UnroutableFlowException 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