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

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

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

    https://github.com/apache/metron/pull/1213#discussion_r221018053
  
    --- Diff: 
metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/ParserRunner.java
 ---
    @@ -0,0 +1,234 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.metron.parsers;
    +
    +import com.github.benmanes.caffeine.cache.Cache;
    +import org.apache.commons.lang3.StringUtils;
    +import org.apache.curator.framework.CuratorFramework;
    +import org.apache.metron.common.Constants;
    +import org.apache.metron.common.configuration.FieldTransformer;
    +import org.apache.metron.common.configuration.FieldValidator;
    +import org.apache.metron.common.configuration.ParserConfigurations;
    +import org.apache.metron.common.configuration.SensorParserConfig;
    +import org.apache.metron.common.error.MetronError;
    +import org.apache.metron.common.message.metadata.RawMessage;
    +import org.apache.metron.common.utils.ReflectionUtils;
    +import org.apache.metron.parsers.filters.Filters;
    +import org.apache.metron.parsers.interfaces.MessageFilter;
    +import org.apache.metron.parsers.interfaces.MessageParser;
    +import org.apache.metron.parsers.topology.ParserComponent;
    +import org.apache.metron.stellar.common.CachingStellarProcessor;
    +import org.apache.metron.stellar.dsl.Context;
    +import org.apache.metron.stellar.dsl.StellarFunctions;
    +import org.json.simple.JSONObject;
    +
    +import java.io.Serializable;
    +import java.util.ArrayList;
    +import java.util.Collections;
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Set;
    +import java.util.UUID;
    +import java.util.function.Consumer;
    +import java.util.function.Supplier;
    +import java.util.stream.Collectors;
    +
    +public class ParserRunner implements Serializable {
    +
    +  protected transient Consumer<ParserResult> onSuccess;
    +  protected transient Consumer<MetronError> onError;
    +
    +  private HashSet<String> sensorTypes;
    +  private Map<String, ParserComponent> sensorToParserComponentMap;
    +
    +  // Stellar variables
    +  private transient Context stellarContext;
    +
    +  public ParserRunner(HashSet<String> sensorTypes) {
    +    this.sensorTypes = sensorTypes;
    +  }
    +
    +  public Map<String, ParserComponent> getSensorToParserComponentMap() {
    +    return sensorToParserComponentMap;
    +  }
    +
    +  public void setSensorToParserComponentMap(Map<String, ParserComponent> 
sensorToParserComponentMap) {
    +    this.sensorToParserComponentMap = sensorToParserComponentMap;
    +  }
    +
    +  public Context getStellarContext() {
    +    return stellarContext;
    +  }
    +
    +  public void setOnSuccess(Consumer<ParserResult> onSuccess) {
    +    this.onSuccess = onSuccess;
    +  }
    +
    +  public void setOnError(Consumer<MetronError> onError) {
    +    this.onError = onError;
    +  }
    +
    +  public void init(CuratorFramework client, Supplier<ParserConfigurations> 
parserConfigSupplier) {
    +    if (parserConfigSupplier == null) {
    +      throw new IllegalStateException("A parser config supplier must be 
set before initializing the ParserRunner.");
    +    }
    +    initializeStellar(client, parserConfigSupplier);
    +    initializeParsers(parserConfigSupplier);
    +  }
    +
    +  protected void initializeStellar(CuratorFramework client, 
Supplier<ParserConfigurations> parserConfigSupplier) {
    --- End diff --
    
    Yes, that could work.  It would make it easier to use if we have a default 
implementation that works in most cases.


> 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