Search in sources :

Example 1 with FlowMirrorPointCreateFsm

use of org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateFsm in project open-kilda by telstra.

the class FlowMirrorPointCreateService method handleAsyncResponse.

/**
 * Handles async response from worker.
 *
 * @param key command identifier.
 */
public void handleAsyncResponse(String key, SpeakerFlowSegmentResponse flowResponse) {
    log.debug("Received flow command response {}", flowResponse);
    FlowMirrorPointCreateFsm 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;
    }
    FlowMirrorPointCreateContext context = FlowMirrorPointCreateContext.builder().speakerFlowResponse(flowResponse).build();
    if (flowResponse instanceof FlowErrorResponse) {
        fsmExecutor.fire(fsm, Event.ERROR_RECEIVED, context);
    } else {
        fsmExecutor.fire(fsm, Event.RESPONSE_RECEIVED, context);
    }
    removeIfFinished(fsm, key);
}
Also used : FlowMirrorPointCreateFsm(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateFsm) FlowErrorResponse(org.openkilda.floodlight.flow.response.FlowErrorResponse) FlowMirrorPointCreateContext(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateContext)

Example 2 with FlowMirrorPointCreateFsm

use of org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateFsm in project open-kilda by telstra.

the class FlowMirrorPointCreateService method handleRequest.

private void handleRequest(String key, CommandContext commandContext, FlowMirrorPointCreateRequest request) {
    String flowId = request.getFlowId();
    log.debug("Handling flow create mirror point request with key {}, flow ID: {}, and flow mirror ID: {}", key, flowId, request.getMirrorPointId());
    if (fsmRegister.hasRegisteredFsmWithKey(key)) {
        log.error("Attempt to create a FSM with key {}, while there's another active FSM with the same key.", key);
        return;
    }
    if (fsmRegister.hasRegisteredFsmWithFlowId(flowId)) {
        sendErrorResponseToNorthbound(ErrorType.REQUEST_INVALID, "Could not update flow", format("Flow %s is updating now", flowId), commandContext);
        log.error("Attempt to create a FSM with key {}, while there's another active FSM for the same flowId {}.", key, flowId);
        return;
    }
    FlowMirrorPointCreateFsm fsm = fsmFactory.newInstance(commandContext, flowId);
    fsmRegister.registerFsm(key, fsm);
    FlowMirrorPointCreateContext context = FlowMirrorPointCreateContext.builder().mirrorPoint(RequestedFlowMirrorPointMapper.INSTANCE.map(request)).build();
    fsmExecutor.fire(fsm, Event.NEXT, context);
    removeIfFinished(fsm, key);
}
Also used : FlowMirrorPointCreateFsm(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateFsm) FlowMirrorPointCreateContext(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateContext)

Example 3 with FlowMirrorPointCreateFsm

use of org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateFsm in project open-kilda by telstra.

the class FlowMirrorPointCreateService method handleTimeout.

/**
 * Handles timeout case.
 *
 * @param key command identifier.
 */
public void handleTimeout(String key) {
    log.debug("Handling timeout for {}", key);
    FlowMirrorPointCreateFsm fsm = fsmRegister.getFsmByKey(key).orElse(null);
    if (fsm == null) {
        log.warn("Failed to find a FSM: timeout event for non pending FSM with key {}", key);
        return;
    }
    fsmExecutor.fire(fsm, Event.TIMEOUT, null);
    removeIfFinished(fsm, key);
}
Also used : FlowMirrorPointCreateFsm(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateFsm)

Aggregations

FlowMirrorPointCreateFsm (org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateFsm)3 FlowMirrorPointCreateContext (org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.create.FlowMirrorPointCreateContext)2 FlowErrorResponse (org.openkilda.floodlight.flow.response.FlowErrorResponse)1