use of org.openkilda.wfm.topology.flowhs.fsm.reroute.FlowRerouteFsm.Event in project open-kilda by telstra.
the class RevertResourceAllocationAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm 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);
}
Aggregations