Search in sources :

Example 1 with FlowMirrorPointDeleteFsm

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

the class FlowMirrorPointDeleteService 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);
    FlowMirrorPointDeleteFsm 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;
    }
    FlowMirrorPointDeleteContext context = FlowMirrorPointDeleteContext.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 : FlowErrorResponse(org.openkilda.floodlight.flow.response.FlowErrorResponse) FlowMirrorPointDeleteFsm(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.delete.FlowMirrorPointDeleteFsm) FlowMirrorPointDeleteContext(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.delete.FlowMirrorPointDeleteContext)

Example 2 with FlowMirrorPointDeleteFsm

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

the class FlowMirrorPointDeleteService method handleRequest.

private void handleRequest(String key, CommandContext commandContext, FlowMirrorPointDeleteRequest request) {
    String flowId = request.getFlowId();
    log.debug("Handling flow delete 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;
    }
    FlowMirrorPointDeleteFsm fsm = fsmFactory.newInstance(commandContext, flowId);
    fsmRegister.registerFsm(key, fsm);
    FlowMirrorPointDeleteContext context = FlowMirrorPointDeleteContext.builder().flowMirrorPointId(request.getMirrorPointId()).build();
    fsmExecutor.fire(fsm, Event.NEXT, context);
    removeIfFinished(fsm, key);
}
Also used : FlowMirrorPointDeleteFsm(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.delete.FlowMirrorPointDeleteFsm) FlowMirrorPointDeleteContext(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.delete.FlowMirrorPointDeleteContext)

Example 3 with FlowMirrorPointDeleteFsm

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

the class FlowMirrorPointDeleteService method handleTimeout.

/**
 * Handles timeout case.
 *
 * @param key command identifier.
 */
public void handleTimeout(String key) {
    log.debug("Handling timeout for {}", key);
    FlowMirrorPointDeleteFsm 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 : FlowMirrorPointDeleteFsm(org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.delete.FlowMirrorPointDeleteFsm)

Aggregations

FlowMirrorPointDeleteFsm (org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.delete.FlowMirrorPointDeleteFsm)3 FlowMirrorPointDeleteContext (org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.delete.FlowMirrorPointDeleteContext)2 FlowErrorResponse (org.openkilda.floodlight.flow.response.FlowErrorResponse)1