Search in sources :

Example 41 with FlowPath

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

the class FlowMirrorPointsFrame method getFlowPath.

@Override
public FlowPath getFlowPath() {
    if (flowPath == null) {
        List<? extends FlowPathFrame> flowFrames = traverse(v -> v.in(FlowPathFrame.HAS_SEGMENTS_EDGE).hasLabel(FlowPathFrame.FRAME_LABEL)).toListExplicit(FlowPathFrame.class);
        flowPath = !flowFrames.isEmpty() ? new FlowPath(flowFrames.get(0)) : null;
        PathId pathId = flowPath != null ? flowPath.getPathId() : null;
        if (!Objects.equals(getFlowPathId(), pathId)) {
            throw new IllegalStateException(format("The flow mirror points %s has inconsistent flow_path_id %s / %s", getId(), getFlowPathId(), pathId));
        }
    }
    return flowPath;
}
Also used : GroupIdConverter(org.openkilda.persistence.ferma.frames.converters.GroupIdConverter) FlowPath(org.openkilda.model.FlowPath) FlowMirrorPointsData(org.openkilda.model.FlowMirrorPoints.FlowMirrorPointsData) SwitchIdConverter(org.openkilda.persistence.ferma.frames.converters.SwitchIdConverter) Convert(org.openkilda.persistence.ferma.frames.converters.Convert) MirrorGroup(org.openkilda.model.MirrorGroup) Map(java.util.Map) PathId(org.openkilda.model.PathId) Edge(org.apache.tinkerpop.gremlin.structure.Edge) Switch(org.openkilda.model.Switch) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Objects(java.util.Objects) Slf4j(lombok.extern.slf4j.Slf4j) Direction(org.apache.tinkerpop.gremlin.structure.Direction) List(java.util.List) SwitchId(org.openkilda.model.SwitchId) Property(com.syncleus.ferma.annotations.Property) FlowMirrorPath(org.openkilda.model.FlowMirrorPath) Optional(java.util.Optional) VertexFrame(com.syncleus.ferma.VertexFrame) GroupId(org.openkilda.model.GroupId) PathIdConverter(org.openkilda.persistence.ferma.frames.converters.PathIdConverter) Collections(java.util.Collections) PathId(org.openkilda.model.PathId) FlowPath(org.openkilda.model.FlowPath)

Example 42 with FlowPath

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

the class FermaFlowPathRepositoryTest method shouldFindPathBySegmentDestSwitch.

@Test
public void shouldFindPathBySegmentDestSwitch() {
    FlowPath flowPath = createTestFlowPathWithIntermediate(switchC, 100);
    flow.setForwardPath(flowPath);
    Collection<FlowPath> foundPaths = flowPathRepository.findBySegmentDestSwitch(switchC.getSwitchId());
    assertThat(foundPaths, hasSize(1));
}
Also used : FlowPath(org.openkilda.model.FlowPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 43 with FlowPath

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

the class FermaFlowPathRepositoryTest method shouldFindPathById.

@Test
public void shouldFindPathById() {
    FlowPath flowPath = createTestFlowPath();
    Optional<FlowPath> foundPath = flowPathRepository.findById(flowPath.getPathId());
    assertTrue(foundPath.isPresent());
}
Also used : FlowPath(org.openkilda.model.FlowPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 44 with FlowPath

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

the class FermaFlowPathRepositoryTest method shouldCreateFlowWithPaths.

@Test
public void shouldCreateFlowWithPaths() {
    createTestFlowPathPair();
    Collection<FlowPath> allPaths = flowPathRepository.findAll();
    assertThat(allPaths, hasSize(2));
    FlowPath foundForwardPath = flowPathRepository.findById(flow.getForwardPathId()).get();
    assertEquals(switchA.getSwitchId(), foundForwardPath.getSrcSwitchId());
    assertEquals(switchB.getSwitchId(), foundForwardPath.getDestSwitchId());
    Flow foundFlow = flowRepository.findById(TEST_FLOW_ID).get();
    assertThat(foundFlow.getPaths(), hasSize(2));
    assertEquals(foundFlow.getFlowId(), foundForwardPath.getFlow().getFlowId());
}
Also used : FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 45 with FlowPath

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

the class FermaFlowPathRepositoryTest method shouldFindInactivePathBySegmentSwitch.

@Test
public void shouldFindInactivePathBySegmentSwitch() {
    Flow activeFlow = Flow.builder().flowId("active flow").srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(2).status(FlowStatus.UP).build();
    flowRepository.add(activeFlow);
    FlowPath activeFlowPath = createFlowPath(activeFlow, "active", 100L, 200L, switchA, switchB);
    activeFlow.addPaths(activeFlowPath);
    activeFlowPath.getFlow().setStatus(FlowStatus.DOWN);
    FlowPath expectedFlowPath = createTestFlowPathWithIntermediate(switchC, 100);
    activeFlow.addPaths(expectedFlowPath);
    expectedFlowPath.getFlow().setStatus(FlowStatus.DOWN);
    Collection<FlowPath> foundPaths = flowPathRepository.findInactiveBySegmentSwitch(switchA.getSwitchId());
    assertThat(foundPaths, hasSize(1));
    FlowPath actualFlowPath = foundPaths.stream().findFirst().orElse(null);
    assertEquals(expectedFlowPath, actualFlowPath);
}
Also used : FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

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