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);
}
}
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;
}
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;
}
Aggregations