Search in sources :

Example 6 with FlowStatus

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

the class UpdateFlowStatusAction method perform.

@TimedExecution("fsm.update_flow_status")
@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
    String flowId = stateMachine.getFlowId();
    FlowStatus resultStatus = transactionManager.doInTransaction(() -> {
        Flow flow = getFlow(flowId);
        FlowStatus flowStatus = flow.computeFlowStatus();
        if (flowStatus != flow.getStatus()) {
            dashboardLogger.onFlowStatusUpdate(flowId, flowStatus);
            flow.setStatus(flowStatus);
            flow.setStatusInfo(getFlowStatusInfo(flow, flowStatus, stateMachine));
        } else if (FlowStatus.DEGRADED.equals(flowStatus)) {
            flow.setStatusInfo(getDegradedFlowStatusInfo(flow, stateMachine));
        }
        stateMachine.setNewFlowStatus(flowStatus);
        return flowStatus;
    });
    stateMachine.saveActionToHistory(format("The flow status was set to %s", resultStatus));
}
Also used : FlowStatus(org.openkilda.model.FlowStatus) Flow(org.openkilda.model.Flow) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution)

Example 7 with FlowStatus

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

the class OnNoPathFoundAction method perform.

@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
    String flowId = stateMachine.getFlowId();
    log.debug("Updating the flow status of {} after 'no path found' event", flowId);
    FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
        stateMachine.setOriginalFlowStatus(null);
        Flow flow = getFlow(flowId);
        if (primaryPathNotFound && stateMachine.isReroutePrimary() && stateMachine.getNewPrimaryForwardPath() == null && stateMachine.getNewPrimaryReversePath() == null) {
            if (flow.getForwardPathId() == null && flow.getReversePathId() == null) {
                log.debug("Skip marking flow path statuses as inactive: flow {} doesn't have main paths", flowId);
            } else {
                log.debug("Set the flow path status of {}/{} to inactive", flow.getForwardPathId(), flow.getReversePathId());
                if (flow.getForwardPathId() != null) {
                    flow.getForwardPath().setStatus(FlowPathStatus.INACTIVE);
                }
                if (flow.getReversePathId() != null) {
                    flow.getReversePath().setStatus(FlowPathStatus.INACTIVE);
                }
            }
        }
        if (stateMachine.isRerouteProtected() && stateMachine.getNewProtectedForwardPath() == null && stateMachine.getNewProtectedReversePath() == null) {
            if (flow.getProtectedForwardPathId() == null && flow.getProtectedReversePathId() == null) {
                log.debug("Skip marking flow path statuses as inactive: flow {} doesn't have protected paths", flowId);
            } else {
                log.debug("Set the flow path status of {}/{} to inactive", flow.getProtectedForwardPathId(), flow.getProtectedReversePathId());
                if (flow.getProtectedForwardPathId() != null) {
                    flow.getProtectedForwardPath().setStatus(FlowPathStatus.INACTIVE);
                }
                if (flow.getProtectedReversePathId() != null) {
                    flow.getProtectedReversePath().setStatus(FlowPathStatus.INACTIVE);
                }
            }
        }
        FlowStatus newFlowStatus = flow.computeFlowStatus();
        if (newFlowStatus != FlowStatus.DOWN && newFlowStatus != FlowStatus.DEGRADED) {
            log.error("Computed unexpected status {} of flow {} after 'no path found' event", newFlowStatus, flow);
            newFlowStatus = FlowStatus.DOWN;
        }
        log.debug("Setting the flow status of {} to {}", flowId, newFlowStatus);
        dashboardLogger.onFlowStatusUpdate(flowId, newFlowStatus);
        flow.setStatus(newFlowStatus);
        flow.setStatusInfo(stateMachine.getErrorReason());
        stateMachine.setNewFlowStatus(newFlowStatus);
        return newFlowStatus;
    });
    stateMachine.saveActionToHistory(String.format("The flow status was set to %s", flowStatus));
}
Also used : FlowStatus(org.openkilda.model.FlowStatus) Flow(org.openkilda.model.Flow)

Example 8 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 9 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 10 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)

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