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

    https://github.com/apache/storm/pull/1897#discussion_r98649259
  
    --- Diff: 
examples/storm-starter/src/jvm/org/apache/storm/starter/RollingTopWords.java ---
    @@ -17,114 +17,89 @@
      */
     package org.apache.storm.starter;
     
    -import org.apache.storm.Config;
    -import org.apache.storm.testing.TestWordSpout;
    -import org.apache.storm.topology.TopologyBuilder;
    -import org.apache.storm.tuple.Fields;
    -import org.apache.log4j.Logger;
     import org.apache.storm.starter.bolt.IntermediateRankingsBolt;
     import org.apache.storm.starter.bolt.RollingCountBolt;
     import org.apache.storm.starter.bolt.TotalRankingsBolt;
    -import org.apache.storm.starter.util.StormRunner;
    +import org.apache.storm.testing.TestWordSpout;
    +import org.apache.storm.topology.ConfigurableTopology;
    +import org.apache.storm.topology.TopologyBuilder;
    +import org.apache.storm.tuple.Fields;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
     
     /**
    - * This topology does a continuous computation of the top N words that the 
topology has seen in terms of cardinality.
    - * The top N computation is done in a completely scalable way, and a 
similar approach could be used to compute things
    - * like trending topics or trending images on Twitter.
    + * This topology does a continuous computation of the top N words that the
    + * topology has seen in terms of cardinality. The top N computation is 
done in a
    + * completely scalable way, and a similar approach could be used to compute
    + * things like trending topics or trending images on Twitter.
      */
    -public class RollingTopWords {
    +public class RollingTopWords extends ConfigurableTopology {
     
    -  private static final Logger LOG = 
Logger.getLogger(RollingTopWords.class);
    -  private static final int DEFAULT_RUNTIME_IN_SECONDS = 60;
    +  private static final Logger LOG = 
LoggerFactory.getLogger(RollingTopWords.class);
       private static final int TOP_N = 5;
     
    -  private final TopologyBuilder builder;
    -  private final String topologyName;
    -  private final Config topologyConfig;
    -  private final int runtimeInSeconds;
    -
    -  public RollingTopWords(String topologyName) throws InterruptedException {
    -    builder = new TopologyBuilder();
    -    this.topologyName = topologyName;
    -    topologyConfig = createTopologyConfiguration();
    -    runtimeInSeconds = DEFAULT_RUNTIME_IN_SECONDS;
    -
    -    wireTopology();
    -  }
    -
    -  private static Config createTopologyConfiguration() {
    -    Config conf = new Config();
    -    conf.setDebug(true);
    -    return conf;
    -  }
    -
    -  private void wireTopology() throws InterruptedException {
    -    String spoutId = "wordGenerator";
    -    String counterId = "counter";
    -    String intermediateRankerId = "intermediateRanker";
    -    String totalRankerId = "finalRanker";
    -    builder.setSpout(spoutId, new TestWordSpout(), 5);
    -    builder.setBolt(counterId, new RollingCountBolt(9, 3), 
4).fieldsGrouping(spoutId, new Fields("word"));
    -    builder.setBolt(intermediateRankerId, new 
IntermediateRankingsBolt(TOP_N), 4).fieldsGrouping(counterId, new Fields(
    -        "obj"));
    -    builder.setBolt(totalRankerId, new 
TotalRankingsBolt(TOP_N)).globalGrouping(intermediateRankerId);
    -  }
    -
    -  public void runLocally() throws InterruptedException {
    -    StormRunner.runTopologyLocally(builder.createTopology(), topologyName, 
topologyConfig, runtimeInSeconds);
    +  private RollingTopWords() {
       }
     
    -  public void runRemotely() throws Exception {
    -    StormRunner.runTopologyRemotely(builder.createTopology(), 
topologyName, topologyConfig);
    +  public static void main(String[] args) throws Exception {
    +    ConfigurableTopology.start(new RollingTopWords(), args);
       }
     
       /**
        * Submits (runs) the topology.
        *
    -   * Usage: "RollingTopWords [topology-name] [local|remote]"
    +   * Usage: "RollingTopWords [topology-name] [-local]"
        *
    -   * By default, the topology is run locally under the name 
"slidingWindowCounts".
    +   * By default, the topology is run locally under the name
    +   * "slidingWindowCounts".
        *
        * Examples:
        *
        * ```
        *
    -   * # Runs in local mode (LocalCluster), with topology name 
"slidingWindowCounts"
    -   * $ storm jar storm-starter-jar-with-dependencies.jar 
org.apache.storm.starter.RollingTopWords
    +   * # Runs in local mode (LocalCluster), with topology name
    +   * "slidingWindowCounts" $ storm jar 
storm-starter-jar-with-dependencies.jar
    --- End diff --
    
    done!


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to