use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method shouldNotFindPathByWrongSegmentDestSwitch.
@Test
public void shouldNotFindPathByWrongSegmentDestSwitch() {
FlowPath flowPath = createTestFlowPathWithIntermediate(switchC, 100);
flow.setForwardPath(flowPath);
Collection<FlowPath> foundPaths = flowPathRepository.findBySegmentDestSwitch(switchA.getSwitchId());
assertThat(foundPaths, Matchers.empty());
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FermaIslRepositoryTest method createFlowWithPath.
private Flow createFlowWithPath(int forwardBandwidth, int reverseBandwidth) {
Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(switchA).destSwitch(switchB).status(FlowStatus.UP).build();
FlowPath forwardPath = FlowPath.builder().srcSwitch(switchA).destSwitch(switchB).pathId(new PathId(TEST_FLOW_ID + "_forward_path")).cookie(new FlowSegmentCookie(1)).meterId(new MeterId(1)).status(FlowPathStatus.ACTIVE).bandwidth(forwardBandwidth).ignoreBandwidth(false).build();
flow.setForwardPath(forwardPath);
PathSegment forwardSegment = PathSegment.builder().pathId(forwardPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(2).build();
forwardPath.setSegments(Collections.singletonList(forwardSegment));
FlowPath reversePath = FlowPath.builder().srcSwitch(switchB).destSwitch(switchA).pathId(new PathId(TEST_FLOW_ID + "_reverse_path")).cookie(new FlowSegmentCookie(2)).meterId(new MeterId(2)).status(FlowPathStatus.ACTIVE).bandwidth(reverseBandwidth).ignoreBandwidth(false).build();
flow.setReversePath(reversePath);
PathSegment reverseSegment = PathSegment.builder().pathId(reversePath.getPathId()).srcSwitch(switchB).srcPort(2).destSwitch(switchA).destPort(1).build();
reversePath.setSegments(Collections.singletonList(reverseSegment));
flowRepository.add(flow);
return flow;
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FermaIslRepositoryTest method createPathWithSegment.
private FlowPath createPathWithSegment(String pathId, Switch srcSwitch, Integer srcPort, Switch destSwitch, Integer destPort, long bandwidth, String sharedBandwidthGroupId) {
PathId pathIdAsObj = new PathId(pathId);
FlowPath path = FlowPath.builder().srcSwitch(srcSwitch).destSwitch(destSwitch).pathId(pathIdAsObj).bandwidth(bandwidth).sharedBandwidthGroupId(sharedBandwidthGroupId).segments(Collections.singletonList(PathSegment.builder().pathId(pathIdAsObj).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build())).build();
flowPathRepository.add(path);
return path;
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class LinkOperationsBolt method updateLinkUnderMaintenanceFlag.
private List<IslInfoData> updateLinkUnderMaintenanceFlag(UpdateLinkUnderMaintenanceRequest request) {
SwitchId srcSwitch = request.getSource().getDatapath();
Integer srcPort = request.getSource().getPortNumber();
SwitchId dstSwitch = request.getDestination().getDatapath();
Integer dstPort = request.getDestination().getPortNumber();
boolean underMaintenance = request.isUnderMaintenance();
boolean evacuate = request.isEvacuate();
List<Isl> isl;
try {
isl = linkOperationsService.updateLinkUnderMaintenanceFlag(srcSwitch, srcPort, dstSwitch, dstPort, underMaintenance);
if (underMaintenance && evacuate) {
Set<IslEndpoint> affectedIslEndpoints = new HashSet<>();
affectedIslEndpoints.add(new IslEndpoint(srcSwitch, srcPort));
affectedIslEndpoints.add(new IslEndpoint(dstSwitch, dstPort));
String reason = format("evacuated due to link maintenance %s_%d - %s_%d", srcSwitch, srcPort, dstSwitch, dstPort);
Collection<FlowPath> targetPaths = flowOperationsService.getFlowPathsForLink(srcSwitch, srcPort, dstSwitch, dstPort);
for (FlowRerouteRequest reroute : flowOperationsService.makeRerouteRequests(targetPaths, affectedIslEndpoints, reason)) {
CommandContext forkedContext = getCommandContext().fork(reroute.getFlowId());
getOutput().emit(StreamType.REROUTE.toString(), getCurrentTuple(), new Values(reroute, forkedContext.getCorrelationId()));
}
}
} catch (IslNotFoundException e) {
throw new MessageException(ErrorType.NOT_FOUND, e.getMessage(), "ISL was not found.");
}
return isl.stream().map(IslMapper.INSTANCE::map).collect(Collectors.toList());
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FlowOperationsServiceTest method createOrphanFlowPaths.
private void createOrphanFlowPaths(Flow flow, Switch srcSwitch, int srcPort, Switch dstSwitch, int dstPort, PathId forwardPartId, PathId reversePathId, Switch transitSwitch) {
FlowPath forwardPath = FlowPath.builder().pathId(forwardPartId).srcSwitch(srcSwitch).destSwitch(dstSwitch).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, UNMASKED_COOKIE)).build();
FlowPath reversePath = FlowPath.builder().pathId(reversePathId).srcSwitch(dstSwitch).destSwitch(srcSwitch).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, UNMASKED_COOKIE)).build();
if (!srcSwitch.getSwitchId().equals(dstSwitch.getSwitchId())) {
if (transitSwitch == null) {
// direct paths between src and dst switches
forwardPath.setSegments(newArrayList(createPathSegment(forwardPath.getPathId(), srcSwitch, srcPort, dstSwitch, dstPort)));
reversePath.setSegments(newArrayList(createPathSegment(reversePath.getPathId(), dstSwitch, dstPort, srcSwitch, srcPort)));
} else {
// src switch ==> transit switch ==> dst switch
forwardPath.setSegments(newArrayList(createPathSegment(forwardPath.getPathId(), srcSwitch, srcPort, transitSwitch, srcPort), createPathSegment(forwardPath.getPathId(), transitSwitch, dstPort, dstSwitch, dstPort)));
reversePath.setSegments(newArrayList(createPathSegment(reversePath.getPathId(), dstSwitch, dstPort, transitSwitch, dstPort), createPathSegment(reversePath.getPathId(), transitSwitch, srcPort, srcSwitch, srcPort)));
}
}
flowPathRepository.add(forwardPath);
flowPathRepository.add(reversePath);
flow.addPaths(forwardPath, reversePath);
}
Aggregations