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;
}
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;
}
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());
}
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;
}
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());
}
Aggregations