metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cestella <...@git.apache.org>
Subject [GitHub] incubator-metron pull request #208: METRON-309 Create a normalcy profiler
Date Thu, 18 Aug 2016 14:56:27 GMT
Github user cestella commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/208#discussion_r75324056
  
    --- Diff: metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileSplitterBolt.java
---
    @@ -0,0 +1,158 @@
    +/*
    + *
    + *  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.profiler.bolt;
    +
    +import backtype.storm.task.OutputCollector;
    +import backtype.storm.task.TopologyContext;
    +import backtype.storm.topology.OutputFieldsDeclarer;
    +import backtype.storm.tuple.Fields;
    +import backtype.storm.tuple.Tuple;
    +import backtype.storm.tuple.Values;
    +import org.apache.metron.common.bolt.ConfiguredProfilerBolt;
    +import org.apache.metron.common.configuration.profiler.ProfileConfig;
    +import org.apache.metron.common.configuration.profiler.ProfilerConfig;
    +import org.apache.metron.profiler.stellar.StellarExecutor;
    +import org.json.simple.JSONObject;
    +import org.json.simple.parser.JSONParser;
    +import org.json.simple.parser.ParseException;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.UnsupportedEncodingException;
    +import java.util.Map;
    +
    +/**
    + * The bolt responsible for filtering incoming messages and directing
    + * each to the one or more bolts responsible for building a Profile.  Each
    + * message may be needed by 0, 1 or even many Profiles.
    + */
    +public class ProfileSplitterBolt extends ConfiguredProfilerBolt {
    +
    +  protected static final Logger LOG = LoggerFactory.getLogger(ProfileSplitterBolt.class);
    +
    +  private OutputCollector collector;
    +
    +  /**
    +   * JSON parser.
    +   */
    +  private transient JSONParser parser;
    +
    +  /**
    +   * Executes Stellar code.
    +   */
    +  private StellarExecutor executor;
    +
    +  /**
    +   * @param zookeeperUrl The Zookeeper URL that contains the configuration for this bolt.
    +   */
    +  public ProfileSplitterBolt(String zookeeperUrl) {
    +    super(zookeeperUrl);
    +  }
    +
    +  @Override
    +  public void prepare(Map stormConf, TopologyContext context, OutputCollector collector)
{
    +    super.prepare(stormConf, context, collector);
    +    this.collector = collector;
    +    this.parser = new JSONParser();
    +  }
    +
    +  @Override
    +  public void execute(Tuple input) {
    +    try {
    +      doExecute(input);
    +
    +    } catch (IllegalArgumentException | ParseException | UnsupportedEncodingException
e) {
    +      LOG.error("Unexpected exception", e);
    --- End diff --
    
    Can you bubble the exception message up like `"Unexpected exception: e.getMessage()`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message