Search in sources :

Example 6 with YFlow

use of org.openkilda.model.YFlow 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 7 with YFlow

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

the class StartRemovingYFlowAction method perform.

@Override
protected void perform(State from, State to, Event event, YFlowDeleteContext context, YFlowDeleteFsm stateMachine) {
    String yFlowId = stateMachine.getYFlowId();
    YFlow yFlow = getYFlow(yFlowId);
    stateMachine.setDeleteOldYFlowCommands(buildYFlowDeleteCommands(yFlow, stateMachine.getCommandContext()));
}
Also used : YFlow(org.openkilda.model.YFlow)

Example 8 with YFlow

use of org.openkilda.model.YFlow 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 9 with YFlow

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

the class OnSubFlowRemovedAction method perform.

@Override
protected void perform(State from, State to, Event event, YFlowDeleteContext context, YFlowDeleteFsm stateMachine) {
    String subFlowId = context.getSubFlowId();
    if (!stateMachine.isDeletingSubFlow(subFlowId)) {
        throw new IllegalStateException("Received an event for non-pending sub-flow " + subFlowId);
    }
    String yFlowId = stateMachine.getYFlowId();
    stateMachine.saveActionToHistory("Removed a sub-flow", format("Removed sub-flow %s of y-flow %s", subFlowId, yFlowId));
    stateMachine.removeDeletingSubFlow(subFlowId);
    stateMachine.notifyEventListeners(listener -> listener.onSubFlowProcessingFinished(yFlowId, subFlowId));
    // TODO: refactor to concurrent deleting once https://github.com/telstra/open-kilda/issues/3411 is fixed.
    YFlow yFlow = getYFlow(yFlowId);
    yFlow.getSubFlows().stream().filter(subFlow -> !stateMachine.getSubFlows().contains(subFlow.getSubFlowId())).findFirst().ifPresent(subFlow -> {
        String nextSubFlowId = subFlow.getSubFlowId();
        stateMachine.addSubFlow(nextSubFlowId);
        stateMachine.addDeletingSubFlow(nextSubFlowId);
        stateMachine.notifyEventListeners(listener -> listener.onSubFlowProcessingStart(yFlowId, nextSubFlowId));
        CommandContext flowContext = stateMachine.getCommandContext().fork(nextSubFlowId);
        flowDeleteService.startFlowDeletion(flowContext, nextSubFlowId);
    });
    if (stateMachine.getDeletingSubFlows().isEmpty()) {
        stateMachine.fire(Event.ALL_SUB_FLOWS_REMOVED);
    }
}
Also used : YFlow(org.openkilda.model.YFlow) CommandContext(org.openkilda.wfm.CommandContext)

Example 10 with YFlow

use of org.openkilda.model.YFlow 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

YFlow (org.openkilda.model.YFlow)74 Flow (org.openkilda.model.Flow)30 SwitchId (org.openkilda.model.SwitchId)29 YSubFlow (org.openkilda.model.YSubFlow)26 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)19 Test (org.junit.Test)12 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)12 ArrayList (java.util.ArrayList)11 FlowStatus (org.openkilda.model.FlowStatus)10 CommandContext (org.openkilda.wfm.CommandContext)10 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)10 FlowPath (org.openkilda.model.FlowPath)9 FlowEndpoint (org.openkilda.model.FlowEndpoint)8 InstallSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest)6 Switch (org.openkilda.model.Switch)6 HashSet (java.util.HashSet)5 DeleteSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.DeleteSpeakerCommandsRequest)5 SharedEndpoint (org.openkilda.model.YFlow.SharedEndpoint)5 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4