use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldAddIntermediateSwitchWeightOnce.
@Test
public void shouldAddIntermediateSwitchWeightOnce() throws UnroutableFlowException {
AvailableNetwork network = buildTestNetwork();
// shouldn't affect path if added once
network.getSwitch(SWITCH_ID_A).increaseDiversityGroupUseCounter();
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(ALLOWED_DEPTH);
Pair<List<Edge>, List<Edge>> paths = pathFinder.findPathWithMinWeight(network, SWITCH_ID_D, SWITCH_ID_F, WEIGHT_FUNCTION).getFoundPath();
assertEquals(Arrays.asList(SWITCH_ID_D, SWITCH_ID_A, SWITCH_ID_F), getSwitchIdsFlowPath(paths.getLeft()));
}
use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method buildThreePathsNetwork.
private AvailableNetwork buildThreePathsNetwork() {
/*
2
/ \
1--3--5
\ /
4
*/
// Path 1>2>5 = 198cost
// Path 1>3>5 = 200cost
// Path 1>4>5 = 201cost
AvailableNetwork network = new AvailableNetwork();
// 1>2>5
addBidirectionalLink(network, SWITCH_ID_1, SWITCH_ID_2, 1, 1, 100);
addBidirectionalLink(network, SWITCH_ID_2, SWITCH_ID_5, 2, 1, 98);
// 1>3>5
addBidirectionalLink(network, SWITCH_ID_1, SWITCH_ID_3, 2, 1, 100);
addBidirectionalLink(network, SWITCH_ID_3, SWITCH_ID_5, 2, 2, 100);
// 1>4>5
addBidirectionalLink(network, SWITCH_ID_1, SWITCH_ID_4, 3, 1, 100);
addBidirectionalLink(network, SWITCH_ID_4, SWITCH_ID_5, 2, 3, 101);
return network;
}
use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldHandleVeryExpensiveLinks.
@Test
public void shouldHandleVeryExpensiveLinks() throws UnroutableFlowException {
AvailableNetwork network = buildExpensiveNetwork();
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(ALLOWED_DEPTH);
Pair<List<Edge>, List<Edge>> paths = pathFinder.findPathWithMinWeight(network, SWITCH_ID_1, SWITCH_ID_3, WEIGHT_FUNCTION).getFoundPath();
List<SwitchId> forwardSwitchPath = getSwitchIdsFlowPath(paths.getLeft());
List<SwitchId> reverseSwitchPath = Lists.reverse(getSwitchIdsFlowPath(paths.getRight()));
assertEquals(forwardSwitchPath, reverseSwitchPath);
assertEquals(forwardSwitchPath, Lists.newArrayList(SWITCH_ID_1, SWITCH_ID_3));
}
use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method buildTestNetworkForVerifyIslConfig.
private AvailableNetwork buildTestNetworkForVerifyIslConfig(boolean shortestPathHasUnderMaintenanceLink, boolean shortPathHasUnstableLink) {
/*
* Topology:
*
* A-------B
* |\ /|
* | +-C-+ |
* D-------E
*/
AvailableNetwork network = new AvailableNetwork();
addLink(network, SWITCH_ID_A, SWITCH_ID_B, 1, 1, 0, 0, false, shortestPathHasUnderMaintenanceLink);
addLink(network, SWITCH_ID_A, SWITCH_ID_C, 2, 1, 0, 0, false, false);
addLink(network, SWITCH_ID_C, SWITCH_ID_B, 2, 2, 0, 0, shortPathHasUnstableLink, false);
addLink(network, SWITCH_ID_A, SWITCH_ID_D, 3, 1, 0, 0, false, false);
addLink(network, SWITCH_ID_D, SWITCH_ID_E, 1, 1, 0, 0, false, false);
addLink(network, SWITCH_ID_E, SWITCH_ID_B, 2, 3, 0, 0, false, false);
return network;
}
use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldChooseExpensiveOverTooDeep.
@Test
public void shouldChooseExpensiveOverTooDeep() throws UnroutableFlowException {
AvailableNetwork network = buildLongAndExpensivePathsNetwork();
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(2);
Pair<List<Edge>, List<Edge>> pairPath = pathFinder.findPathWithMinWeight(network, SWITCH_ID_1, SWITCH_ID_4, 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());
}
Aggregations