use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class MaxLatencyPathComputationStrategyBaseTest method maxLatencyShouldChooseCorrectWayTest.
@Test
public void maxLatencyShouldChooseCorrectWayTest() throws Exception {
createThreeWaysTopo();
Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:05")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).maxLatency(25L).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult path = pathComputer.getPath(flow);
assertNotNull(path);
assertEquals(path.getForward().getSegments().size(), 2);
assertEquals(path.getForward().getSegments().get(1).getSrcSwitchId(), new SwitchId("00:03"));
}
use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class LatencyPathComputationStrategyBaseTest method shouldFindTheSameDiversePath.
@Test
public void shouldFindTheSameDiversePath() throws RecoverableException, UnroutableFlowException {
createDiamondWithDiversity();
Flow flow = Flow.builder().flowId("new-flow").diverseGroupId("diverse").bandwidth(10).srcSwitch(getSwitchById("00:0A")).srcPort(10).destSwitch(getSwitchById("00:0D")).destPort(10).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.LATENCY).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult diversePath = pathComputer.getPath(flow);
FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(flow.getSrcSwitch()).destSwitch(flow.getDestSwitch()).bandwidth(flow.getBandwidth()).build();
addPathSegments(forwardPath, diversePath.getForward());
flow.setForwardPath(forwardPath);
FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(flow.getDestSwitch()).destSwitch(flow.getSrcSwitch()).bandwidth(flow.getBandwidth()).build();
addPathSegments(reversePath, diversePath.getReverse());
flow.setReversePath(reversePath);
flowRepository.add(flow);
GetPathsResult path2 = pathComputer.getPath(flow, flow.getPathIds());
assertEquals(diversePath, path2);
}
use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class LatencyPathComputationStrategyBaseTest method shouldReturnEmptyPathWhenPathHasLatencyGreaterThanMaxLatencyTier2.
@Test
public void shouldReturnEmptyPathWhenPathHasLatencyGreaterThanMaxLatencyTier2() throws RecoverableException, UnroutableFlowException {
createTriangleTopo(IslStatus.ACTIVE, 100, 100, "00:", 1);
// when: request a flow with LATENCY strategy and 'max-latency-tier-2' is lower than found path
Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:02")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.LATENCY).maxLatency(50L).maxLatencyTier2(70L).build();
PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
// then: system can't find path
thrown.expect(UnroutableFlowException.class);
pathComputer.getPath(flow);
}
use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverTriangleByLatency.
@Test
public void shouldFindPathOverTriangleByLatency() throws UnroutableFlowException, RecoverableException {
/*
* should choose longer (in hops) but low latency path
*/
createTriangleTopo(IslStatus.ACTIVE, 10, 10, "00:", 1);
Switch srcSwitch = getSwitchById("00:01");
Switch destSwitch = getSwitchById("00:02");
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));
// it should now have C as first hop since A - B segment has high latency
assertEquals(new SwitchId("00:03"), path.getForward().getSegments().get(0).getDestSwitchId());
}
use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class FlowRerouteHubBolt method init.
@Override
protected void init() {
AvailableNetworkFactory availableNetworkFactory = new AvailableNetworkFactory(pathComputerConfig, persistenceManager.getRepositoryFactory());
PathComputer pathComputer = new PathComputerFactory(pathComputerConfig, availableNetworkFactory).getPathComputer();
FlowResourcesManager resourcesManager = new FlowResourcesManager(persistenceManager, flowResourcesConfig);
service = new FlowRerouteService(this, persistenceManager, pathComputer, resourcesManager, config.getPathAllocationRetriesLimit(), config.getPathAllocationRetryDelay(), config.getResourceAllocationRetriesLimit(), config.getSpeakerCommandRetriesLimit());
}
Aggregations