Search in sources :

Example 1 with State

use of org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationFsm.State in project open-kilda by telstra.

the class CompleteYFlowValidationAction method performWithResponse.

@Override
public Optional<Message> performWithResponse(State from, State to, Event event, YFlowValidationContext context, YFlowValidationFsm stateMachine) throws FlowNotFoundException, SwitchNotFoundException {
    YFlowDiscrepancyDto resourcesValidationResult = validationService.validateYFlowResources(stateMachine.getYFlowId(), stateMachine.getReceivedRules(), stateMachine.getReceivedMeters());
    YFlowValidationResponse result = new YFlowValidationResponse();
    result.setYFlowValidationResult(resourcesValidationResult);
    result.setSubFlowValidationResults(stateMachine.getSubFlowValidationResults());
    boolean notAsExpected = !resourcesValidationResult.isAsExpected() || stateMachine.getSubFlowValidationResults().stream().map(FlowValidationResponse::getAsExpected).anyMatch(n -> !n);
    result.setAsExpected(!notAsExpected);
    CommandContext commandContext = stateMachine.getCommandContext();
    InfoMessage message = new InfoMessage(result, commandContext.getCreateTime(), commandContext.getCorrelationId());
    return Optional.of(message);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) FlowValidationResponse(org.openkilda.messaging.info.flow.FlowValidationResponse) YFlowValidationFsm(org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationFsm) CommandContext(org.openkilda.wfm.CommandContext) YFlowValidationContext(org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationContext) SwitchNotFoundException(org.openkilda.wfm.error.SwitchNotFoundException) Slf4j(lombok.extern.slf4j.Slf4j) NbTrackableAction(org.openkilda.wfm.topology.flowhs.fsm.common.actions.NbTrackableAction) YFlowDiscrepancyDto(org.openkilda.messaging.command.yflow.YFlowDiscrepancyDto) Event(org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationFsm.Event) Optional(java.util.Optional) YFlowValidationResponse(org.openkilda.messaging.command.yflow.YFlowValidationResponse) YFlowValidationService(org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationService) State(org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationFsm.State) FlowNotFoundException(org.openkilda.wfm.error.FlowNotFoundException) YFlowValidationResponse(org.openkilda.messaging.command.yflow.YFlowValidationResponse) CommandContext(org.openkilda.wfm.CommandContext) InfoMessage(org.openkilda.messaging.info.InfoMessage) YFlowDiscrepancyDto(org.openkilda.messaging.command.yflow.YFlowDiscrepancyDto) FlowValidationResponse(org.openkilda.messaging.info.flow.FlowValidationResponse) YFlowValidationResponse(org.openkilda.messaging.command.yflow.YFlowValidationResponse)

Aggregations

Optional (java.util.Optional)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Message (org.openkilda.messaging.Message)1 YFlowDiscrepancyDto (org.openkilda.messaging.command.yflow.YFlowDiscrepancyDto)1 YFlowValidationResponse (org.openkilda.messaging.command.yflow.YFlowValidationResponse)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 FlowValidationResponse (org.openkilda.messaging.info.flow.FlowValidationResponse)1 CommandContext (org.openkilda.wfm.CommandContext)1 FlowNotFoundException (org.openkilda.wfm.error.FlowNotFoundException)1 SwitchNotFoundException (org.openkilda.wfm.error.SwitchNotFoundException)1 NbTrackableAction (org.openkilda.wfm.topology.flowhs.fsm.common.actions.NbTrackableAction)1 YFlowValidationContext (org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationContext)1 YFlowValidationFsm (org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationFsm)1 Event (org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationFsm.Event)1 State (org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationFsm.State)1 YFlowValidationService (org.openkilda.wfm.topology.flowhs.fsm.yflow.validation.YFlowValidationService)1