Search in sources :

Example 1 with FlowMirrorPointDeleteContext

use of org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.delete.FlowMirrorPointDeleteContext 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 FlowMirrorPointDeleteContext

use of org.openkilda.wfm.topology.flowhs.fsm.mirrorpoint.delete.FlowMirrorPointDeleteContext 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)

Aggregations

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