use of org.openkilda.wfm.topology.flowhs.fsm.delete.FlowDeleteFsm in project open-kilda by telstra.
the class FlowDeleteService method handleAsyncResponse.
/**
* Handles async response from worker.
*
* @param key command identifier.
*/
public void handleAsyncResponse(@NonNull String key, @NonNull SpeakerFlowSegmentResponse flowResponse) throws UnknownKeyException {
log.debug("Received flow command response {}", flowResponse);
FlowDeleteFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
FlowDeleteContext context = FlowDeleteContext.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);
}
use of org.openkilda.wfm.topology.flowhs.fsm.delete.FlowDeleteFsm in project open-kilda by telstra.
the class FlowDeleteService method startFlowDeletion.
private void startFlowDeletion(String key, CommandContext commandContext, String flowId) throws DuplicateKeyException {
log.debug("Handling flow deletion request with key {} and flow ID: {}", key, flowId);
if (fsmRegister.hasRegisteredFsmWithKey(key)) {
throw new DuplicateKeyException(key, "There's another active FSM with the same key");
}
if (fsmRegister.hasRegisteredFsmWithFlowId(flowId)) {
sendErrorResponseToNorthbound(ErrorType.REQUEST_INVALID, "Could not delete flow", format("Flow %s is already deleting now", flowId), commandContext);
throw new DuplicateKeyException(key, "There's another active FSM for the same flowId " + flowId);
}
FlowDeleteFsm fsm = fsmFactory.newInstance(commandContext, flowId, eventListeners);
fsmRegister.registerFsm(key, fsm);
fsm.start();
fsmExecutor.fire(fsm, Event.NEXT, FlowDeleteContext.builder().build());
removeIfFinished(fsm, key);
}
use of org.openkilda.wfm.topology.flowhs.fsm.delete.FlowDeleteFsm in project open-kilda by telstra.
the class FlowDeleteService method handleTimeout.
/**
* Handles timeout case.
*
* @param key command identifier.
*/
public void handleTimeout(@NonNull String key) throws UnknownKeyException {
log.debug("Handling timeout for {}", key);
FlowDeleteFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
fsmExecutor.fire(fsm, Event.TIMEOUT);
removeIfFinished(fsm, key);
}
Aggregations