use of org.openkilda.model.PathId in project open-kilda by telstra.
the class FlowMirrorPathFrame method setSegments.
@Override
public void setSegments(List<PathSegment> segments) {
getElement().edges(Direction.OUT, OWNS_SEGMENTS_EDGE).forEachRemaining(edge -> {
edge.inVertex().remove();
edge.remove();
});
PathId pathId = getPathId();
for (int idx = 0; idx < segments.size(); idx++) {
PathSegment segment = segments.get(idx);
PathSegment.PathSegmentData data = segment.getData();
data.setPathId(pathId);
data.setSeqId(idx);
PathSegmentFrame frame;
if (data instanceof PathSegmentFrame) {
frame = (PathSegmentFrame) data;
// Unlink the path from the previous owner.
frame.getElement().edges(Direction.IN, OWNS_SEGMENTS_EDGE).forEachRemaining(Edge::remove);
} else {
frame = PathSegmentFrame.create(getGraph(), data);
}
linkOut(frame, OWNS_SEGMENTS_EDGE);
}
// force to reload
this.segments = null;
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class FlowPathFrame method setSegments.
@Override
public void setSegments(List<PathSegment> segments) {
getElement().edges(Direction.OUT, OWNS_SEGMENTS_EDGE).forEachRemaining(edge -> {
edge.inVertex().remove();
edge.remove();
});
PathId pathId = getPathId();
for (int idx = 0; idx < segments.size(); idx++) {
PathSegment segment = segments.get(idx);
PathSegment.PathSegmentData data = segment.getData();
data.setPathId(pathId);
data.setSeqId(idx);
PathSegmentFrame frame;
if (data instanceof PathSegmentFrame) {
frame = (PathSegmentFrame) data;
// Unlink the path from the previous owner.
frame.getElement().edges(Direction.IN, OWNS_SEGMENTS_EDGE).forEachRemaining(Edge::remove);
} else {
frame = PathSegmentFrame.create(getGraph(), data);
}
linkOut(frame, OWNS_SEGMENTS_EDGE);
}
// force to reload
this.segments = null;
}
use of org.openkilda.model.PathId 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.PathId 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;
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method buildTestProtectedFlow.
private Flow buildTestProtectedFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan) {
Flow flow = buildTestFlow(flowId, srcSwitch, srcPort, srcVlan, destSwitch, destPort, destVlan);
FlowPath forwardProtectedFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_protected_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 2L)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
flow.setProtectedForwardPath(forwardProtectedFlowPath);
PathSegment forwardSegment = PathSegment.builder().pathId(forwardProtectedFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
forwardProtectedFlowPath.setSegments(Collections.singletonList(forwardSegment));
FlowPath reverseProtectedFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_protected_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 2L)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
flow.setProtectedReversePath(reverseProtectedFlowPath);
PathSegment reverseSegment = PathSegment.builder().pathId(reverseProtectedFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
reverseProtectedFlowPath.setSegments(Collections.singletonList(reverseSegment));
return flow;
}
Aggregations