use of org.openkilda.model.Switch in project open-kilda by telstra.
the class LatencyPathComputationStrategyBaseTest method shouldFailToFindOverDiamondWithNoActiveRoutes.
@Test
public void shouldFailToFindOverDiamondWithNoActiveRoutes() throws UnroutableFlowException, RecoverableException {
createDiamond(IslStatus.INACTIVE, IslStatus.INACTIVE, 100L, 1000L);
Switch srcSwitch = getSwitchById("00:01");
Switch destSwitch = getSwitchById("00:04");
Flow flow = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(100).pathComputationStrategy(PathComputationStrategy.LATENCY).build();
thrown.expect(UnroutableFlowException.class);
PathComputer pathComputer = pathComputerFactory.getPathComputer();
pathComputer.getPath(flow);
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverDiamondWithOneIslUnderMaintenanceByLatency.
@Test
public void shouldFindPathOverDiamondWithOneIslUnderMaintenanceByLatency() throws UnroutableFlowException, RecoverableException {
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 100L, 1000L);
Switch srcSwitch = getSwitchById("00:01");
Switch destSwitch = getSwitchById("00:04");
Isl linkAB = islRepository.findBySrcSwitch(srcSwitch.getSwitchId()).stream().filter(isl -> isl.getDestSwitchId().equals(new SwitchId("00:02"))).findAny().orElseThrow(() -> new IllegalStateException("Link A-B not found"));
linkAB.setUnderMaintenance(true);
Flow flow = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(100).pathComputationStrategy(PathComputationStrategy.LATENCY).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult path = pathComputer.getPath(flow);
assertNotNull(path);
assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
// should now have C as first hop since A - B link is under maintenance
assertEquals(new SwitchId("00:03"), path.getForward().getSegments().get(0).getDestSwitchId());
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class MaxLatencyPathComputationStrategyBaseTest method createNonGreedyMaxLatencyTopo.
private void createNonGreedyMaxLatencyTopo() {
// A - B - C
// \ / \
// D - E - F
String switchStart = "00:";
int index = 1;
Switch nodeA = createSwitch(switchStart + format("%02X", index++));
Switch nodeB = createSwitch(switchStart + format("%02X", index++));
Switch nodeC = createSwitch(switchStart + format("%02X", index++));
Switch nodeD = createSwitch(switchStart + format("%02X", index++));
Switch nodeE = createSwitch(switchStart + format("%02X", index++));
Switch nodeF = createSwitch(switchStart + format("%02X", index));
createBiIsl(nodeA, nodeB, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 1, 1L);
createBiIsl(nodeB, nodeC, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 2, 7L);
createBiIsl(nodeA, nodeD, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 3, 3L);
createBiIsl(nodeB, nodeD, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 4, 10L);
createBiIsl(nodeD, nodeE, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 5, 5L);
createBiIsl(nodeE, nodeF, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 6, 12L);
createBiIsl(nodeC, nodeF, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 7, 4L);
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class AvailableNetworkTest method buildPathWithSegment.
private PathSegment buildPathWithSegment(SwitchId srcDpid, SwitchId dstDpid, int srcPort, int dstPort, String srcPop, String dstPop, int seqId) {
Switch srcSwitch = Switch.builder().switchId(srcDpid).pop(srcPop).build();
Switch dstSwitch = Switch.builder().switchId(dstDpid).pop(dstPop).build();
PathId pathId = new PathId(UUID.randomUUID().toString());
FlowPath flowPath = FlowPath.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(dstSwitch).segments(IntStream.rangeClosed(0, seqId).mapToObj(i -> PathSegment.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(dstSwitch).srcPort(srcPort).destPort(dstPort).build()).collect(toList())).build();
return flowPath.getSegments().get(seqId);
}
use of org.openkilda.model.Switch in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method createDiamondWithAffinity.
// A - B - D and A-B-D is used in flow affinity group
// + C +
void createDiamondWithAffinity() {
Switch nodeA = createSwitch("00:0A");
Switch nodeB = createSwitch("00:0B");
Switch nodeC = createSwitch("00:0C");
Switch nodeD = createSwitch("00:0D");
IslStatus status = IslStatus.ACTIVE;
int cost = 100;
createIsl(nodeA, nodeB, status, status, cost * 2, 1000, 1, cost * 2);
createIsl(nodeA, nodeC, status, status, cost, 1000, 2, cost);
createIsl(nodeB, nodeD, status, status, cost * 2, 1000, 3, cost * 2);
createIsl(nodeC, nodeD, status, status, cost, 1000, 4, cost);
createIsl(nodeB, nodeA, status, status, cost * 2, 1000, 1, cost * 2);
createIsl(nodeC, nodeA, status, status, cost, 1000, 2, cost);
createIsl(nodeD, nodeB, status, status, cost * 2, 1000, 3, cost * 2);
createIsl(nodeD, nodeC, status, status, cost, 1000, 4, cost);
int bandwith = 10;
Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(nodeA).srcPort(15).destSwitch(nodeD).destPort(16).affinityGroupId(TEST_FLOW_ID).bandwidth(bandwith).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).build();
FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeA).destSwitch(nodeD).bandwidth(bandwith).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.FORWARD).build()).build();
addPathSegment(forwardPath, nodeA, nodeB, 1, 1);
addPathSegment(forwardPath, nodeB, nodeD, 3, 3);
flow.setForwardPath(forwardPath);
FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeD).destSwitch(nodeA).bandwidth(bandwith).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.REVERSE).build()).build();
addPathSegment(reversePath, nodeD, nodeB, 3, 3);
addPathSegment(reversePath, nodeB, nodeA, 1, 1);
flow.setReversePath(reversePath);
flowRepository.add(flow);
}
Aggregations