Search in sources :

Example 36 with FlowPath

use of org.openkilda.model.FlowPath 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 37 with FlowPath

use of org.openkilda.model.FlowPath 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 38 with FlowPath

use of org.openkilda.model.FlowPath 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)

Example 39 with FlowPath

use of org.openkilda.model.FlowPath 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 40 with FlowPath

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

the class FermaPathSegmentRepository method updateFailedStatus.

@Override
@TransactionRequired
public void updateFailedStatus(FlowPath path, PathSegment segment, boolean failed) {
    PathSegment segmentToUpdate;
    if (segment.getData() instanceof PathSegmentFrame) {
        segmentToUpdate = segment;
    } else {
        segmentToUpdate = path.getSegments().stream().filter(pathSegment -> pathSegment.getSrcSwitchId().equals(segment.getSrcSwitchId()) && pathSegment.getSrcPort() == segment.getSrcPort() && pathSegment.getDestSwitchId().equals(segment.getDestSwitchId()) && pathSegment.getDestPort() == segment.getDestPort()).findAny().orElse(null);
    }
    if (segmentToUpdate == null) {
        throw new PersistenceException(format("PathSegment not found to be updated: %s_%d - %s_%d. Path id: %s.", segment.getSrcSwitchId(), segment.getSrcPort(), segment.getDestSwitchId(), segment.getDestPort(), path.getPathId()));
    }
    segmentToUpdate.setFailed(failed);
}
Also used : PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) TransactionRequired(org.openkilda.persistence.tx.TransactionRequired) PathSegmentData(org.openkilda.model.PathSegment.PathSegmentData) PathSegmentFrame(org.openkilda.persistence.ferma.frames.PathSegmentFrame) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException) FermaPersistentImplementation(org.openkilda.persistence.ferma.FermaPersistentImplementation) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) List(java.util.List) PathSegmentRepository(org.openkilda.persistence.repositories.PathSegmentRepository) IslRepository(org.openkilda.persistence.repositories.IslRepository) Optional(java.util.Optional) Comparator(java.util.Comparator) PathIdConverter(org.openkilda.persistence.ferma.frames.converters.PathIdConverter) PathId(org.openkilda.model.PathId) PathSegmentFrame(org.openkilda.persistence.ferma.frames.PathSegmentFrame) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException) PathSegment(org.openkilda.model.PathSegment) TransactionRequired(org.openkilda.persistence.tx.TransactionRequired)

Aggregations

FlowPath (org.openkilda.model.FlowPath)229 Flow (org.openkilda.model.Flow)128 Test (org.junit.Test)108 PathId (org.openkilda.model.PathId)65 PathSegment (org.openkilda.model.PathSegment)42 SwitchId (org.openkilda.model.SwitchId)40 ArrayList (java.util.ArrayList)39 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)33 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)29 Switch (org.openkilda.model.Switch)28 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)27 SpeakerData (org.openkilda.rulemanager.SpeakerData)27 Action (org.openkilda.rulemanager.action.Action)26 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)26 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)26 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)26 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)26 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)26 MeterId (org.openkilda.model.MeterId)20 YFlow (org.openkilda.model.YFlow)19