Search in sources :

Example 1 with IllegalFlowStateException

use of org.openkilda.wfm.error.IllegalFlowStateException in project open-kilda by telstra.

the class FlowValidationFsm method receiveData.

protected void receiveData(State from, State to, Event event, Object context) {
    Flow flow;
    try {
        flow = service.checkFlowStatusAndGetFlow(flowId);
    } catch (FlowNotFoundException e) {
        log.error("Flow {} not found when sending commands to SpeakerWorkerBolt", flowId, e);
        sendException(e.getMessage(), "Receiving rules operation in FlowValidationFsm", ErrorType.NOT_FOUND);
        return;
    } catch (IllegalFlowStateException e) {
        log.error("Could not validate flow: Flow {} is in DOWN state", flowId, e);
        sendException("Could not validate flow", format("Could not validate flow: Flow %s is in DOWN state", flowId), ErrorType.UNPROCESSABLE_REQUEST);
        return;
    }
    List<SwitchId> switchIds = service.getSwitchIdListByFlowId(flowId);
    awaitingRules = switchIds.size();
    log.debug("Send commands to get rules on the switches");
    switchIds.forEach(switchId -> getCarrier().sendSpeakerRequest(flowId, new DumpRulesForFlowHsRequest(switchId)));
    log.debug("Send commands to get meters on the termination switches");
    awaitingMeters = TERMINATION_SWITCHES_COUNT;
    getCarrier().sendSpeakerRequest(flowId, new DumpMetersForFlowHsRequest(flow.getSrcSwitchId()));
    getCarrier().sendSpeakerRequest(flowId, new DumpMetersForFlowHsRequest(flow.getDestSwitchId()));
    log.debug("Send commands to get groups on the termination switches");
    awaitingGroups = TERMINATION_SWITCHES_COUNT;
    getCarrier().sendSpeakerRequest(flowId, new DumpGroupsForFlowHsRequest(flow.getSrcSwitchId()));
    getCarrier().sendSpeakerRequest(flowId, new DumpGroupsForFlowHsRequest(flow.getDestSwitchId()));
}
Also used : FlowNotFoundException(org.openkilda.wfm.error.FlowNotFoundException) DumpGroupsForFlowHsRequest(org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) IllegalFlowStateException(org.openkilda.wfm.error.IllegalFlowStateException) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow)

Aggregations

DumpGroupsForFlowHsRequest (org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest)1 DumpMetersForFlowHsRequest (org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest)1 DumpRulesForFlowHsRequest (org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest)1 Flow (org.openkilda.model.Flow)1 SwitchId (org.openkilda.model.SwitchId)1 FlowNotFoundException (org.openkilda.wfm.error.FlowNotFoundException)1 IllegalFlowStateException (org.openkilda.wfm.error.IllegalFlowStateException)1