Search in sources :

Example 21 with PathId

use of org.openkilda.model.PathId 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);
}
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)

Example 22 with PathId

use of org.openkilda.model.PathId 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);
}
Also used : PathId(org.openkilda.model.PathId) IntStream(java.util.stream.IntStream) PathWeight(org.openkilda.pce.model.PathWeight) Switch(org.openkilda.model.Switch) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Matchers(org.hamcrest.Matchers) Set(java.util.Set) Test(org.junit.Test) UUID(java.util.UUID) Collections.singletonList(java.util.Collections.singletonList) WeightFunction(org.openkilda.pce.model.WeightFunction) Assert.assertThat(org.junit.Assert.assertThat) Collectors.toList(java.util.stream.Collectors.toList) Edge(org.openkilda.pce.model.Edge) Flow(org.openkilda.model.Flow) SwitchId(org.openkilda.model.SwitchId) Arrays.asList(java.util.Arrays.asList) Node(org.openkilda.pce.model.Node) Assert.assertEquals(org.junit.Assert.assertEquals) PathId(org.openkilda.model.PathId) Switch(org.openkilda.model.Switch) FlowPath(org.openkilda.model.FlowPath)

Example 23 with PathId

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

the class InMemoryPathComputerBaseTest method buildFlowPath.

private FlowPath buildFlowPath(String pathIdAsString, int... ids) {
    PathId pathId = new PathId(pathIdAsString);
    List<PathSegment> segments = new ArrayList<>();
    for (int i = 1; i < ids.length; i++) {
        segments.add(PathSegment.builder().pathId(pathId).srcSwitch(Switch.builder().switchId(new SwitchId(ids[i - 1])).build()).destSwitch(Switch.builder().switchId(new SwitchId(ids[i])).build()).build());
    }
    return FlowPath.builder().pathId(pathId).srcSwitch(Switch.builder().switchId(new SwitchId(ids[0])).build()).destSwitch(Switch.builder().switchId(new SwitchId(ids[ids.length - 1])).build()).segments(segments).build();
}
Also used : PathId(org.openkilda.model.PathId) ArrayList(java.util.ArrayList) SwitchId(org.openkilda.model.SwitchId) PathSegment(org.openkilda.model.PathSegment)

Example 24 with PathId

use of org.openkilda.model.PathId 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);
}
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 25 with PathId

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

the class InMemoryPathComputerBaseTest method shouldThrowPathHasNoSegmentsWhenSegmentsIsNull.

@Test
public void shouldThrowPathHasNoSegmentsWhenSegmentsIsNull() {
    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()).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) 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)

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