Search in sources :

Example 1 with Event

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

the class RevertResourceAllocationAction method perform.

@Override
protected void perform(State from, State to, Event event, FlowUpdateContext context, FlowUpdateFsm stateMachine) {
    Flow flow = getFlow(stateMachine.getFlowId());
    Stream.of(stateMachine.getNewPrimaryResources(), stateMachine.getNewProtectedResources()).filter(Objects::nonNull).forEach(resources -> {
        transactionManager.doInTransaction(() -> resourcesManager.deallocatePathResources(resources));
        saveHistory(stateMachine, flow, resources);
    });
    stateMachine.getRejectedResources().forEach(flowResources -> {
        transactionManager.doInTransaction(() -> resourcesManager.deallocatePathResources(flowResources));
        saveHistory(stateMachine, flow, flowResources);
    });
    Stream.of(stateMachine.getNewPrimaryForwardPath(), stateMachine.getNewPrimaryReversePath(), stateMachine.getNewProtectedForwardPath(), stateMachine.getNewProtectedReversePath()).forEach(pathId -> flowPathRepository.remove(pathId).ifPresent(flowPath -> {
        updateIslsForFlowPath(flowPath);
        saveRemovalActionWithDumpToHistory(stateMachine, flow, flowPath);
    }));
    stateMachine.getRejectedPaths().stream().forEach(pathId -> flowPathRepository.remove(pathId).ifPresent(flowPath -> {
        updateIslsForFlowPath(flowPath);
        saveRemovalActionWithDumpToHistory(stateMachine, flow, flowPath);
    }));
    stateMachine.setNewPrimaryResources(null);
    stateMachine.setNewPrimaryForwardPath(null);
    stateMachine.setNewPrimaryReversePath(null);
    stateMachine.setNewProtectedResources(null);
    stateMachine.setNewProtectedForwardPath(null);
    stateMachine.setNewProtectedReversePath(null);
}
Also used : HistoryMapper(org.openkilda.wfm.share.mappers.HistoryMapper) FlowUpdateFsm(org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm) State(org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm.State) FlowResources(org.openkilda.wfm.share.flow.resources.FlowResources) String.format(java.lang.String.format) Event(org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm.Event) Objects(java.util.Objects) BaseFlowPathRemovalAction(org.openkilda.wfm.topology.flowhs.fsm.common.actions.BaseFlowPathRemovalAction) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) Flow(org.openkilda.model.Flow) FlowUpdateContext(org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateContext) FlowDumpData(org.openkilda.wfm.share.history.model.FlowDumpData) FlowResourcesManager(org.openkilda.wfm.share.flow.resources.FlowResourcesManager) DumpType(org.openkilda.wfm.share.history.model.FlowDumpData.DumpType) PersistenceManager(org.openkilda.persistence.PersistenceManager) Flow(org.openkilda.model.Flow)

Aggregations

String.format (java.lang.String.format)1 Objects (java.util.Objects)1 Stream (java.util.stream.Stream)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Flow (org.openkilda.model.Flow)1 PersistenceManager (org.openkilda.persistence.PersistenceManager)1 FlowResources (org.openkilda.wfm.share.flow.resources.FlowResources)1 FlowResourcesManager (org.openkilda.wfm.share.flow.resources.FlowResourcesManager)1 FlowDumpData (org.openkilda.wfm.share.history.model.FlowDumpData)1 DumpType (org.openkilda.wfm.share.history.model.FlowDumpData.DumpType)1 HistoryMapper (org.openkilda.wfm.share.mappers.HistoryMapper)1 BaseFlowPathRemovalAction (org.openkilda.wfm.topology.flowhs.fsm.common.actions.BaseFlowPathRemovalAction)1 FlowUpdateContext (org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateContext)1 FlowUpdateFsm (org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm)1 Event (org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm.Event)1 State (org.openkilda.wfm.topology.flowhs.fsm.update.FlowUpdateFsm.State)1