use of org.openkilda.persistence.ferma.frames.PathSegmentFrame in project open-kilda by telstra.
the class FermaPathSegmentRepository method updateFailedStatus.
@Override
@TransactionRequired
public void updateFailedStatus(FlowPath path, PathSegment segment, boolean failed) {
PathSegment segmentToUpdate;
if (segment.getData() instanceof PathSegmentFrame) {
segmentToUpdate = segment;
} else {
segmentToUpdate = path.getSegments().stream().filter(pathSegment -> pathSegment.getSrcSwitchId().equals(segment.getSrcSwitchId()) && pathSegment.getSrcPort() == segment.getSrcPort() && pathSegment.getDestSwitchId().equals(segment.getDestSwitchId()) && pathSegment.getDestPort() == segment.getDestPort()).findAny().orElse(null);
}
if (segmentToUpdate == null) {
throw new PersistenceException(format("PathSegment not found to be updated: %s_%d - %s_%d. Path id: %s.", segment.getSrcSwitchId(), segment.getSrcPort(), segment.getDestSwitchId(), segment.getDestPort(), path.getPathId()));
}
segmentToUpdate.setFailed(failed);
}
use of org.openkilda.persistence.ferma.frames.PathSegmentFrame in project open-kilda by telstra.
the class FermaIslRepository method findByPathIds.
@Override
public Collection<Isl> findByPathIds(List<PathId> pathIds) {
List<String> pathIdAsStr = pathIds.stream().map(PathIdConverter.INSTANCE::toGraphProperty).collect(Collectors.toList());
List<? extends PathSegmentFrame> segmentFrames = framedGraph().traverse(g -> g.V().hasLabel(PathSegmentFrame.FRAME_LABEL).has(PathSegmentFrame.PATH_ID_PROPERTY, P.within(pathIdAsStr))).toListExplicit(PathSegmentFrame.class);
if (segmentFrames.isEmpty()) {
return emptyList();
}
List<Isl> result = new ArrayList<>();
segmentFrames.forEach(segmentFrame -> {
framedGraph().traverse(g -> g.E().hasLabel(IslFrame.FRAME_LABEL).has(IslFrame.SRC_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(segmentFrame.getSrcSwitchId())).has(IslFrame.DST_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(segmentFrame.getDestSwitchId())).has(IslFrame.SRC_PORT_PROPERTY, segmentFrame.getSrcPort()).has(IslFrame.DST_PORT_PROPERTY, segmentFrame.getDestPort())).frameExplicit(IslFrame.class).forEachRemaining(frame -> result.add(addIslConfigToIsl(new Isl(frame))));
});
return result;
}
Aggregations