Search in sources :

Example 66 with PathSegment

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

the class FermaFlowPathRepositoryTest method createTestFlowPathWithIntermediate.

private FlowPath createTestFlowPathWithIntermediate(Switch intSwitch, int intPort) {
    FlowPath flowPath = FlowPath.builder().pathId(new PathId(flow.getFlowId() + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchB).status(FlowPathStatus.ACTIVE).build();
    PathSegment segment1 = PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(intSwitch).destPort(intPort).build();
    PathSegment segment2 = PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(intSwitch).srcPort(intPort + 100).destSwitch(switchB).destPort(2).build();
    flowPath.setSegments(asList(segment1, segment2));
    flowPathRepository.add(flowPath);
    return flowPath;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) MeterId(org.openkilda.model.MeterId)

Example 67 with PathSegment

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

the class FermaIslRepositoryTest method shouldFindIslByPathId.

@Test
public void shouldFindIslByPathId() {
    Isl isl = createIsl(switchA, 111, switchB, 112);
    PathId pathId = new PathId("test_path_id");
    PathSegment segment = PathSegment.builder().pathId(pathId).srcSwitch(isl.getSrcSwitch()).srcPort(isl.getSrcPort()).destSwitch(isl.getDestSwitch()).destPort(isl.getDestPort()).build();
    FlowPath path = FlowPath.builder().pathId(pathId).srcSwitch(switchA).destSwitch(switchB).segments(Collections.singletonList(segment)).build();
    flowPathRepository.add(path);
    List<Isl> foundIsls = Lists.newArrayList(islRepository.findByPathIds(Collections.singletonList(pathId)));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl));
}
Also used : PathId(org.openkilda.model.PathId) Isl(org.openkilda.model.Isl) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 68 with PathSegment

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

the class FermaFlowRepositoryTest method createTestFlow.

private Flow createTestFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan, boolean multiTable) {
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).srcVlan(srcVlan).destSwitch(destSwitch).destPort(destPort).destVlan(destVlan).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    flowRepository.add(flow);
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).srcWithMultiTable(multiTable).destWithMultiTable(multiTable).build();
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
    forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
    flowPathRepository.add(forwardFlowPath);
    flow.setForwardPath(forwardFlowPath);
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).srcWithMultiTable(multiTable).destWithMultiTable(multiTable).build();
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
    reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
    flowPathRepository.add(reverseFlowPath);
    flow.setReversePath(reverseFlowPath);
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 69 with PathSegment

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

the class FermaFlowRepositoryTest method createTestFlowWithIntermediate.

private Flow createTestFlowWithIntermediate(String flowId, Switch srcSwitch, Switch intSwitch, int intPort, Switch destSwitch) {
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(PORT_1).destSwitch(destSwitch).destPort(PORT_2).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    flowRepository.add(flow);
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
    flowPathRepository.add(forwardFlowPath);
    flow.setForwardPath(forwardFlowPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(1).destSwitch(intSwitch).destPort(intPort).build();
    forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
    flowPathRepository.add(reverseFlowPath);
    flow.setReversePath(reverseFlowPath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(intSwitch).srcPort(100).destSwitch(srcSwitch).destPort(1).build();
    reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 70 with PathSegment

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

the class FermaYFlowRepositoryTest method createTestFlow.

private Flow createTestFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan) {
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).srcVlan(srcVlan).destSwitch(destSwitch).destPort(destPort).destVlan(destVlan).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    flowRepository.add(flow);
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
    forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
    flowPathRepository.add(forwardFlowPath);
    flow.setForwardPath(forwardFlowPath);
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
    reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
    flowPathRepository.add(reverseFlowPath);
    flow.setReversePath(reverseFlowPath);
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow) 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