Search in sources :

Example 1 with IntermediateRankingsBolt

use of org.apache.storm.starter.bolt.IntermediateRankingsBolt in project storm by apache.

the class SkewedRollingTopWords method run.

/**
   * Submits (runs) the topology.
   *
   * Usage: "SkewedRollingTopWords [topology-name] [-local]"
   *
   * 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.SkewedRollingTopWords -local
   *
   * # Runs in local mode (LocalCluster), with topology name "foobar"
   * $ storm jar storm-starter-jar-with-dependencies.jar org.apache.storm.starter.SkewedRollingTopWords foobar -local
   * 
   * # Runs in local mode (LocalCluster) for 30 seconds, with topology name "foobar" 
   * $ storm jar storm-starter-jar-with-dependencies.jar org.apache.storm.starter.SkewedRollingTopWords foobar -local -ttl 30
   *
   * # Runs in remote/cluster mode, with topology name "production-topology"
   * $ storm jar storm-starter-jar-with-dependencies.jar org.apache.storm.starter.SkewedRollingTopWords production-topology ```
   *
   * @param args
   *          First positional argument (optional) is topology name, second
   *          positional argument (optional) defines whether to run the topology
   *          locally ("-local") or remotely, i.e. on a real cluster.
   * @throws Exception
   */
protected int run(String[] args) {
    String topologyName = "slidingWindowCounts";
    if (args.length >= 1) {
        topologyName = args[0];
    }
    TopologyBuilder builder = new TopologyBuilder();
    String spoutId = "wordGenerator";
    String counterId = "counter";
    String aggId = "aggregator";
    String intermediateRankerId = "intermediateRanker";
    String totalRankerId = "finalRanker";
    builder.setSpout(spoutId, new TestWordSpout(), 5);
    builder.setBolt(counterId, new RollingCountBolt(9, 3), 4).partialKeyGrouping(spoutId, new Fields("word"));
    builder.setBolt(aggId, new RollingCountAggBolt(), 4).fieldsGrouping(counterId, new Fields("obj"));
    builder.setBolt(intermediateRankerId, new IntermediateRankingsBolt(TOP_N), 4).fieldsGrouping(aggId, new Fields("obj"));
    builder.setBolt(totalRankerId, new TotalRankingsBolt(TOP_N)).globalGrouping(intermediateRankerId);
    LOG.info("Topology name: " + topologyName);
    return submit(topologyName, conf, builder);
}
Also used : RollingCountBolt(org.apache.storm.starter.bolt.RollingCountBolt) IntermediateRankingsBolt(org.apache.storm.starter.bolt.IntermediateRankingsBolt) Fields(org.apache.storm.tuple.Fields) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) TotalRankingsBolt(org.apache.storm.starter.bolt.TotalRankingsBolt) TestWordSpout(org.apache.storm.testing.TestWordSpout) RollingCountAggBolt(org.apache.storm.starter.bolt.RollingCountAggBolt)

Example 2 with IntermediateRankingsBolt

use of org.apache.storm.starter.bolt.IntermediateRankingsBolt in project jstorm by alibaba.

the class RollingTopWords method wireTopology.

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);
}
Also used : RollingCountBolt(org.apache.storm.starter.bolt.RollingCountBolt) IntermediateRankingsBolt(org.apache.storm.starter.bolt.IntermediateRankingsBolt) Fields(backtype.storm.tuple.Fields) TotalRankingsBolt(org.apache.storm.starter.bolt.TotalRankingsBolt) TestWordSpout(backtype.storm.testing.TestWordSpout)

Example 3 with IntermediateRankingsBolt

use of org.apache.storm.starter.bolt.IntermediateRankingsBolt in project storm by apache.

the class RollingTopWords method run.

/**
   * Submits (runs) the topology.
   *
   * Usage: "RollingTopWords [topology-name] [-local]"
   *
   * 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 -local
   * 
   * # Runs in local mode (LocalCluster), with topology name "foobar"
   * $ storm jar storm-starter-jar-with-dependencies.jar org.apache.storm.starter.RollingTopWords foobar -local
   * 
   * # Runs in local mode (LocalCluster) for 30 seconds, with topology name "foobar" 
   * $ storm jar storm-starter-jar-with-dependencies.jar org.apache.storm.starter.RollingTopWords foobar -local -ttl 30
   *
   * # Runs in remote/cluster mode, with topology name "production-topology"
   * $ storm jar storm-starter-jar-with-dependencies.jar org.apache.storm.starter.RollingTopWords production-topology ```
   *
   * @param args
   *          First positional argument (optional) is topology name, second
   *          positional argument (optional) defines whether to run the topology
   *          locally ("-local") or remotely, i.e. on a real cluster.
   * @throws Exception
   */
protected int run(String[] args) {
    String topologyName = "slidingWindowCounts";
    if (args.length >= 1) {
        topologyName = args[0];
    }
    TopologyBuilder builder = new TopologyBuilder();
    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);
    LOG.info("Topology name: " + topologyName);
    return submit(topologyName, conf, builder);
}
Also used : RollingCountBolt(org.apache.storm.starter.bolt.RollingCountBolt) IntermediateRankingsBolt(org.apache.storm.starter.bolt.IntermediateRankingsBolt) Fields(org.apache.storm.tuple.Fields) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) TotalRankingsBolt(org.apache.storm.starter.bolt.TotalRankingsBolt) TestWordSpout(org.apache.storm.testing.TestWordSpout)

Example 4 with IntermediateRankingsBolt

use of org.apache.storm.starter.bolt.IntermediateRankingsBolt in project jstorm by alibaba.

the class SkewedRollingTopWords method wireTopology.

private void wireTopology() throws InterruptedException {
    String spoutId = "wordGenerator";
    String counterId = "counter";
    String aggId = "aggregator";
    String intermediateRankerId = "intermediateRanker";
    String totalRankerId = "finalRanker";
    builder.setSpout(spoutId, new TestWordSpout(), 5);
    builder.setBolt(counterId, new RollingCountBolt(9, 3), 4).partialKeyGrouping(spoutId, new Fields("word"));
    builder.setBolt(aggId, new RollingCountAggBolt(), 4).fieldsGrouping(counterId, new Fields("obj"));
    builder.setBolt(intermediateRankerId, new IntermediateRankingsBolt(TOP_N), 4).fieldsGrouping(aggId, new Fields("obj"));
    builder.setBolt(totalRankerId, new TotalRankingsBolt(TOP_N)).globalGrouping(intermediateRankerId);
}
Also used : RollingCountBolt(org.apache.storm.starter.bolt.RollingCountBolt) IntermediateRankingsBolt(org.apache.storm.starter.bolt.IntermediateRankingsBolt) Fields(backtype.storm.tuple.Fields) TotalRankingsBolt(org.apache.storm.starter.bolt.TotalRankingsBolt) TestWordSpout(backtype.storm.testing.TestWordSpout) RollingCountAggBolt(org.apache.storm.starter.bolt.RollingCountAggBolt)

Aggregations

IntermediateRankingsBolt (org.apache.storm.starter.bolt.IntermediateRankingsBolt)4 RollingCountBolt (org.apache.storm.starter.bolt.RollingCountBolt)4 TotalRankingsBolt (org.apache.storm.starter.bolt.TotalRankingsBolt)4 TestWordSpout (backtype.storm.testing.TestWordSpout)2 Fields (backtype.storm.tuple.Fields)2 RollingCountAggBolt (org.apache.storm.starter.bolt.RollingCountAggBolt)2 TestWordSpout (org.apache.storm.testing.TestWordSpout)2 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)2 Fields (org.apache.storm.tuple.Fields)2