Search in sources :

Example 6 with FlowRerouteRequest

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());
}
Also used : FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest)

Example 7 with FlowRerouteRequest

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);
}
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 8 with FlowRerouteRequest

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());
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) Isl(org.openkilda.model.Isl) CommandContext(org.openkilda.wfm.CommandContext) Values(org.apache.storm.tuple.Values) SwitchId(org.openkilda.model.SwitchId) MessageException(org.openkilda.messaging.error.MessageException) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) FlowPath(org.openkilda.model.FlowPath) HashSet(java.util.HashSet) IslMapper(org.openkilda.wfm.share.mappers.IslMapper)

Example 9 with FlowRerouteRequest

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);
        }
    }
}
Also used : YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest)

Example 10 with FlowRerouteRequest

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);
    }
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) MessageData(org.openkilda.messaging.MessageData) FlowPathSwapRequest(org.openkilda.messaging.command.flow.FlowPathSwapRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) PathSwapResult(org.openkilda.messaging.info.reroute.PathSwapResult)

Aggregations

FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)49 Test (org.junit.Test)27 Flow (org.openkilda.model.Flow)23 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)14 Values (org.apache.storm.tuple.Values)10 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)9 CommandMessage (org.openkilda.messaging.command.CommandMessage)8 IslEndpoint (org.openkilda.model.IslEndpoint)8 CommandContext (org.openkilda.wfm.CommandContext)7 FlowPath (org.openkilda.model.FlowPath)6 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)5 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)4 GetPathsResult (org.openkilda.pce.GetPathsResult)4 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)4 HashSet (java.util.HashSet)3 RerouteQueue (org.openkilda.wfm.topology.reroute.model.RerouteQueue)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Ignore (org.junit.Ignore)2 FlowErrorResponse (org.openkilda.floodlight.flow.response.FlowErrorResponse)2