Search in sources :

Example 1 with FlowDumpData

use of org.openkilda.wfm.share.history.model.FlowDumpData in project open-kilda by telstra.

the class BaseResourceAllocationAction method saveAllocationActionWithDumpsToHistory.

protected void saveAllocationActionWithDumpsToHistory(T stateMachine, Flow flow, String pathType, FlowPathPair newFlowPaths) {
    FlowDumpData dumpData = HistoryMapper.INSTANCE.map(flow, newFlowPaths.getForward(), newFlowPaths.getReverse(), DumpType.STATE_AFTER);
    stateMachine.saveActionWithDumpToHistory(format("New %s paths were created", pathType), format("The flow paths %s / %s were created (with allocated resources)", newFlowPaths.getForward().getPathId(), newFlowPaths.getReverse().getPathId()), dumpData);
}
Also used : FlowDumpData(org.openkilda.wfm.share.history.model.FlowDumpData)

Example 2 with FlowDumpData

use of org.openkilda.wfm.share.history.model.FlowDumpData in project open-kilda by telstra.

the class ResourcesAllocationAction method saveHistory.

private void saveHistory(FlowCreateFsm stateMachine, Flow flow) {
    FlowDumpData primaryPathsDumpData = HistoryMapper.INSTANCE.map(flow, flow.getForwardPath(), flow.getReversePath(), DumpType.STATE_AFTER);
    stateMachine.saveActionWithDumpToHistory("New primary paths were created", format("The flow paths were created (with allocated resources): %s / %s", flow.getForwardPathId(), flow.getReversePathId()), primaryPathsDumpData);
    if (flow.isAllocateProtectedPath()) {
        FlowDumpData protectedPathsDumpData = HistoryMapper.INSTANCE.map(flow, flow.getProtectedForwardPath(), flow.getProtectedReversePath(), DumpType.STATE_AFTER);
        stateMachine.saveActionWithDumpToHistory("New protected paths were created", format("The flow paths were created (with allocated resources): %s / %s", flow.getProtectedForwardPathId(), flow.getProtectedReversePathId()), protectedPathsDumpData);
    }
}
Also used : FlowDumpData(org.openkilda.wfm.share.history.model.FlowDumpData)

Example 3 with FlowDumpData

use of org.openkilda.wfm.share.history.model.FlowDumpData in project open-kilda by telstra.

the class SkipPathsAndResourcesDeallocationAction method perform.

@Override
public void perform(State from, State to, Event event, FlowUpdateContext context, FlowUpdateFsm stateMachine) {
    if (stateMachine.getEndpointUpdate().isPartialUpdate()) {
        FlowDumpData dumpData = HistoryMapper.INSTANCE.map(RequestedFlowMapper.INSTANCE.toFlow(stateMachine.getOriginalFlow()), getFlowPath(stateMachine.getNewPrimaryForwardPath()), getFlowPath(stateMachine.getNewPrimaryReversePath()), DumpType.STATE_BEFORE);
        stateMachine.saveActionWithDumpToHistory("New endpoints were stored for flow", format("The flow endpoints were updated for: %s / %s", stateMachine.getTargetFlow().getSrcSwitch(), stateMachine.getTargetFlow().getDestSwitch()), dumpData);
        stateMachine.fire(Event.UPDATE_ENDPOINT_RULES_ONLY);
    }
}
Also used : FlowDumpData(org.openkilda.wfm.share.history.model.FlowDumpData)

Example 4 with FlowDumpData

use of org.openkilda.wfm.share.history.model.FlowDumpData 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)

Example 5 with FlowDumpData

use of org.openkilda.wfm.share.history.model.FlowDumpData in project open-kilda by telstra.

the class RevertResourceAllocationAction method saveHistory.

private void saveHistory(FlowUpdateFsm stateMachine, Flow flow, FlowResources resources) {
    FlowDumpData flowDumpData = HistoryMapper.INSTANCE.map(flow, resources, DumpType.STATE_BEFORE);
    stateMachine.saveActionWithDumpToHistory("Flow resources were deallocated", format("The flow resources for %s / %s were deallocated", resources.getForward().getPathId(), resources.getReverse().getPathId()), flowDumpData);
}
Also used : FlowDumpData(org.openkilda.wfm.share.history.model.FlowDumpData)

Aggregations

FlowDumpData (org.openkilda.wfm.share.history.model.FlowDumpData)8 Flow (org.openkilda.model.Flow)1 YFlow (org.openkilda.model.YFlow)1 YSubFlow (org.openkilda.model.YSubFlow)1 FlowSegmentCookieBuilder (org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder)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