Search in sources :

Example 16 with PathComputer

use of org.openkilda.pce.PathComputer 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());
}
Also used : Isl(org.openkilda.model.Isl) PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 17 with PathComputer

use of org.openkilda.pce.PathComputer in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method shouldGetYPoint3FlowPaths.

@Test
public void shouldGetYPoint3FlowPaths() {
    FlowPath flowPathA = buildFlowPath("flow_path_a", 1, 2, 3, 7);
    FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 2, 3, 4, 5);
    FlowPath flowPathC = buildFlowPath("flow_path_c", 1, 2, 3, 4, 6);
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    SwitchId result = pathComputer.getIntersectionPoint(SWITCH_1, flowPathA, flowPathB, flowPathC);
    assertEquals(new SwitchId(3), result);
}
Also used : PathComputer(org.openkilda.pce.PathComputer) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 18 with PathComputer

use of org.openkilda.pce.PathComputer in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method shouldGetYPoint2FlowPathsWithSameEndpoints.

@Test
public void shouldGetYPoint2FlowPathsWithSameEndpoints() {
    FlowPath flowPathA = buildFlowPath("flow_path_a", 1, 2, 3);
    FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 2, 3);
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    SwitchId result = pathComputer.getIntersectionPoint(SWITCH_1, flowPathA, flowPathB);
    assertEquals(new SwitchId(3), result);
}
Also used : PathComputer(org.openkilda.pce.PathComputer) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 19 with PathComputer

use of org.openkilda.pce.PathComputer in project open-kilda by telstra.

the class MaxLatencyPathComputationStrategyBaseTest method maxLatencyStratWithNullLatency.

/**
 * Special case: flow with MAX_LATENCY strategy and 'max-latency' being unset(null) should pick path with least
 * latency.
 */
@Test
public void maxLatencyStratWithNullLatency() throws RecoverableException, UnroutableFlowException {
    // 1 - 2 - 4
    // + 3 +
    // path 1>2>4 has less latency than 1>3>4
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 100, 100, "00:", 1, 100, 101);
    // when: request a flow with MAX_LATENCY strategy and 'max-latency' set to 0
    Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:04")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
    PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
    GetPathsResult pathsResult = pathComputer.getPath(flow);
    // then: system returns a path with least weight
    assertFalse(pathsResult.isBackUpPathComputationWayUsed());
    assertThat(pathsResult.getForward().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:02")));
    assertThat(pathsResult.getReverse().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:02")));
}
Also used : PathComputer(org.openkilda.pce.PathComputer) BestWeightAndShortestPathFinder(org.openkilda.pce.finder.BestWeightAndShortestPathFinder) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 20 with PathComputer

use of org.openkilda.pce.PathComputer in project open-kilda by telstra.

the class MaxLatencyPathComputationStrategyBaseTest method shouldUseBackUpWeightWhenNoPathFoundInMaxLatencyStrat.

@Test
public void shouldUseBackUpWeightWhenNoPathFoundInMaxLatencyStrat() throws RecoverableException, UnroutableFlowException {
    // 1 - 2 - 4
    // + 3 +
    // path 1>2>4 has less latency than 1>3>4
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 100, 100, "00:", 1, 100, 101);
    // when: request a flow with MAX_LATENCY strategy and 'max-latency' is not enough to build a path
    Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:04")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).maxLatency(100L).maxLatencyTier2(300L).build();
    PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
    GetPathsResult pathsResult = pathComputer.getPath(flow);
    // then: system returns a path built by 'max_latency_tier2'
    assertTrue(pathsResult.isBackUpPathComputationWayUsed());
    assertThat(pathsResult.getForward().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
    assertThat(pathsResult.getReverse().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
}
Also used : PathComputer(org.openkilda.pce.PathComputer) BestWeightAndShortestPathFinder(org.openkilda.pce.finder.BestWeightAndShortestPathFinder) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Aggregations

PathComputer (org.openkilda.pce.PathComputer)56 Test (org.junit.Test)46 Flow (org.openkilda.model.Flow)45 GetPathsResult (org.openkilda.pce.GetPathsResult)39 SwitchId (org.openkilda.model.SwitchId)33 Switch (org.openkilda.model.Switch)27 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)8 FlowPath (org.openkilda.model.FlowPath)7 AvailableNetworkFactory (org.openkilda.pce.AvailableNetworkFactory)7 PathComputerFactory (org.openkilda.pce.PathComputerFactory)7 FlowResourcesManager (org.openkilda.wfm.share.flow.resources.FlowResourcesManager)7 BestWeightAndShortestPathFinder (org.openkilda.pce.finder.BestWeightAndShortestPathFinder)6 PathSegment (org.openkilda.model.PathSegment)4 Segment (org.openkilda.pce.Path.Segment)4 PathId (org.openkilda.model.PathId)3 RuleManager (org.openkilda.rulemanager.RuleManager)3 RuleManagerImpl (org.openkilda.rulemanager.RuleManagerImpl)3 Isl (org.openkilda.model.Isl)2 FlowCreateService (org.openkilda.wfm.topology.flowhs.service.FlowCreateService)2 FlowRerouteService (org.openkilda.wfm.topology.flowhs.service.FlowRerouteService)2