Search in sources :

Example 1 with MirrorGroup

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

the class ResourceAllocationAction method createFlowMirrorPoints.

private FlowMirrorPoints createFlowMirrorPoints(RequestedFlowMirrorPoint mirrorPoint, FlowPath flowPath) throws ResourceAllocationException {
    Switch mirrorSwitch = switchRepository.findById(mirrorPoint.getMirrorPointSwitchId()).orElseThrow(() -> new FlowProcessingException(ErrorType.NOT_FOUND, format("Switch %s not found", mirrorPoint.getMirrorPointSwitchId())));
    MirrorDirection direction = mirrorPoint.getMirrorPointSwitchId().equals(flowPath.getSrcSwitchId()) ? MirrorDirection.INGRESS : MirrorDirection.EGRESS;
    MirrorGroup mirrorGroup = resourcesManager.getAllocatedMirrorGroup(mirrorPoint.getMirrorPointSwitchId(), mirrorPoint.getFlowId(), flowPath.getPathId(), MirrorGroupType.TRAFFIC_INTEGRITY, direction);
    FlowMirrorPoints flowMirrorPoints = FlowMirrorPoints.builder().mirrorSwitch(mirrorSwitch).mirrorGroup(mirrorGroup).build();
    flowMirrorPointsRepository.add(flowMirrorPoints);
    flowPath.addFlowMirrorPoints(flowMirrorPoints);
    return flowMirrorPoints;
}
Also used : MirrorGroup(org.openkilda.model.MirrorGroup) Switch(org.openkilda.model.Switch) FlowProcessingException(org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) MirrorDirection(org.openkilda.model.MirrorDirection)

Example 2 with MirrorGroup

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

the class FlowMirrorPointsFrame method getMirrorGroup.

@Override
public MirrorGroup getMirrorGroup() {
    if (mirrorGroup == null) {
        List<? extends MirrorGroupFrame> mirrorGroupFrames = traverse(v -> v.out(HAS_MIRROR_GROUP_EDGE).hasLabel(MirrorGroupFrame.FRAME_LABEL)).toListExplicit(MirrorGroupFrame.class);
        if (!mirrorGroupFrames.isEmpty()) {
            mirrorGroup = new MirrorGroup((mirrorGroupFrames.get(0)));
            if (!Objects.equals(getMirrorGroupId(), mirrorGroup.getGroupId())) {
                throw new IllegalStateException(format("The flow mirror points %s has inconsistent mirror group %s / %s", getId(), getMirrorGroupId(), mirrorGroup.getGroupId()));
            }
        } else {
            String switchId = getProperty(MIRROR_SWITCH_ID_PROPERTY);
            String pathId = getProperty(FLOW_PATH_ID_PROPERTY);
            log.warn("Fallback to find the mirror group by a reference instead of an edge. " + "The switch {}, the vertex {}", switchId, this);
            mirrorGroup = MirrorGroupFrame.load(getGraph(), switchId, pathId).map(MirrorGroup::new).orElse(null);
        }
    }
    return mirrorGroup;
}
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) MirrorGroup(org.openkilda.model.MirrorGroup)

Example 3 with MirrorGroup

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

the class FermaMirrorGroupRepositoryTest method shouldDeleteFoundMirrorGroup.

@Test
public void shouldDeleteFoundMirrorGroup() {
    createMirrorGroup();
    transactionManager.doInTransaction(() -> {
        Collection<MirrorGroup> allMirrorGroups = mirrorGroupRepository.findAll();
        MirrorGroup foundMirrorGroup = allMirrorGroups.iterator().next();
        mirrorGroupRepository.remove(foundMirrorGroup);
    });
    assertEquals(0, mirrorGroupRepository.findAll().size());
}
Also used : MirrorGroup(org.openkilda.model.MirrorGroup) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 4 with MirrorGroup

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

the class FermaMirrorGroupRepositoryTest method createMirrorGroup.

private MirrorGroup createMirrorGroup(int groupId, PathId pathId) {
    MirrorGroup mirrorGroup = MirrorGroup.builder().switchId(theSwitch.getSwitchId()).groupId(new GroupId(groupId)).pathId(pathId).flowId(TEST_FLOW_ID).mirrorDirection(MirrorDirection.INGRESS).mirrorGroupType(MirrorGroupType.TRAFFIC_INTEGRITY).build();
    mirrorGroupRepository.add(mirrorGroup);
    return mirrorGroup;
}
Also used : MirrorGroup(org.openkilda.model.MirrorGroup) GroupId(org.openkilda.model.GroupId)

Example 5 with MirrorGroup

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

the class FermaMirrorGroupRepositoryTest method shouldGetZeroMirrorGroupsForPath.

@Test
public void shouldGetZeroMirrorGroupsForPath() {
    Collection<MirrorGroup> meters = mirrorGroupRepository.findByPathId(new PathId(TEST_PATH_ID));
    assertTrue(meters.isEmpty());
}
Also used : PathId(org.openkilda.model.PathId) MirrorGroup(org.openkilda.model.MirrorGroup) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

MirrorGroup (org.openkilda.model.MirrorGroup)13 GroupId (org.openkilda.model.GroupId)7 Test (org.junit.Test)6 PathId (org.openkilda.model.PathId)6 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)6 Switch (org.openkilda.model.Switch)5 FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)4 String.format (java.lang.String.format)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Slf4j (lombok.extern.slf4j.Slf4j)2 FlowPath (org.openkilda.model.FlowPath)2 SwitchId (org.openkilda.model.SwitchId)2 Generators (com.fasterxml.uuid.Generators)1 NoArgGenerator (com.fasterxml.uuid.NoArgGenerator)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1