Search in sources :

Example 1 with ErrorType

use of org.openkilda.messaging.error.ErrorType in project open-kilda by telstra.

the class CrudBolt method handleErrorRequest.

private void handleErrorRequest(String flowId, ErrorMessage message, Tuple tuple) throws IOException {
    ErrorType errorType = message.getData().getErrorType();
    message.getData().setErrorDescription("topology-engine internal error");
    logger.info("Flow {} {} failure", errorType, flowId);
    switch(errorType) {
        case CREATION_FAILURE:
            flowCache.removeFlow(flowId);
            break;
        case UPDATE_FAILURE:
            handleStateRequest(flowId, FlowState.DOWN, tuple);
            break;
        case DELETION_FAILURE:
            break;
        case INTERNAL_ERROR:
            break;
        default:
            logger.warn("Flow {} undefined failure", flowId);
    }
    Values error = new Values(message, errorType);
    outputCollector.emit(StreamType.ERROR.toString(), tuple, error);
}
Also used : ErrorType(org.openkilda.messaging.error.ErrorType) Values(org.apache.storm.tuple.Values)

Example 2 with ErrorType

use of org.openkilda.messaging.error.ErrorType in project open-kilda by telstra.

the class ErrorBolt method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(Tuple tuple) {
    ComponentType componentId = ComponentType.valueOf(tuple.getSourceComponent());
    StreamType streamId = StreamType.valueOf(tuple.getSourceStreamId());
    ErrorType errorType = (ErrorType) tuple.getValueByField(FlowTopology.ERROR_TYPE_FIELD);
    ErrorMessage error = (ErrorMessage) tuple.getValueByField(AbstractTopology.MESSAGE_FIELD);
    error.setDestination(Destination.NORTHBOUND);
    Values values = new Values(error);
    try {
        logger.debug("Request tuple={}", tuple);
        switch(componentId) {
            case CRUD_BOLT:
            case SPLITTER_BOLT:
                logger.debug("Error message: data={}", error.getData());
                outputCollector.emit(StreamType.RESPONSE.toString(), tuple, values);
                break;
            default:
                logger.debug("Skip message from unknown component: component={}, stream={}, error-type={}", componentId, streamId, errorType);
                break;
        }
    } catch (Exception exception) {
        logger.error("Could not process message: {}", tuple, exception);
    } finally {
        logger.debug("Error message ack: component={}, stream={}, tuple={}, values={}", tuple.getSourceComponent(), tuple.getSourceStreamId(), tuple, values);
        outputCollector.ack(tuple);
    }
}
Also used : StreamType(org.openkilda.wfm.topology.flow.StreamType) ComponentType(org.openkilda.wfm.topology.flow.ComponentType) ErrorType(org.openkilda.messaging.error.ErrorType) Values(org.apache.storm.tuple.Values) ErrorMessage(org.openkilda.messaging.error.ErrorMessage)

Aggregations

Values (org.apache.storm.tuple.Values)2 ErrorType (org.openkilda.messaging.error.ErrorType)2 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 ComponentType (org.openkilda.wfm.topology.flow.ComponentType)1 StreamType (org.openkilda.wfm.topology.flow.StreamType)1