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();
}
Aggregations