Search in sources :

Example 6 with ProcessingException

use of com.hortonworks.streamline.streams.exception.ProcessingException in project streamline by hortonworks.

the class RulesBolt method process.

@Override
protected void process(Tuple input, StreamlineEvent event) {
    // Input tuple is expected to be an StreamlineEvent
    StreamlineEvent eventWithStream = getStreamlineEventWithStream(event, input);
    LOG.debug("++++++++ Executing tuple [{}], StreamlineEvent [{}]", input, eventWithStream);
    try {
        for (Result result : ruleProcessorRuntime.process(eventWithStream)) {
            for (StreamlineEvent e : result.events) {
                collector.emit(result.stream, input, new Values(e));
            }
        }
    } catch (ProcessingException e) {
        throw new RuntimeException(e);
    }
}
Also used : StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) Values(org.apache.storm.tuple.Values) Result(com.hortonworks.streamline.streams.Result) ProcessingException(com.hortonworks.streamline.streams.exception.ProcessingException)

Example 7 with ProcessingException

use of com.hortonworks.streamline.streams.exception.ProcessingException in project streamline by hortonworks.

the class MultiLangProcessorRuntime method processEvent.

private List<Result> processEvent(StreamlineEvent inputEvent) {
    List<Result> results = new LinkedList<>();
    try {
        markWaitingSubprocess();
        ProcessorMsg processorMsg = createProcessorMessage(inputEvent);
        shellProcess.writeProcessorMsg(processorMsg);
        ShellMsg errorMsg = null;
        Map<String, List<ShellMsg>> emitMsgMap = new HashMap<>();
        while (true) {
            ShellMsg shellMsg = shellProcess.readShellMsg();
            String command = shellMsg.getCommand();
            if (command == null) {
                throw new IllegalArgumentException("Command not found in shell message: " + shellMsg);
            }
            setHeartbeat();
            if (command.equals("sync")) {
                break;
            } else if (command.equals("error")) {
                errorMsg = shellMsg;
            } else if (command.equals("emit")) {
                String stream = shellMsg.getOutputStream();
                List<ShellMsg> eventList = emitMsgMap.get(stream);
                if (eventList == null) {
                    eventList = new LinkedList<>();
                    emitMsgMap.put(stream, eventList);
                }
                eventList.add(shellMsg);
            } else {
                throw new RuntimeException("Unknown command received: " + command);
            }
        }
        if (errorMsg != null) {
            LOG.error(errorMsg.getMsg());
            throw new ProcessingException(errorMsg.getMsg());
        }
        for (Map.Entry<String, List<ShellMsg>> entry : emitMsgMap.entrySet()) {
            results.add(convertShellMsg(entry.getKey(), entry.getValue(), inputEvent));
        }
    } catch (IOException | ProcessingException e) {
        String processInfo = shellProcess.getProcessInfoString() + shellProcess.getProcessTerminationInfoString();
        throw new RuntimeException(processInfo, e);
    } finally {
        completedWaitingSubprocess();
    }
    return results;
}
Also used : HashMap(java.util.HashMap) IOException(java.io.IOException) LinkedList(java.util.LinkedList) Result(com.hortonworks.streamline.streams.Result) ProcessorMsg(com.hortonworks.streamline.streams.common.utils.ProcessorMsg) ShellMsg(com.hortonworks.streamline.streams.common.utils.ShellMsg) LinkedList(java.util.LinkedList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) ProcessingException(com.hortonworks.streamline.streams.exception.ProcessingException)

Example 8 with ProcessingException

use of com.hortonworks.streamline.streams.exception.ProcessingException in project streamline by hortonworks.

the class TestSinkProcessor method process.

public List<StreamlineEvent> process(StreamlineEvent streamlineEvent) throws ProcessingException {
    try {
        LOG.debug("Processing {}", streamlineEvent);
        JSONObject json = new JSONObject();
        json.putAll(streamlineEvent);
        writer.write(json.toJSONString());
        writer.flush();
    } catch (Exception e) {
        LOG.error("Failed to process event", e);
        throw new ProcessingException(e);
    }
    return null;
}
Also used : JSONObject(org.json.simple.JSONObject) ProcessingException(com.hortonworks.streamline.streams.exception.ProcessingException) ConfigException(com.hortonworks.streamline.common.exception.ConfigException) IOException(java.io.IOException) ProcessingException(com.hortonworks.streamline.streams.exception.ProcessingException)

Aggregations

ProcessingException (com.hortonworks.streamline.streams.exception.ProcessingException)8 Result (com.hortonworks.streamline.streams.Result)5 StreamlineEvent (com.hortonworks.streamline.streams.StreamlineEvent)5 HashMap (java.util.HashMap)4 Values (org.apache.storm.tuple.Values)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 IOException (java.io.IOException)2 List (java.util.List)2 ScriptException (javax.script.ScriptException)2 Schema (com.hortonworks.registries.common.Schema)1 ConfigException (com.hortonworks.streamline.common.exception.ConfigException)1 Utils (com.hortonworks.streamline.common.util.Utils)1 ConsoleCustomProcessor (com.hortonworks.streamline.examples.processors.ConsoleCustomProcessor)1 IdPreservedStreamlineEvent (com.hortonworks.streamline.streams.common.IdPreservedStreamlineEvent)1 StreamlineEventImpl (com.hortonworks.streamline.streams.common.StreamlineEventImpl)1 GROUP_BY_TRIGGER_EVENT (com.hortonworks.streamline.streams.common.StreamlineEventImpl.GROUP_BY_TRIGGER_EVENT)1 EventCorrelationInjector (com.hortonworks.streamline.streams.common.event.correlation.EventCorrelationInjector)1 ProcessorMsg (com.hortonworks.streamline.streams.common.utils.ProcessorMsg)1 ShellMsg (com.hortonworks.streamline.streams.common.utils.ShellMsg)1