use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class FlowRerouteHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
FlowRerouteRequest request = pullValue(input, FIELD_ID_PAYLOAD, FlowRerouteRequest.class);
service.handleRequest(currentKey, request, getCommandContext());
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class FlowRerouteService method startFlowRerouting.
private void startFlowRerouting(String key, FlowRerouteRequest reroute, CommandContext commandContext, String sharedBandwidthGroupId) {
String flowId = reroute.getFlowId();
log.debug("Handling flow reroute request with key {} and flow ID: {}", key, flowId);
try {
checkRequestsCollision(key, flowId);
} catch (Exception e) {
log.error(e.getMessage());
fsmRegister.getFsmByKey(key).ifPresent(fsm -> removeIfFinished(fsm, key));
return;
}
if (fsmRegister.hasRegisteredFsmWithFlowId(flowId)) {
carrier.sendRerouteResultStatus(flowId, new RerouteInProgressError(), commandContext.getCorrelationId());
return;
}
FlowRerouteFsm fsm = fsmFactory.newInstance(flowId, commandContext, eventListeners);
fsm.setSharedBandwidthGroupId(sharedBandwidthGroupId);
fsmRegister.registerFsm(key, fsm);
FlowRerouteContext context = FlowRerouteContext.builder().flowId(flowId).affectedIsl(reroute.getAffectedIsl()).forceReroute(reroute.isForce()).ignoreBandwidth(reroute.isIgnoreBandwidth()).effectivelyDown(reroute.isEffectivelyDown()).rerouteReason(reroute.getReason()).build();
fsmExecutor.fire(fsm, Event.NEXT, context);
removeIfFinished(fsm, key);
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest 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.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class RerouteQueueService method sendRerouteRequest.
private void sendRerouteRequest(String flowId, FlowThrottlingData throttlingData) {
if (throttlingData != null) {
if (throttlingData.isYFlow()) {
YFlowRerouteRequest request = new YFlowRerouteRequest(flowId, throttlingData.getAffectedIsl(), throttlingData.isForce(), throttlingData.getReason(), throttlingData.isIgnoreBandwidth());
carrier.sendRerouteRequest(throttlingData.getCorrelationId(), request);
} else {
FlowRerouteRequest request = new FlowRerouteRequest(flowId, throttlingData.isForce(), throttlingData.isEffectivelyDown(), throttlingData.isIgnoreBandwidth(), throttlingData.getAffectedIsl(), throttlingData.getReason(), false);
carrier.sendRerouteRequest(throttlingData.getCorrelationId(), request);
}
}
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class OperationQueueBolt method handleInput.
@Override
protected void handleInput(Tuple tuple) throws PipelineException {
CommandContext context = pullContext(tuple);
MessageData data = pullValue(tuple, FIELD_ID_PAYLOAD, MessageData.class);
if (data instanceof FlowPathSwapRequest) {
FlowPathSwapRequest flowPathSwapRequest = (FlowPathSwapRequest) data;
service.addFirst(flowPathSwapRequest.getFlowId(), context.getCorrelationId(), flowPathSwapRequest);
} else if (data instanceof FlowRerouteRequest) {
FlowRerouteRequest flowRerouteRequest = (FlowRerouteRequest) data;
service.addLast(flowRerouteRequest.getFlowId(), context.getCorrelationId(), flowRerouteRequest);
} else if (data instanceof YFlowRerouteRequest) {
YFlowRerouteRequest yFlowRerouteRequest = (YFlowRerouteRequest) data;
service.addLast(yFlowRerouteRequest.getYFlowId(), context.getCorrelationId(), yFlowRerouteRequest);
} else if (data instanceof RerouteResultInfoData) {
RerouteResultInfoData rerouteResultInfoData = (RerouteResultInfoData) data;
service.operationCompleted(rerouteResultInfoData.getFlowId(), rerouteResultInfoData);
emitRerouteResponse(rerouteResultInfoData);
} else if (data instanceof PathSwapResult) {
PathSwapResult pathSwapResult = (PathSwapResult) data;
service.operationCompleted(pathSwapResult.getFlowId(), pathSwapResult);
} else {
unhandledInput(tuple);
}
}
Aggregations