use of org.openkilda.messaging.info.reroute.error.RerouteInProgressError 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.info.reroute.error.RerouteInProgressError in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldInjectRetryToThrottlingWhenReceivedFailedRerouteResult.
@Test
public void shouldInjectRetryToThrottlingWhenReceivedFailedRerouteResult() {
FlowThrottlingData inProgress = getFlowThrottlingData(flow, CORRELATION_ID).build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(FLOW_ID).success(false).rerouteError(new RerouteInProgressError()).build();
rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
assertNull(rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
FlowThrottlingData expected = getFlowThrottlingData(flow, CORRELATION_ID + " : retry #1 ignore_bw false").build();
expected.setRetryCounter(1);
assertEquals(expected, rerouteQueue.getThrottling());
verify(carrier).sendExtendTimeWindowEvent();
}
use of org.openkilda.messaging.info.reroute.error.RerouteInProgressError in project open-kilda by telstra.
the class RerouteQueueService method isRetryRequired.
private boolean isRetryRequired(String flowId, RerouteError rerouteError, boolean isYFlow) {
if (rerouteError instanceof NoPathFoundError) {
log.info("Received no path found error for flow {}", flowId);
return true;
} else if (rerouteError instanceof RerouteInProgressError) {
log.info("Received reroute in progress error for flow {}", flowId);
return true;
} else if (rerouteError instanceof SpeakerRequestError) {
if (isYFlow) {
log.info("Received speaker request error for y-flow {}", flowId);
YFlow yFlow = yFlowRepository.findById(flowId).orElse(null);
if (yFlow == null) {
log.error("Y-flow {} not found", flowId);
return false;
}
Set<SwitchId> yFlowSwitchIds = yFlow.getSubFlows().stream().map(YSubFlow::getEndpointSwitchId).collect(Collectors.toSet());
yFlowSwitchIds.add(yFlow.getSharedEndpoint().getSwitchId());
boolean isRetryRequired = true;
SpeakerRequestError ruleFailedError = (SpeakerRequestError) rerouteError;
for (SwitchId switchId : yFlowSwitchIds) {
isRetryRequired &= !ruleFailedError.getSwitches().contains(switchId);
}
return isRetryRequired;
} else {
log.info("Received speaker request error for flow {}", flowId);
Flow flow = flowRepository.findById(flowId).orElse(null);
if (flow == null) {
log.error("Flow {} not found", flowId);
return false;
}
SpeakerRequestError ruleFailedError = (SpeakerRequestError) rerouteError;
return !ruleFailedError.getSwitches().contains(flow.getSrcSwitchId()) && !ruleFailedError.getSwitches().contains(flow.getDestSwitchId());
}
}
return false;
}
Aggregations