Search in sources :

Example 36 with LocalCluster

use of backtype.storm.LocalCluster in project storm-kestrel by nathanmarz.

the class TestTopology method main.

public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    KestrelThriftSpout spout = new KestrelThriftSpout("localhost", 2229, "test", new StringScheme());
    builder.setSpout("spout", spout).setDebug(true);
    builder.setBolt("bolt", new FailEveryOther()).shuffleGrouping("spout");
    LocalCluster cluster = new LocalCluster();
    Config conf = new Config();
    cluster.submitTopology("test", conf, builder.createTopology());
    Thread.sleep(600000);
}
Also used : LocalCluster(backtype.storm.LocalCluster) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config) StringScheme(backtype.storm.scheme.StringScheme)

Example 37 with LocalCluster

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

the class HBaseTridentValueTopology method main.

/**
 * @param args
 * @throws InterruptedException
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] args) throws InterruptedException {
    List<Object> v0 = HBaseCountersBatchTopology.values.get(0).get(0);
    List<Object> v1 = HBaseCountersBatchTopology.values.get(0).get(1);
    List<Object> v2 = HBaseCountersBatchTopology.values.get(0).get(2);
    List<Object> v3 = HBaseCountersBatchTopology.values.get(0).get(3);
    List<Object> v4 = HBaseCountersBatchTopology.values.get(0).get(4);
    FixedBatchSpout spout = new FixedBatchSpout(new Fields("shortid", "url", "user", "date"), 3, v0, v1, v2, v3, v4);
    spout.setCycle(true);
    // Trident updater
    TridentConfig updateConfig = new TridentConfig("shorturl", "shortid");
    updateConfig.setBatch(false);
    updateConfig.addColumn("data", "url");
    updateConfig.addColumn("data", "user");
    updateConfig.addColumn("data", "date");
    TridentTopology topology = new TridentTopology();
    topology.newStream("shorturls", spout).partitionPersist(new HBaseValueFactory(updateConfig), new Fields("shortid", "url", "user", "date"), new HBaseValueUpdater());
    Config conf = new Config();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("hbase-trident-updater", conf, topology.build());
    Utils.sleep(10000);
    cluster.shutdown();
}
Also used : FixedBatchSpout(storm.trident.testing.FixedBatchSpout) LocalCluster(backtype.storm.LocalCluster) Fields(backtype.storm.tuple.Fields) HBaseValueUpdater(backtype.storm.contrib.hbase.trident.HBaseValueUpdater) TridentTopology(storm.trident.TridentTopology) Config(backtype.storm.Config) TridentConfig(backtype.storm.contrib.hbase.utils.TridentConfig) HBaseValueFactory(backtype.storm.contrib.hbase.trident.HBaseValueFactory) TridentConfig(backtype.storm.contrib.hbase.utils.TridentConfig)

Example 38 with LocalCluster

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

the class HBaseTridentAggregateTopology method main.

/**
 * @param args
 * @throws InterruptedException
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] args) throws InterruptedException {
    List<Object> v0 = HBaseCountersBatchTopology.values.get(0).get(0);
    List<Object> v1 = HBaseCountersBatchTopology.values.get(0).get(1);
    List<Object> v2 = HBaseCountersBatchTopology.values.get(0).get(2);
    List<Object> v3 = HBaseCountersBatchTopology.values.get(0).get(3);
    List<Object> v4 = HBaseCountersBatchTopology.values.get(0).get(4);
    List<Object> v5 = HBaseCountersBatchTopology.values.get(1).get(0);
    List<Object> v6 = HBaseCountersBatchTopology.values.get(1).get(1);
    List<Object> v7 = HBaseCountersBatchTopology.values.get(1).get(2);
    List<Object> v8 = HBaseCountersBatchTopology.values.get(2).get(0);
    List<Object> v9 = HBaseCountersBatchTopology.values.get(2).get(1);
    List<Object> v10 = HBaseCountersBatchTopology.values.get(2).get(2);
    HBaseCountersBatchTopology.values.values();
    FixedBatchSpout spout = new FixedBatchSpout(new Fields("shortid", "url", "user", "date"), 3, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10);
    spout.setCycle(false);
    TridentConfig config = new TridentConfig("shorturl", "shortid");
    config.setBatch(false);
    StateFactory state = HBaseAggregateState.transactional(config);
    TridentTopology topology = new TridentTopology();
    topology.newStream("spout", spout).each(new Fields("shortid", "date"), new DatePartitionFunction(), new Fields("cf", "cq")).project(new Fields("shortid", "cf", "cq")).groupBy(new Fields("shortid", "cf", "cq")).persistentAggregate(state, new Count(), new Fields("count"));
    Config conf = new Config();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("hbase-trident-aggregate", conf, topology.build());
    Utils.sleep(5000);
    cluster.shutdown();
}
Also used : FixedBatchSpout(storm.trident.testing.FixedBatchSpout) LocalCluster(backtype.storm.LocalCluster) Fields(backtype.storm.tuple.Fields) StateFactory(storm.trident.state.StateFactory) TridentTopology(storm.trident.TridentTopology) Config(backtype.storm.Config) TridentConfig(backtype.storm.contrib.hbase.utils.TridentConfig) TridentConfig(backtype.storm.contrib.hbase.utils.TridentConfig) Count(storm.trident.operation.builtin.Count)

Aggregations

LocalCluster (backtype.storm.LocalCluster)38 Config (backtype.storm.Config)31 TopologyBuilder (backtype.storm.topology.TopologyBuilder)23 Fields (backtype.storm.tuple.Fields)12 LocalDRPC (backtype.storm.LocalDRPC)3 TupleTableConfig (backtype.storm.contrib.hbase.utils.TupleTableConfig)3 TridentConfig (backtype.storm.contrib.hbase.utils.TridentConfig)2 LinearDRPCTopologyBuilder (backtype.storm.drpc.LinearDRPCTopologyBuilder)2 StormTopology (backtype.storm.generated.StormTopology)2 MemoryTransactionalSpout (backtype.storm.testing.MemoryTransactionalSpout)2 TransactionalTopologyBuilder (backtype.storm.transactional.TransactionalTopologyBuilder)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 KafkaConfig (storm.kafka.KafkaConfig)2 KafkaSpout (storm.kafka.KafkaSpout)2 SpoutConfig (storm.kafka.SpoutConfig)2 TridentTopology (storm.trident.TridentTopology)2 FixedBatchSpout (storm.trident.testing.FixedBatchSpout)2 HBaseBolt (backtype.storm.contrib.hbase.bolts.HBaseBolt)1 HBaseCountersBatchBolt (backtype.storm.contrib.hbase.bolts.HBaseCountersBatchBolt)1