Search in sources :

Example 1 with Config

use of backtype.storm.Config in project storm-hbase by jrkinley.

the class HBaseCountersBatchTopology method main.

/**
   * @param args
   * @throws InterruptedException 
   */
public static void main(String[] args) throws InterruptedException {
    // Add transactional spout
    MemoryTransactionalSpout spout = new MemoryTransactionalSpout(values, new Fields("shortid", "url", "user", "date"), 3);
    TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("shorturl-count", "spout", spout, 2);
    // Build TupleTableConifg
    TupleTableConfig ttConfig = new TupleTableConfig("shorturl", "shortid");
    ttConfig.setBatch(false);
    ttConfig.addColumn("data", "clicks");
    ttConfig.addColumn("daily", "date");
    builder.setBolt("hbase-counters", new HBaseCountersBatchBolt(ttConfig), 2).fieldsGrouping("spout", new Fields("shortid"));
    LocalCluster cluster = new LocalCluster();
    Config stormConfig = new Config();
    stormConfig.setDebug(true);
    stormConfig.setMaxSpoutPending(3);
    cluster.submitTopology("hbase-example", stormConfig, builder.buildTopology());
    Thread.sleep(10000);
    cluster.shutdown();
}
Also used : LocalCluster(backtype.storm.LocalCluster) MemoryTransactionalSpout(backtype.storm.testing.MemoryTransactionalSpout) Fields(backtype.storm.tuple.Fields) HBaseCountersBatchBolt(backtype.storm.contrib.hbase.bolts.HBaseCountersBatchBolt) Config(backtype.storm.Config) TupleTableConfig(backtype.storm.contrib.hbase.utils.TupleTableConfig) TupleTableConfig(backtype.storm.contrib.hbase.utils.TupleTableConfig) TransactionalTopologyBuilder(backtype.storm.transactional.TransactionalTopologyBuilder)

Example 2 with Config

use of backtype.storm.Config in project storm-hbase by jrkinley.

the class HBaseCountersTopology method main.

/**
   * @param args
   */
public static void main(String[] args) {
    TopologyBuilder builder = new TopologyBuilder();
    // Add test spout
    builder.setSpout("spout", new TestSpout(), 1);
    // Build TupleTableConifg
    TupleTableConfig config = new TupleTableConfig("shorturl", "shortid");
    config.setBatch(false);
    /*
     * By default the HBaseCountersBolt will use the tuple output fields value
     * to set the CQ name. For example if the 'date' output field exists in the
     * tuple then its value (e.g. "YYYYMMDD") will be used to set the counters
     * CQ. However, the 'clicks' output field does not exist in the tuple so in
     * this case the counters CQ will be set to the given field name 'clicks'.
     */
    config.addColumn("data", "clicks");
    config.addColumn("daily", "date");
    // Add HBaseBolt
    builder.setBolt("hbase-counters", new HBaseCountersBolt(config), 1).shuffleGrouping("spout");
    Config stormConf = new Config();
    stormConf.setDebug(true);
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("hbase-example", stormConf, builder.createTopology());
    Utils.sleep(10000);
    cluster.shutdown();
}
Also used : LocalCluster(backtype.storm.LocalCluster) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config) TupleTableConfig(backtype.storm.contrib.hbase.utils.TupleTableConfig) HBaseCountersBolt(backtype.storm.contrib.hbase.bolts.HBaseCountersBolt) TupleTableConfig(backtype.storm.contrib.hbase.utils.TupleTableConfig)

Example 3 with Config

use of backtype.storm.Config in project storm-hbase by jrkinley.

the class HBaseExampleTopology method main.

/**
   * @param args
   */
public static void main(String[] args) {
    TopologyBuilder builder = new TopologyBuilder();
    // Add test spout
    builder.setSpout("spout", new TestSpout(), 1);
    // Build TupleTableConifg
    TupleTableConfig config = new TupleTableConfig("shorturl", "shortid");
    config.setBatch(false);
    config.addColumn("data", "url");
    config.addColumn("data", "user");
    config.addColumn("data", "date");
    // Add HBaseBolt
    builder.setBolt("hbase", new HBaseBolt(config), 1).shuffleGrouping("spout");
    Config stormConf = new Config();
    stormConf.setDebug(true);
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("hbase-example", stormConf, builder.createTopology());
    Utils.sleep(10000);
    cluster.shutdown();
}
Also used : LocalCluster(backtype.storm.LocalCluster) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config) TupleTableConfig(backtype.storm.contrib.hbase.utils.TupleTableConfig) TupleTableConfig(backtype.storm.contrib.hbase.utils.TupleTableConfig) HBaseBolt(backtype.storm.contrib.hbase.bolts.HBaseBolt)

Example 4 with Config

use of backtype.storm.Config in project storm by nathanmarz.

the class TridentSpoutCoordinator method getComponentConfiguration.

@Override
public Map<String, Object> getComponentConfiguration() {
    Config ret = new Config();
    ret.setMaxTaskParallelism(1);
    return ret;
}
Also used : Config(backtype.storm.Config)

Example 5 with Config

use of backtype.storm.Config in project storm by nathanmarz.

the class FixedBatchSpout method getComponentConfiguration.

@Override
public Map getComponentConfiguration() {
    Config conf = new Config();
    conf.setMaxTaskParallelism(1);
    return conf;
}
Also used : Config(backtype.storm.Config)

Aggregations

Config (backtype.storm.Config)75 TopologyBuilder (backtype.storm.topology.TopologyBuilder)38 LocalCluster (backtype.storm.LocalCluster)31 Fields (backtype.storm.tuple.Fields)19 Test (org.junit.Test)8 StormTopology (backtype.storm.generated.StormTopology)7 Map (java.util.Map)7 LocalDRPC (backtype.storm.LocalDRPC)6 ArrayList (java.util.ArrayList)4 ILocalCluster (backtype.storm.ILocalCluster)3 TupleTableConfig (backtype.storm.contrib.hbase.utils.TupleTableConfig)3 LinearDRPCTopologyBuilder (backtype.storm.drpc.LinearDRPCTopologyBuilder)3 MkClusterParam (backtype.storm.testing.MkClusterParam)3 TestJob (backtype.storm.testing.TestJob)3 TransactionalTopologyBuilder (backtype.storm.transactional.TransactionalTopologyBuilder)3 Values (backtype.storm.tuple.Values)3 TridentConfig (backtype.storm.contrib.hbase.utils.TridentConfig)2 DRPCSpout (backtype.storm.drpc.DRPCSpout)2 ReturnResults (backtype.storm.drpc.ReturnResults)2 FeederSpout (backtype.storm.testing.FeederSpout)2