Search in sources :

Example 11 with UnknownKeyException

use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.

the class FlowDeleteService method handleAsyncResponseByFlowId.

/**
 * Handles async response from worker.
 * Used if the command identifier is unknown, so FSM is identified by the flow Id.
 */
public void handleAsyncResponseByFlowId(@NonNull String flowId, @NonNull SpeakerFlowSegmentResponse flowResponse) throws UnknownKeyException {
    String commandKey = fsmRegister.getKeyByFlowId(flowId).orElseThrow(() -> new UnknownKeyException(flowId));
    handleAsyncResponse(commandKey, flowResponse);
}
Also used : UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)

Example 12 with UnknownKeyException

use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.

the class FlowDeleteService method handleTimeoutByFlowId.

/**
 * Handles timeout case.
 * Used if the command identifier is unknown, so FSM is identified by the flow Id.
 */
public void handleTimeoutByFlowId(@NonNull String flowId) throws UnknownKeyException {
    String commandKey = fsmRegister.getKeyByFlowId(flowId).orElseThrow(() -> new UnknownKeyException(flowId));
    handleTimeout(commandKey);
}
Also used : UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)

Example 13 with UnknownKeyException

use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.

the class FlowValidationHubService method handleAsyncResponseByFlowId.

/**
 * Handles async response from worker.
 * Used if the command identifier is unknown, so FSM is identified by the flow Id.
 */
public void handleAsyncResponseByFlowId(@NonNull String flowId, @NonNull MessageData data) throws UnknownKeyException {
    String commandKey = fsmRegister.getKeyByFlowId(flowId).orElseThrow(() -> new UnknownKeyException(flowId));
    handleAsyncResponse(commandKey, data);
}
Also used : UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)

Example 14 with UnknownKeyException

use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.

the class FlowValidationHubService method handleTimeout.

/**
 * Handles timeout case.
 *
 * @param key command identifier.
 */
public void handleTimeout(@NonNull String key) throws UnknownKeyException {
    log.debug("Handling timeout for {}", key);
    FlowValidationFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
    ErrorData errorData = new ErrorData(ErrorType.OPERATION_TIMED_OUT, "Flow validation failed by timeout", "Error in FlowValidationHubService");
    fsmExecutor.fire(fsm, Event.ERROR, errorData);
    removeIfFinished(fsm, key);
}
Also used : FlowValidationFsm(org.openkilda.wfm.topology.flowhs.fsm.validation.FlowValidationFsm) ErrorData(org.openkilda.messaging.error.ErrorData) UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)

Example 15 with UnknownKeyException

use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.

the class FlowValidationHubService method handleAsyncResponse.

/**
 * Handles async response from worker.
 *
 * @param key command identifier.
 */
public void handleAsyncResponse(@NonNull String key, @NonNull MessageData data) throws UnknownKeyException {
    log.debug("Received command response {}", data);
    FlowValidationFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
    if (data instanceof SwitchFlowEntries) {
        fsmExecutor.fire(fsm, Event.RULES_RECEIVED, data);
    } else if (data instanceof SwitchMeterEntries) {
        fsmExecutor.fire(fsm, Event.METERS_RECEIVED, data);
    } else if (data instanceof SwitchMeterUnsupported) {
        SwitchMeterUnsupported meterUnsupported = (SwitchMeterUnsupported) data;
        log.info("Key: {}; Meters unsupported for switch '{};", key, meterUnsupported.getSwitchId());
        fsmExecutor.fire(fsm, Event.METERS_RECEIVED, SwitchMeterEntries.builder().switchId(meterUnsupported.getSwitchId()).meterEntries(Collections.emptyList()).build());
    } else if (data instanceof SwitchGroupEntries) {
        fsmExecutor.fire(fsm, Event.GROUPS_RECEIVED, data);
    } else if (data instanceof ErrorData) {
        fsmExecutor.fire(fsm, Event.ERROR, data);
    } else {
        log.warn("Key: {}; Unhandled message {}", key, data);
    }
    removeIfFinished(fsm, key);
}
Also used : SwitchFlowEntries(org.openkilda.messaging.info.rule.SwitchFlowEntries) SwitchMeterUnsupported(org.openkilda.messaging.info.meter.SwitchMeterUnsupported) SwitchMeterEntries(org.openkilda.messaging.info.meter.SwitchMeterEntries) SwitchGroupEntries(org.openkilda.messaging.info.rule.SwitchGroupEntries) FlowValidationFsm(org.openkilda.wfm.topology.flowhs.fsm.validation.FlowValidationFsm) ErrorData(org.openkilda.messaging.error.ErrorData) UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)

Aggregations

UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)49 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)9 SpeakerFlowSegmentResponse (org.openkilda.floodlight.api.response.SpeakerFlowSegmentResponse)9 Flow (org.openkilda.model.Flow)7 SpeakerResponse (org.openkilda.floodlight.api.response.SpeakerResponse)6 Test (org.junit.Test)5 FlowErrorResponse (org.openkilda.floodlight.flow.response.FlowErrorResponse)5 SpeakerCommandResponse (org.openkilda.floodlight.api.response.rulemanager.SpeakerCommandResponse)4 FlowRequest (org.openkilda.messaging.command.flow.FlowRequest)4 FlowEndpoint (org.openkilda.model.FlowEndpoint)4 CommandContext (org.openkilda.wfm.CommandContext)4 ErrorData (org.openkilda.messaging.error.ErrorData)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 UUID (java.util.UUID)2 Matchers.equalTo (org.hamcrest.Matchers.equalTo)2 Matchers.hasProperty (org.hamcrest.Matchers.hasProperty)2 Assert (org.junit.Assert)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertFalse (org.junit.Assert.assertFalse)2