use of org.openkilda.wfm.topology.flowhs.fsm.validation.FlowValidationFsm in project open-kilda by telstra.
the class FlowValidationHubService method handleTimeout.
/**
* Handles timeout case.
*
* @param key command identifier.
*/
public void handleTimeout(@NonNull String key) throws UnknownKeyException {
log.debug("Handling timeout for {}", key);
FlowValidationFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
ErrorData errorData = new ErrorData(ErrorType.OPERATION_TIMED_OUT, "Flow validation failed by timeout", "Error in FlowValidationHubService");
fsmExecutor.fire(fsm, Event.ERROR, errorData);
removeIfFinished(fsm, key);
}
use of org.openkilda.wfm.topology.flowhs.fsm.validation.FlowValidationFsm in project open-kilda by telstra.
the class FlowValidationHubService method handleAsyncResponse.
/**
* Handles async response from worker.
*
* @param key command identifier.
*/
public void handleAsyncResponse(@NonNull String key, @NonNull MessageData data) throws UnknownKeyException {
log.debug("Received command response {}", data);
FlowValidationFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
if (data instanceof SwitchFlowEntries) {
fsmExecutor.fire(fsm, Event.RULES_RECEIVED, data);
} else if (data instanceof SwitchMeterEntries) {
fsmExecutor.fire(fsm, Event.METERS_RECEIVED, data);
} else if (data instanceof SwitchMeterUnsupported) {
SwitchMeterUnsupported meterUnsupported = (SwitchMeterUnsupported) data;
log.info("Key: {}; Meters unsupported for switch '{};", key, meterUnsupported.getSwitchId());
fsmExecutor.fire(fsm, Event.METERS_RECEIVED, SwitchMeterEntries.builder().switchId(meterUnsupported.getSwitchId()).meterEntries(Collections.emptyList()).build());
} else if (data instanceof SwitchGroupEntries) {
fsmExecutor.fire(fsm, Event.GROUPS_RECEIVED, data);
} else if (data instanceof ErrorData) {
fsmExecutor.fire(fsm, Event.ERROR, data);
} else {
log.warn("Key: {}; Unhandled message {}", key, data);
}
removeIfFinished(fsm, key);
}
use of org.openkilda.wfm.topology.flowhs.fsm.validation.FlowValidationFsm in project open-kilda by telstra.
the class FlowValidationHubService method startFlowValidation.
private void startFlowValidation(@NonNull String key, @NonNull CommandContext commandContext, @NonNull String flowId) throws DuplicateKeyException {
log.debug("Handling flow validation 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");
}
FlowValidationFsm fsm = fsmFactory.newInstance(flowId, commandContext, eventListeners);
fsmRegister.registerFsm(key, fsm);
fsm.start();
fsmExecutor.fire(fsm, Event.NEXT, flowId);
removeIfFinished(fsm, key);
}
Aggregations