[ 
https://issues.apache.org/jira/browse/METRON-1681?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16644175#comment-16644175
 ] 

ASF GitHub Bot commented on METRON-1681:
----------------------------------------

Github user merrimanr commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1213#discussion_r223885124
  
    --- 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 --
    
    I believe not present means the message was filtered out (our FilterClass 
mechanism).  Otherwise there will either be a message or error in the 
ParserResult.


> 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)

Reply via email to