[
https://issues.apache.org/jira/browse/METRON-1681?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16644074#comment-16644074
]
ASF GitHub Bot commented on METRON-1681:
----------------------------------------
Github user mmiklavc commented on a diff in the pull request:
https://github.com/apache/metron/pull/1213#discussion_r223857423
--- Diff:
metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/ParserRunnerImpl.java
---
@@ -101,26 +92,28 @@ public void init(Supplier<ParserConfigurations>
parserConfigSupplier, Context st
}
@Override
- public void execute(String sensorType, RawMessage rawMessage,
ParserConfigurations parserConfigurations) {
- if (onSuccess == null) {
- throw new IllegalStateException("An onSuccess function must be set
before parsing a message.");
- }
- if (onError == null) {
- throw new IllegalStateException("An onError function must be set
before parsing a message.");
- }
+ public List<ParserResult> execute(String sensorType, RawMessage
rawMessage, ParserConfigurations parserConfigurations) {
+ List<ParserResult> parserResults;
SensorParserConfig sensorParserConfig =
parserConfigurations.getSensorParserConfig(sensorType);
if (sensorParserConfig != null) {
MessageParser<JSONObject> parser =
sensorToParserComponentMap.get(sensorType).getMessageParser();
List<JSONObject> messages =
parser.parseOptional(rawMessage.getMessage()).orElse(Collections.emptyList());
- messages.forEach(message -> processMessage(sensorType, message,
rawMessage, parser, parserConfigurations));
+ parserResults = messages.stream()
+ .map(message -> processMessage(sensorType, message,
rawMessage, parser, parserConfigurations))
+ .filter(Optional::isPresent)
--- End diff --
Remind me what the difference between not present, present, and present
w/exception or error is wrt the return value from processMessage.
> Decouple the ParserBolt from the Parse execution logic
> ------------------------------------------------------
>
> Key: METRON-1681
> URL: https://issues.apache.org/jira/browse/METRON-1681
> Project: Metron
> Issue Type: Improvement
> Reporter: Justin Leet
> Priority: Major
>
> Per discussion on https://github.com/apache/metron/pull/1099, there are
> concerns about the ParserBolt needed some refactoring. The discussion didn't
> hold the PR up, but it was generally agreed that we should decouple some of
> the initialization and execution logic.
> This also aids us in integrating with other systems such as NiFi or Spark.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)