use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldChooseExpensiveOverTooDeepForReverseOrder.
@Test
public void shouldChooseExpensiveOverTooDeepForReverseOrder() throws UnroutableFlowException {
AvailableNetwork network = buildLongAndExpensivePathsNetwork();
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(2);
Pair<List<Edge>, List<Edge>> pairPath = pathFinder.findPathWithMinWeight(network, SWITCH_ID_4, SWITCH_ID_1, WEIGHT_FUNCTION).getFoundPath();
List<Edge> fpath = pairPath.getLeft();
assertThat(fpath, Matchers.hasSize(2));
assertEquals(SWITCH_ID_2, fpath.get(1).getSrcSwitch().getSwitchId());
List<Edge> rpath = pairPath.getRight();
assertThat(rpath, Matchers.hasSize(2));
assertEquals(SWITCH_ID_2, rpath.get(0).getDestSwitch().getSwitchId());
}
use of org.openkilda.pce.impl.AvailableNetwork 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.impl.AvailableNetwork in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldChooseCheaperWithSameDepth.
@Test
public void shouldChooseCheaperWithSameDepth() throws UnroutableFlowException {
AvailableNetwork network = buildLongAndExpensivePathsNetwork();
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(3);
Pair<List<Edge>, List<Edge>> pairPath = pathFinder.findPathWithMinWeight(network, SWITCH_ID_1, SWITCH_ID_5, WEIGHT_FUNCTION).getFoundPath();
List<Edge> fpath = pairPath.getLeft();
assertThat(fpath, Matchers.hasSize(3));
assertEquals(SWITCH_ID_3, fpath.get(2).getSrcSwitch().getSwitchId());
List<Edge> rpath = pairPath.getRight();
assertThat(rpath, Matchers.hasSize(3));
assertEquals(SWITCH_ID_3, rpath.get(0).getDestSwitch().getSwitchId());
}
use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldChooseCheaperOverTooDeepMaxWeightStrategy.
@Test
public void shouldChooseCheaperOverTooDeepMaxWeightStrategy() throws UnroutableFlowException {
AvailableNetwork network = buildLongAndExpensivePathsNetwork();
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(2);
Pair<List<Edge>, List<Edge>> pairPath = pathFinder.findPathWithWeightCloseToMaxWeight(network, SWITCH_ID_1, SWITCH_ID_3, WEIGHT_FUNCTION, Long.MAX_VALUE, Long.MAX_VALUE).getFoundPath();
List<Edge> fpath = pairPath.getLeft();
assertThat(fpath, Matchers.hasSize(2));
assertEquals(SWITCH_ID_2, fpath.get(1).getSrcSwitch().getSwitchId());
List<Edge> rpath = pairPath.getRight();
assertThat(rpath, Matchers.hasSize(2));
assertEquals(SWITCH_ID_2, rpath.get(0).getDestSwitch().getSwitchId());
}
use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.
the class AvailableNetworkFactoryTest method shouldBuildAvailableNetworkUsingSymmetricCostStrategy.
@Test
public void shouldBuildAvailableNetworkUsingSymmetricCostStrategy() throws RecoverableException {
Flow flow = getFlow(false);
IslImmutableView isl = getIslView(flow);
when(config.getNetworkStrategy()).thenReturn("SYMMETRIC_COST");
when(islRepository.findSymmetricActiveByBandwidthAndEncapsulationType(flow.getBandwidth(), flow.getEncapsulationType())).thenReturn(Collections.singletonList(isl));
AvailableNetwork availableNetwork = availableNetworkFactory.getAvailableNetwork(flow, Collections.emptyList());
assertAvailableNetworkIsCorrect(isl, availableNetwork);
}
Aggregations