Search in sources :

Example 1 with FlowSwapEndpointsContext

use of org.openkilda.wfm.topology.flowhs.fsm.swapendpoints.FlowSwapEndpointsContext in project open-kilda by telstra.

the class FlowSwapEndpointsHubService method handleAsyncResponse.

/**
 * Handles async response.
 */
public void handleAsyncResponse(String key, Message message) {
    log.debug("Received response {}", message);
    FlowSwapEndpointsFsm fsm = fsmRegister.getFsmByKey(key).orElse(null);
    if (fsm == null) {
        log.warn("Failed to find a FSM: received response with key {} for non pending FSM", key);
        return;
    }
    if (message instanceof InfoMessage && ((InfoMessage) message).getData() instanceof FlowResponse) {
        fsm.fire(Event.RESPONSE_RECEIVED, new FlowSwapEndpointsContext(((InfoMessage) message).getData()));
    } else if (message instanceof ErrorMessage) {
        fsm.fire(Event.ERROR_RECEIVED, new FlowSwapEndpointsContext(((ErrorMessage) message).getData()));
    } else {
        log.warn("Key: {}; Unhandled message {}", key, message);
    }
    removeIfFinished(fsm, key);
}
Also used : FlowSwapEndpointsFsm(org.openkilda.wfm.topology.flowhs.fsm.swapendpoints.FlowSwapEndpointsFsm) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) FlowSwapEndpointsContext(org.openkilda.wfm.topology.flowhs.fsm.swapendpoints.FlowSwapEndpointsContext)

Aggregations

ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)1 FlowSwapEndpointsContext (org.openkilda.wfm.topology.flowhs.fsm.swapendpoints.FlowSwapEndpointsContext)1 FlowSwapEndpointsFsm (org.openkilda.wfm.topology.flowhs.fsm.swapendpoints.FlowSwapEndpointsFsm)1