Search in sources :

Example 1 with FlowStatus

use of org.openkilda.model.FlowStatus in project open-kilda by telstra.

the class RevertYFlowAction method perform.

@Override
protected void perform(State from, State to, Event event, YFlowUpdateContext context, YFlowUpdateFsm stateMachine) {
    YFlowRequest originalFlow = stateMachine.getOriginalFlow();
    YFlowResources resources = stateMachine.getOldResources();
    FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
        YFlow yFlow = getYFlow(originalFlow.getYFlowId());
        revertFlow(yFlow, YFlowRequestMapper.INSTANCE.toYFlow(originalFlow), resources);
        return yFlow.getStatus();
    });
    stateMachine.saveActionToHistory(format("The y-flow was reverted. The status %s", flowStatus));
}
Also used : YFlow(org.openkilda.model.YFlow) YFlowResources(org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) FlowStatus(org.openkilda.model.FlowStatus)

Example 2 with FlowStatus

use of org.openkilda.model.FlowStatus in project open-kilda by telstra.

the class CompleteYFlowUpdatingAction method perform.

@Override
protected void perform(State from, State to, Event event, YFlowUpdateContext context, YFlowUpdateFsm stateMachine) {
    String yFlowId = stateMachine.getYFlowId();
    FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
        YFlow yFlow = getYFlow(yFlowId);
        yFlow.recalculateStatus();
        return yFlow.getStatus();
    });
    dashboardLogger.onYFlowStatusUpdate(yFlowId, flowStatus);
    stateMachine.saveActionToHistory(format("The y-flow status was set to %s", flowStatus));
}
Also used : YFlow(org.openkilda.model.YFlow) FlowStatus(org.openkilda.model.FlowStatus)

Example 3 with FlowStatus

use of org.openkilda.model.FlowStatus in project open-kilda by telstra.

the class CompleteYFlowReroutingAction method perform.

@Override
protected void perform(State from, State to, Event event, YFlowRerouteContext context, YFlowRerouteFsm stateMachine) {
    String yFlowId = stateMachine.getYFlowId();
    FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
        YFlow yFlow = getYFlow(yFlowId);
        yFlow.recalculateStatus();
        return yFlow.getStatus();
    });
    dashboardLogger.onYFlowStatusUpdate(yFlowId, flowStatus);
    stateMachine.saveActionToHistory(format("The y-flow status was set to %s", flowStatus));
    if (stateMachine.getErrorReason() == null) {
        stateMachine.fire(Event.YFLOW_REROUTE_FINISHED);
    } else {
        stateMachine.fire(Event.ERROR);
    }
}
Also used : YFlow(org.openkilda.model.YFlow) FlowStatus(org.openkilda.model.FlowStatus)

Example 4 with FlowStatus

use of org.openkilda.model.FlowStatus in project open-kilda by telstra.

the class RevertYFlowStatusAction method perform.

@Override
protected void perform(S from, S to, E event, C context, T stateMachine) {
    String yFlowId = stateMachine.getYFlowId();
    FlowStatus originalStatus = stateMachine.getOriginalYFlowStatus();
    if (originalStatus != null) {
        log.debug("Reverting the y-flow status of {} to {}", yFlowId, originalStatus);
        transactionManager.doInTransaction(() -> {
            YFlow flow = getYFlow(yFlowId);
            flow.setStatus(originalStatus);
        });
        dashboardLogger.onYFlowStatusUpdate(yFlowId, originalStatus);
        stateMachine.saveActionToHistory(format("The y-flow status was reverted to %s", originalStatus));
    }
}
Also used : YFlow(org.openkilda.model.YFlow) FlowStatus(org.openkilda.model.FlowStatus)

Example 5 with FlowStatus

use of org.openkilda.model.FlowStatus in project open-kilda by telstra.

the class CompleteFlowCreateAction method perform.

@Override
protected void perform(State from, State to, Event event, FlowCreateContext context, FlowCreateFsm stateMachine) {
    String flowId = stateMachine.getFlowId();
    if (!flowRepository.exists(flowId)) {
        throw new FlowProcessingException(ErrorType.NOT_FOUND, "Couldn't complete flow creation. The flow was deleted");
    }
    FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
        FlowStatus status = FlowStatus.UP;
        FlowPathStatus primaryPathStatus;
        if (stateMachine.isBackUpPrimaryPathComputationWayUsed()) {
            primaryPathStatus = FlowPathStatus.DEGRADED;
            status = FlowStatus.DEGRADED;
        } else {
            primaryPathStatus = FlowPathStatus.ACTIVE;
        }
        flowPathRepository.updateStatus(stateMachine.getForwardPathId(), primaryPathStatus);
        flowPathRepository.updateStatus(stateMachine.getReversePathId(), primaryPathStatus);
        if (stateMachine.getProtectedForwardPathId() != null && stateMachine.getProtectedReversePathId() != null) {
            FlowPathStatus protectedPathStatus;
            if (stateMachine.isBackUpProtectedPathComputationWayUsed()) {
                protectedPathStatus = FlowPathStatus.DEGRADED;
                status = FlowStatus.DEGRADED;
            } else {
                protectedPathStatus = FlowPathStatus.ACTIVE;
            }
            flowPathRepository.updateStatus(stateMachine.getProtectedForwardPathId(), protectedPathStatus);
            flowPathRepository.updateStatus(stateMachine.getProtectedReversePathId(), protectedPathStatus);
        }
        flowRepository.updateStatus(flowId, status);
        if (FlowStatus.DEGRADED.equals(status)) {
            flowRepository.updateStatusInfo(flowId, "An alternative way " + "(back up strategy or max_latency_tier2 value) of building the path was used");
        }
        return status;
    });
    dashboardLogger.onFlowStatusUpdate(flowId, flowStatus);
    stateMachine.saveActionToHistory(format("The flow status was set to %s", flowStatus));
}
Also used : FlowPathStatus(org.openkilda.model.FlowPathStatus) FlowProcessingException(org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException) FlowStatus(org.openkilda.model.FlowStatus)

Aggregations

FlowStatus (org.openkilda.model.FlowStatus)22 YFlow (org.openkilda.model.YFlow)11 Flow (org.openkilda.model.Flow)9 FlowPath (org.openkilda.model.FlowPath)4 FlowPathStatus (org.openkilda.model.FlowPathStatus)3 TimedExecution (org.openkilda.wfm.share.metrics.TimedExecution)3 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)2 PathNode (org.openkilda.messaging.info.event.PathNode)2 IslEndpoint (org.openkilda.model.IslEndpoint)2 PathSegment (org.openkilda.model.PathSegment)2 SwitchId (org.openkilda.model.SwitchId)2 YSubFlow (org.openkilda.model.YSubFlow)2 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Test (org.junit.Test)1 PersistenceManager (org.openkilda.persistence.PersistenceManager)1