Search in sources :

Example 1 with BaseRequest

use of org.openkilda.messaging.nbtopology.request.BaseRequest in project open-kilda by telstra.

the class PersistenceOperationsBolt method handleInput.

protected void handleInput(Tuple input) throws Exception {
    BaseRequest request = pullValue(input, FIELD_ID_REQUEST, BaseRequest.class);
    log.debug("Received operation request");
    try {
        List<? extends InfoData> result = processRequest(input, request);
        getOutput().emit(input, new Values(result, getCommandContext()));
    } catch (MessageException e) {
        log.error(format("Failed to process request: %s", e.getMessage()), e);
        ErrorData data = new ErrorData(e.getErrorType(), e.getMessage(), e.getErrorDescription());
        getOutput().emit(StreamType.ERROR.toString(), input, new Values(data, getCommandContext()));
    }
}
Also used : MessageException(org.openkilda.messaging.error.MessageException) BaseRequest(org.openkilda.messaging.nbtopology.request.BaseRequest) Values(org.apache.storm.tuple.Values) ErrorData(org.openkilda.messaging.error.ErrorData)

Example 2 with BaseRequest

use of org.openkilda.messaging.nbtopology.request.BaseRequest in project open-kilda by telstra.

the class RouterBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws PipelineException {
    String key = input.getStringByField(MessageKafkaTranslator.FIELD_ID_KEY);
    Message message = pullValue(input, FIELD_ID_PAYLOAD, Message.class);
    if (message instanceof CommandMessage) {
        if (active) {
            log.debug("Received command message {}", message);
            CommandMessage command = (CommandMessage) message;
            CommandData data = command.getData();
            if (data instanceof BaseRequest) {
                BaseRequest baseRequest = (BaseRequest) data;
                processRequest(input, key, baseRequest);
            }
        }
    } else if (message instanceof InfoMessage || message instanceof ErrorMessage) {
        log.debug("Received hub response message {}", message);
        emitWithContext(SpeakerWorkerBolt.INCOME_STREAM, input, new Values(key, message));
    } else {
        unhandledInput(input);
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) BaseRequest(org.openkilda.messaging.nbtopology.request.BaseRequest) LinksBaseRequest(org.openkilda.messaging.nbtopology.request.LinksBaseRequest) SwitchesBaseRequest(org.openkilda.messaging.nbtopology.request.SwitchesBaseRequest) FeatureTogglesBaseRequest(org.openkilda.messaging.nbtopology.request.FeatureTogglesBaseRequest) FlowsBaseRequest(org.openkilda.messaging.nbtopology.request.FlowsBaseRequest) KildaConfigurationBaseRequest(org.openkilda.messaging.nbtopology.request.KildaConfigurationBaseRequest) Values(org.apache.storm.tuple.Values) CommandData(org.openkilda.messaging.command.CommandData) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

Values (org.apache.storm.tuple.Values)2 BaseRequest (org.openkilda.messaging.nbtopology.request.BaseRequest)2 Message (org.openkilda.messaging.Message)1 CommandData (org.openkilda.messaging.command.CommandData)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 ErrorData (org.openkilda.messaging.error.ErrorData)1 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 MessageException (org.openkilda.messaging.error.MessageException)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 FeatureTogglesBaseRequest (org.openkilda.messaging.nbtopology.request.FeatureTogglesBaseRequest)1 FlowsBaseRequest (org.openkilda.messaging.nbtopology.request.FlowsBaseRequest)1 KildaConfigurationBaseRequest (org.openkilda.messaging.nbtopology.request.KildaConfigurationBaseRequest)1 LinksBaseRequest (org.openkilda.messaging.nbtopology.request.LinksBaseRequest)1 SwitchesBaseRequest (org.openkilda.messaging.nbtopology.request.SwitchesBaseRequest)1