use of org.openkilda.model.IslEndpoint in project open-kilda by telstra.
the class AbstractYFlowTest method buildPathSegment.
private Segment buildPathSegment(IslDirectionalReference reference) {
IslEndpoint source = reference.getSourceEndpoint();
IslEndpoint dest = reference.getDestEndpoint();
return Segment.builder().srcSwitchId(source.getSwitchId()).srcPort(source.getPortNumber()).destSwitchId(dest.getSwitchId()).destPort(dest.getPortNumber()).build();
}
use of org.openkilda.model.IslEndpoint in project open-kilda by telstra.
the class FlowRerouteServiceTest method extractIslEndpoint.
private IslEndpoint extractIslEndpoint(Flow flow) {
FlowPath forwardPath = flow.getForwardPath();
assertNotNull(forwardPath);
List<PathSegment> forwardSegments = forwardPath.getSegments();
assertFalse(forwardSegments.isEmpty());
PathSegment firstSegment = forwardSegments.get(0);
return new IslEndpoint(firstSegment.getSrcSwitchId(), firstSegment.getSrcPort());
}
use of org.openkilda.model.IslEndpoint in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldProcessRerouteForValidRequest.
@Test
public void shouldProcessRerouteForValidRequest() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
Flow origin = makeFlow();
origin.setTargetPathComputationStrategy(LATENCY);
setupFlowRepositorySpy().findById(origin.getFlowId()).ifPresent(foundPath -> foundPath.setTargetPathComputationStrategy(LATENCY));
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRerouteService service = makeService();
IslEndpoint affectedEndpoint = extractIslEndpoint(origin);
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, true, false, Collections.singleton(affectedEndpoint), null, false);
service.handleRequest(currentRequestKey, request, commandContext);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
produceAsyncResponse(service, speakerRequest);
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathReplace(origin, result);
assertEquals(LATENCY, result.getPathComputationStrategy());
assertNull(result.getTargetPathComputationStrategy());
}
use of org.openkilda.model.IslEndpoint in project open-kilda by telstra.
the class AbstractFlowTest method makePathSegment.
private Segment makePathSegment(IslDirectionalReference reference) {
IslEndpoint source = reference.getSourceEndpoint();
IslEndpoint dest = reference.getDestEndpoint();
return Segment.builder().srcSwitchId(source.getSwitchId()).srcPort(source.getPortNumber()).destSwitchId(dest.getSwitchId()).destPort(dest.getPortNumber()).build();
}
use of org.openkilda.model.IslEndpoint 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());
}
Aggregations