use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method maxWeightStratAccountsForBothLinkDirections.
private FindPathResult maxWeightStratAccountsForBothLinkDirections(long maxWeight, long backUpMaxWeight) throws UnroutableFlowException {
// given 2 paths with costs: path1 forward 100, path1 reverse 102, path2 forward 101, path2 reverse 100
AvailableNetwork network = new AvailableNetwork();
addLink(network, SWITCH_ID_1, SWITCH_ID_2, 1, 1, 100, 0, false, false);
addLink(network, SWITCH_ID_2, SWITCH_ID_1, 1, 1, 102, 0, false, false);
addLink(network, SWITCH_ID_1, SWITCH_ID_2, 2, 2, 101, 0, false, false);
addLink(network, SWITCH_ID_2, SWITCH_ID_1, 2, 2, 100, 0, false, false);
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(ALLOWED_DEPTH);
// when: request a path with maxWeight 103
FindPathResult pathResult = pathFinder.findPathWithWeightCloseToMaxWeight(network, SWITCH_ID_1, SWITCH_ID_2, WEIGHT_FUNCTION, maxWeight, backUpMaxWeight);
Pair<List<Edge>, List<Edge>> pairPath = pathResult.getFoundPath();
// then: pick path1, because its reverse cost is 102 which is the closest to 103
// system skips path2 even though its forward cost is 101, which is closer to 103 than 100 (path1 forward)
assertThat(pairPath.getLeft().get(0).getSrcPort(), equalTo(1));
assertThat(pairPath.getRight().get(0).getSrcPort(), equalTo(1));
return pathResult;
}
use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldReturnThePathClosestToMaxWeight.
/**
* System picks path closest to maxWeight. Omit too cheap path, omit equal to maxWeight path
*/
@Test
public void shouldReturnThePathClosestToMaxWeight() throws UnroutableFlowException {
// a path with maxWeight 201
FindPathResult pathResult = findThePathClosestToMaxWeight(201L, Long.MAX_VALUE);
assertFalse(pathResult.isBackUpPathComputationWayUsed());
}
use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method addIntermediateSwitchWeightOnceMaxWeightStrategy.
private FindPathResult addIntermediateSwitchWeightOnceMaxWeightStrategy(long maxWeight, long backUpMaxWeight) throws UnroutableFlowException {
// given 3 paths that cost: 198, 200, 201
AvailableNetwork network = buildThreePathsNetwork();
// switch on '200' path has a diversity weight increase
network.getSwitch(SWITCH_ID_3).increaseDiversityGroupUseCounter();
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(ALLOWED_DEPTH);
// when: request a path with maxWeight 201
FindPathResult pathResult = pathFinder.findPathWithWeightCloseToMaxWeight(network, SWITCH_ID_1, SWITCH_ID_5, WEIGHT_FUNCTION, maxWeight, backUpMaxWeight);
Pair<List<Edge>, List<Edge>> pairPath = pathResult.getFoundPath();
// then: system picks 198 path (since 200 path is no longer '200' due to diversity weight rise)
List<SwitchId> forwardSwitches = getInvolvedSwitches(pairPath.getLeft());
assertThat(forwardSwitches, equalTo(Arrays.asList(SWITCH_ID_1, SWITCH_ID_2, SWITCH_ID_5)));
assertThat(getInvolvedSwitches(pairPath.getRight()), equalTo(Lists.reverse(forwardSwitches)));
return pathResult;
}
use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method backUpMaxWeightAccountsForBothLinkDirections.
/**
* Check that we take into account both forward-way and reverse-way links when calculating path using MAX_LATENCY
* strategy when backUpMaxWeight satisfies the path.
*/
@Test
public void backUpMaxWeightAccountsForBothLinkDirections() throws UnroutableFlowException {
// a path with backUpMaxWeight 103
FindPathResult pathResult = maxWeightStratAccountsForBothLinkDirections(50L, 103L);
assertTrue(pathResult.isBackUpPathComputationWayUsed());
}
use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldCreatePathThrowMoreExpensiveWayMaxLatencyStrategy.
@Test
public void shouldCreatePathThrowMoreExpensiveWayMaxLatencyStrategy() throws UnroutableFlowException {
FindPathResult pathResult = findPathThrowMoreExpensiveWayMaxLatencyStrategy(10201L, Long.MAX_VALUE);
assertFalse(pathResult.isBackUpPathComputationWayUsed());
}
Aggregations