use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.
the class RevertNewRulesAction method getSpeakerRequestBuildContextForRemoval.
private SpeakerRequestBuildContext getSpeakerRequestBuildContextForRemoval(FlowUpdateFsm stateMachine, boolean removeMeters) {
RequestedFlow originalFlow = stateMachine.getOriginalFlow();
RequestedFlow targetFlow = stateMachine.getTargetFlow();
return buildSpeakerContextForRemovalIngressAndShared(targetFlow, originalFlow, removeMeters);
}
use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.
the class RemoveOldRulesAction method getSpeakerRequestBuildContext.
private SpeakerRequestBuildContext getSpeakerRequestBuildContext(FlowUpdateFsm stateMachine, boolean removeMeters) {
RequestedFlow originalFlow = stateMachine.getOriginalFlow();
RequestedFlow targetFlow = stateMachine.getTargetFlow();
return buildSpeakerContextForRemovalIngressAndShared(originalFlow, targetFlow, removeMeters);
}
use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.
the class OnFinishedAction method updateFlowMonitoring.
private void updateFlowMonitoring(FlowUpdateFsm stateMachine) {
// If was single flow do nothing
RequestedFlow original = stateMachine.getOriginalFlow();
RequestedFlow target = stateMachine.getTargetFlow();
boolean originalNotSingle = !original.getSrcSwitch().equals(original.getDestSwitch());
boolean targetNotSingle = !target.getSrcSwitch().equals(target.getDestSwitch());
boolean srcUpdated = !(original.getSrcSwitch().equals(target.getSrcSwitch()) && original.getSrcPort() == target.getSrcPort() && original.getSrcVlan() == target.getSrcVlan() && original.getSrcInnerVlan() == target.getSrcInnerVlan());
boolean dstUpdated = !(original.getDestSwitch().equals(target.getDestSwitch()) && original.getDestPort() == target.getDestPort() && original.getDestVlan() == target.getDestVlan() && original.getDestInnerVlan() == target.getDestInnerVlan());
// clean up old if old not single
if (originalNotSingle && (srcUpdated || dstUpdated)) {
stateMachine.getCarrier().sendDeactivateFlowMonitoring(stateMachine.getFlowId(), original.getSrcSwitch(), original.getDestSwitch());
}
// setup new if new not single
if (targetNotSingle && (srcUpdated || dstUpdated)) {
stateMachine.getCarrier().sendActivateFlowMonitoring(target);
}
}
use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.
the class OnFinishedAction method sendPeriodicPingNotification.
private void sendPeriodicPingNotification(FlowUpdateFsm stateMachine) {
RequestedFlow requestedFlow = stateMachine.getTargetFlow();
stateMachine.getCarrier().sendPeriodicPingNotification(requestedFlow.getFlowId(), requestedFlow.isPeriodicPings());
}
use of org.openkilda.wfm.topology.flowhs.model.RequestedFlow in project open-kilda by telstra.
the class ValidateFlowsAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowSwapEndpointsContext context, FlowSwapEndpointsFsm stateMachine) {
RequestedFlow firstTargetFlow = stateMachine.getFirstTargetFlow();
RequestedFlow secondTargetFlow = stateMachine.getSecondTargetFlow();
if (!featureTogglesRepository.getOrDefault().getUpdateFlowEnabled()) {
throw new FlowProcessingException(ErrorType.NOT_PERMITTED, "Flow update feature is disabled");
}
try {
flowValidator.validateForSwapEndpoints(firstTargetFlow, secondTargetFlow);
} catch (InvalidFlowException e) {
stateMachine.fireValidationError(new ErrorData(e.getType(), FlowSwapEndpointsFsm.GENERIC_ERROR_MESSAGE, e.getMessage()));
return;
} catch (UnavailableFlowEndpointException e) {
stateMachine.fireValidationError(new ErrorData(ErrorType.DATA_INVALID, FlowSwapEndpointsFsm.GENERIC_ERROR_MESSAGE, e.getMessage()));
return;
}
try {
transactionManager.doInTransaction(() -> {
Flow foundFirstFlow = checkAndGetFlow(stateMachine.getFirstFlowId());
Flow foundSecondFlow = checkAndGetFlow(stateMachine.getSecondFlowId());
stateMachine.setFirstOriginalFlow(foundFirstFlow);
stateMachine.setSecondOriginalFlow(foundSecondFlow);
foundFirstFlow.setStatus(FlowStatus.IN_PROGRESS);
foundSecondFlow.setStatus(FlowStatus.IN_PROGRESS);
});
} catch (FlowProcessingException e) {
stateMachine.fireValidationError(new ErrorData(e.getErrorType(), FlowSwapEndpointsFsm.GENERIC_ERROR_MESSAGE, e.getMessage()));
return;
}
stateMachine.saveNewEventToHistory(stateMachine.getFirstFlowId(), format("Current flow and flow %s were validated successfully", stateMachine.getSecondFlowId()), FlowEventData.Event.SWAP_ENDPOINTS);
stateMachine.saveNewEventToHistory(stateMachine.getSecondFlowId(), format("Current flow and flow %s were validated successfully", stateMachine.getFirstFlowId()), FlowEventData.Event.SWAP_ENDPOINTS);
stateMachine.fireNext();
}
Aggregations