Search in sources :

Example 71 with PathSegment

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

the class FermaPathSegmentRepositoryTest method createFlowPath.

private FlowPath createFlowPath(PathId pathId) {
    Switch srcSwitch = createTestSwitch(1);
    Switch dstSwitch = createTestSwitch(2);
    Switch intSwitch = createTestSwitch(3);
    FlowPath flowPath = FlowPath.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(dstSwitch).status(FlowPathStatus.ACTIVE).build();
    PathSegment segment1 = PathSegment.builder().pathId(pathId).srcSwitch(srcSwitch).srcPort(1).destSwitch(intSwitch).destPort(3).build();
    PathSegment segment2 = PathSegment.builder().pathId(pathId).srcSwitch(intSwitch).srcPort(4).destSwitch(dstSwitch).destPort(2).build();
    flowPath.setSegments(asList(segment1, segment2));
    flowPathRepository.add(flowPath);
    return flowPath;
}
Also used : Switch(org.openkilda.model.Switch) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath)

Example 72 with PathSegment

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

the class FermaPathSegmentRepositoryTest method shouldFindSegmentsByPath.

@Test
public void shouldFindSegmentsByPath() {
    FlowPath path = createFlowPath(TEST_PATH_ID);
    assertThat(flowPathRepository.findAll(), hasSize(1));
    List<PathSegment> foundSegments = pathSegmentRepository.findByPathId(TEST_PATH_ID);
    assertThat(foundSegments, containsInAnyOrder(path.getSegments().toArray()));
}
Also used : PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 73 with PathSegment

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

the class FermaSwitchRepositoryTest method createTwoFlows.

private void createTwoFlows() {
    Switch switchA = createTestSwitch(TEST_SWITCH_ID_A.getId());
    Switch switchB = createTestSwitch(TEST_SWITCH_ID_B.getId());
    // create flow TEST_FLOW_ID_A
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID_A).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(4).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchB).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(2).destSwitch(switchB).destPort(3).build();
    forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(switchB).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchB).srcPort(3).destSwitch(switchA).destPort(2).build();
    reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
    flowRepository.add(flow);
    Switch switchC = createTestSwitch(TEST_SWITCH_ID_C.getId());
    // create flow TEST_FLOW_ID_B
    flow = Flow.builder().flowId(TEST_FLOW_ID_B).srcSwitch(switchA).srcPort(1).destSwitch(switchC).destPort(7).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(3)).srcSwitch(switchA).destSwitch(switchC).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    PathSegment forwardSegmentA = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(2).destSwitch(switchB).destPort(3).build();
    PathSegment forwardSegmentB = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchB).srcPort(5).destSwitch(switchC).destPort(6).build();
    forwardFlowPath.setSegments(Lists.newArrayList(forwardSegmentA, forwardSegmentB));
    reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(4)).srcSwitch(switchC).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    PathSegment reverseSegmentA = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchC).srcPort(6).destSwitch(switchB).destPort(5).build();
    PathSegment reverseSegmentB = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchB).srcPort(3).destSwitch(switchA).destPort(2).build();
    reverseFlowPath.setSegments(Lists.newArrayList(reverseSegmentA, reverseSegmentB));
    flowRepository.add(flow);
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Aggregations

PathSegment (org.openkilda.model.PathSegment)73 FlowPath (org.openkilda.model.FlowPath)40 ArrayList (java.util.ArrayList)28 Flow (org.openkilda.model.Flow)26 PathId (org.openkilda.model.PathId)24 SwitchId (org.openkilda.model.SwitchId)18 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)17 FlowEndpoint (org.openkilda.model.FlowEndpoint)12 Test (org.junit.Test)11 List (java.util.List)9 MeterId (org.openkilda.model.MeterId)9 Switch (org.openkilda.model.Switch)9 YFlow (org.openkilda.model.YFlow)8 PersistenceManager (org.openkilda.persistence.PersistenceManager)7 Optional (java.util.Optional)6 Slf4j (lombok.extern.slf4j.Slf4j)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)5 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)5