Search in sources :

Example 86 with PathId

use of org.openkilda.model.PathId in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method shouldThrowPathHasNoSegmentsWhenSegmentsIsEmpty.

@Test
public void shouldThrowPathHasNoSegmentsWhenSegmentsIsEmpty() {
    FlowPath flowPathA = FlowPath.builder().pathId(new PathId("flow_path_a")).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).destSwitch(Switch.builder().switchId(new SwitchId(3)).build()).segments(new ArrayList<>()).build();
    FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 2, 4, 5);
    InMemoryPathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(config.getMaxAllowedDepth()), config);
    Exception exception = assertThrows(IllegalArgumentException.class, () -> pathComputer.convertFlowPathsToSwitchLists(SWITCH_1, flowPathA, flowPathB));
    assertEquals("The path 'flow_path_a' has no path segments", exception.getMessage());
}
Also used : PathId(org.openkilda.model.PathId) ArrayList(java.util.ArrayList) BestWeightAndShortestPathFinder(org.openkilda.pce.finder.BestWeightAndShortestPathFinder) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) RecoverableException(org.openkilda.pce.exception.RecoverableException) ExpectedException(org.junit.rules.ExpectedException) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 87 with PathId

use of org.openkilda.model.PathId in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method createTestTopologyForAffinityTesting.

// A - B - C - D    and A-B-C-D is used in flow affinity group
// |   |   |   |
// E   F   \   |
// |   |     \ |
// G - H - - - Z
void createTestTopologyForAffinityTesting() {
    final Switch nodeA = createSwitch("00:0A");
    final Switch nodeB = createSwitch("00:0B");
    final Switch nodeC = createSwitch("00:0C");
    final Switch nodeD = createSwitch("00:0D");
    final Switch nodeE = createSwitch("00:0E");
    final Switch nodeF = createSwitch("00:0F");
    final Switch nodeG = createSwitch("00:01");
    final Switch nodeH = createSwitch("00:02");
    final Switch nodeZ = createSwitch("00:03");
    IslStatus status = IslStatus.ACTIVE;
    int cost = 100;
    long bw = 1000;
    long latency = 1000;
    createBiIsl(nodeA, nodeB, status, status, cost, bw, 1, latency);
    createBiIsl(nodeB, nodeC, status, status, cost, bw, 2, latency);
    createBiIsl(nodeC, nodeD, status, status, cost, bw, 3, latency);
    createBiIsl(nodeA, nodeE, status, status, cost, bw, 4, latency);
    createBiIsl(nodeE, nodeG, status, status, cost, bw, 5, latency);
    createBiIsl(nodeG, nodeH, status, status, cost, bw, 6, latency);
    createBiIsl(nodeB, nodeF, status, status, cost, bw, 7, latency);
    createBiIsl(nodeF, nodeH, status, status, cost, bw, 8, latency);
    createBiIsl(nodeH, nodeZ, status, status, cost, bw, 9, latency);
    createBiIsl(nodeC, nodeZ, status, status, cost, bw, 10, latency);
    createBiIsl(nodeD, nodeZ, status, status, cost, bw, 11, latency);
    int bandwidth = 10;
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(nodeA).srcPort(15).destSwitch(nodeD).destPort(16).affinityGroupId(TEST_FLOW_ID).bandwidth(bandwidth).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).build();
    FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeA).destSwitch(nodeD).bandwidth(bandwidth).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.FORWARD).build()).build();
    flow.setForwardPath(forwardPath);
    addPathSegment(forwardPath, nodeA, nodeB, 1, 1);
    addPathSegment(forwardPath, nodeB, nodeC, 2, 2);
    addPathSegment(forwardPath, nodeC, nodeD, 3, 3);
    FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeD).destSwitch(nodeA).bandwidth(bandwidth).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.REVERSE).build()).build();
    flow.setReversePath(reversePath);
    addPathSegment(reversePath, nodeD, nodeC, 3, 3);
    addPathSegment(reversePath, nodeC, nodeB, 2, 2);
    addPathSegment(reversePath, nodeB, nodeA, 1, 1);
    flowRepository.add(flow);
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) IslStatus(org.openkilda.model.IslStatus) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Example 88 with PathId

use of org.openkilda.model.PathId in project open-kilda by telstra.

the class CostAndBandwidthPathComputationStrategyTest 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.COST).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()).segments(new ArrayList<>()).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()).segments(new ArrayList<>()).build();
    addPathSegments(reversePath, diversePath.getReverse());
    flow.setReversePath(reversePath);
    flowRepository.add(flow);
    GetPathsResult path2 = pathComputer.getPath(flow, flow.getPathIds());
    assertEquals(diversePath, path2);
}
Also used : PathId(org.openkilda.model.PathId) PathComputer(org.openkilda.pce.PathComputer) ArrayList(java.util.ArrayList) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 89 with PathId

use of org.openkilda.model.PathId in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method createDiamondWithDiversity.

// A - B - D    and A-B-D is used in flow diverse group
// + C +
void createDiamondWithDiversity() {
    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, 1000, 1);
    createIsl(nodeA, nodeC, status, status, cost * 2, 1000, 2);
    createIsl(nodeB, nodeD, status, status, cost, 1000, 3);
    createIsl(nodeC, nodeD, status, status, cost * 2, 1000, 4);
    createIsl(nodeB, nodeA, status, status, cost, 1000, 1);
    createIsl(nodeC, nodeA, status, status, cost * 2, 1000, 2);
    createIsl(nodeD, nodeB, status, status, cost, 1000, 3);
    createIsl(nodeD, nodeC, status, status, cost * 2, 1000, 4);
    int bandwith = 10;
    String flowId = "existed-flow";
    String diverseGroupId = "diverse";
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(nodeA).srcPort(15).destSwitch(nodeD).destPort(16).diverseGroupId(diverseGroupId).bandwidth(bandwith).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).build();
    FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeA).destSwitch(nodeD).bandwidth(bandwith).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).build();
    addPathSegment(reversePath, nodeD, nodeB, 3, 3);
    addPathSegment(reversePath, nodeB, nodeA, 1, 1);
    flow.setReversePath(reversePath);
    flowRepository.add(flow);
}
Also used : PathId(org.openkilda.model.PathId) Switch(org.openkilda.model.Switch) IslStatus(org.openkilda.model.IslStatus) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Example 90 with PathId

use of org.openkilda.model.PathId in project open-kilda by telstra.

the class CostPathComputationStrategyTest 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.COST).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);
}
Also used : PathId(org.openkilda.model.PathId) PathComputer(org.openkilda.pce.PathComputer) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Aggregations

PathId (org.openkilda.model.PathId)124 Flow (org.openkilda.model.Flow)65 FlowPath (org.openkilda.model.FlowPath)65 Test (org.junit.Test)44 Switch (org.openkilda.model.Switch)29 SwitchId (org.openkilda.model.SwitchId)28 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)27 PathSegment (org.openkilda.model.PathSegment)26 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)21 MeterId (org.openkilda.model.MeterId)19 ArrayList (java.util.ArrayList)18 List (java.util.List)13 Slf4j (lombok.extern.slf4j.Slf4j)11 GetPathsResult (org.openkilda.pce.GetPathsResult)11 FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)10 Path (org.openkilda.pce.Path)10 Collection (java.util.Collection)9 RecoverableException (org.openkilda.pce.exception.RecoverableException)9 String.format (java.lang.String.format)8 HashMap (java.util.HashMap)8