Search in sources :

Example 1 with EndpointUpdate

use of org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm.EndpointUpdate in project open-kilda by telstra.

the class UpdateFlowAction method performWithResponse.

@Override
protected Optional<Message> performWithResponse(State from, State to, Event event, FlowUpdateContext context, FlowUpdateFsm stateMachine) {
    RequestedFlow targetFlow = stateMachine.getTargetFlow();
    String flowId = targetFlow.getFlowId();
    transactionManager.doInTransaction(() -> {
        Flow flow = getFlow(flowId);
        log.debug("Updating the flow {} with properties: {}", flowId, targetFlow);
        RequestedFlow originalFlow = RequestedFlowMapper.INSTANCE.toRequestedFlow(flow);
        stateMachine.setOldTargetPathComputationStrategy(flow.getTargetPathComputationStrategy());
        stateMachine.setOriginalFlow(originalFlow);
        stateMachine.setOriginalDiverseFlowGroup(flow.getDiverseGroupId());
        stateMachine.setOriginalAffinityFlowGroup(flow.getAffinityGroupId());
        // Complete target flow in FSM with values from original flow
        stateMachine.setTargetFlow(updateFlow(flow, targetFlow));
        EndpointUpdate endpointUpdate = updateEndpointRulesOnly(originalFlow, targetFlow, stateMachine.getOriginalDiverseFlowGroup(), flow.getDiverseGroupId(), stateMachine.getOriginalAffinityFlowGroup(), flow.getAffinityGroupId());
        stateMachine.setEndpointUpdate(endpointUpdate);
        if (endpointUpdate.isPartialUpdate()) {
            FlowLoopOperation flowLoopOperation = detectFlowLoopOperation(originalFlow, targetFlow);
            stateMachine.setFlowLoopOperation(flowLoopOperation);
            stateMachine.setNewPrimaryForwardPath(flow.getForwardPathId());
            stateMachine.setNewPrimaryReversePath(flow.getReversePathId());
            stateMachine.setNewProtectedForwardPath(flow.getProtectedForwardPathId());
            stateMachine.setNewProtectedReversePath(flow.getProtectedReversePathId());
            FlowDumpData dumpData = HistoryMapper.INSTANCE.map(flow, flow.getForwardPath(), flow.getReversePath(), DumpType.STATE_AFTER);
            stateMachine.saveActionWithDumpToHistory("New endpoints were stored for flow", format("The flow endpoints were updated for: %s / %s", flow.getSrcSwitch(), flow.getDestSwitch()), dumpData);
        }
    });
    stateMachine.saveActionToHistory("The flow properties were updated");
    if (stateMachine.getEndpointUpdate().isPartialUpdate()) {
        stateMachine.saveActionToHistory("Skip paths and resources allocation");
        stateMachine.fire(Event.UPDATE_ENDPOINT_RULES_ONLY);
    }
    return Optional.empty();
}
Also used : FlowDumpData(org.openkilda.wfm.share.history.model.FlowDumpData) EndpointUpdate(org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm.EndpointUpdate) FlowLoopOperation(org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm.FlowLoopOperation) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow)

Aggregations

Flow (org.openkilda.model.Flow)1 YFlow (org.openkilda.model.YFlow)1 YSubFlow (org.openkilda.model.YSubFlow)1 FlowDumpData (org.openkilda.wfm.share.history.model.FlowDumpData)1 EndpointUpdate (org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm.EndpointUpdate)1 FlowLoopOperation (org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm.FlowLoopOperation)1 RequestedFlow (org.openkilda.wfm.topology.flowhs.model.RequestedFlow)1