Search in sources :

Example 1 with RerouteInProgressError

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);
}
Also used : RerouteInProgressError(org.openkilda.messaging.info.reroute.error.RerouteInProgressError) FlowRerouteContext(org.openkilda.wfm.topology.flowhs.fsm.reroute.FlowRerouteContext) SpeakerFlowSegmentResponse(org.openkilda.floodlight.api.response.SpeakerFlowSegmentResponse) FlowErrorResponse(org.openkilda.floodlight.flow.response.FlowErrorResponse) FlowProcessingFsmRegister(org.openkilda.wfm.topology.flowhs.service.common.FlowProcessingFsmRegister) NonNull(lombok.NonNull) Config(org.openkilda.wfm.topology.flowhs.fsm.reroute.FlowRerouteFsm.Config) CommandContext(org.openkilda.wfm.CommandContext) FlowRerouteFsm(org.openkilda.wfm.topology.flowhs.fsm.reroute.FlowRerouteFsm) Event(org.openkilda.wfm.topology.flowhs.fsm.reroute.FlowRerouteFsm.Event) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Slf4j(lombok.extern.slf4j.Slf4j) FlowProcessingService(org.openkilda.wfm.topology.flowhs.service.common.FlowProcessingService) PathComputer(org.openkilda.pce.PathComputer) UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException) FlowResourcesManager(org.openkilda.wfm.share.flow.resources.FlowResourcesManager) FsmExecutor(org.openkilda.wfm.share.utils.FsmExecutor) PersistenceManager(org.openkilda.persistence.PersistenceManager) FlowRerouteFsm(org.openkilda.wfm.topology.flowhs.fsm.reroute.FlowRerouteFsm) FlowRerouteContext(org.openkilda.wfm.topology.flowhs.fsm.reroute.FlowRerouteContext) UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException) RerouteInProgressError(org.openkilda.messaging.info.reroute.error.RerouteInProgressError)

Example 2 with RerouteInProgressError

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();
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) RerouteInProgressError(org.openkilda.messaging.info.reroute.error.RerouteInProgressError) Test(org.junit.Test)

Example 3 with RerouteInProgressError

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;
}
Also used : YFlow(org.openkilda.model.YFlow) NoPathFoundError(org.openkilda.messaging.info.reroute.error.NoPathFoundError) SwitchId(org.openkilda.model.SwitchId) SpeakerRequestError(org.openkilda.messaging.info.reroute.error.SpeakerRequestError) RerouteInProgressError(org.openkilda.messaging.info.reroute.error.RerouteInProgressError) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow)

Aggregations

RerouteInProgressError (org.openkilda.messaging.info.reroute.error.RerouteInProgressError)3 NonNull (lombok.NonNull)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Test (org.junit.Test)1 SpeakerFlowSegmentResponse (org.openkilda.floodlight.api.response.SpeakerFlowSegmentResponse)1 FlowErrorResponse (org.openkilda.floodlight.flow.response.FlowErrorResponse)1 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)1 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)1 NoPathFoundError (org.openkilda.messaging.info.reroute.error.NoPathFoundError)1 SpeakerRequestError (org.openkilda.messaging.info.reroute.error.SpeakerRequestError)1 Flow (org.openkilda.model.Flow)1 SwitchId (org.openkilda.model.SwitchId)1 YFlow (org.openkilda.model.YFlow)1 YSubFlow (org.openkilda.model.YSubFlow)1 PathComputer (org.openkilda.pce.PathComputer)1 PersistenceManager (org.openkilda.persistence.PersistenceManager)1 CommandContext (org.openkilda.wfm.CommandContext)1 FlowResourcesManager (org.openkilda.wfm.share.flow.resources.FlowResourcesManager)1 FsmExecutor (org.openkilda.wfm.share.utils.FsmExecutor)1 UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)1