Search in sources :

Example 11 with LocalTopology

use of org.apache.storm.LocalCluster.LocalTopology in project storm by apache.

the class TridentEsTopology method main.

public static void main(String[] args) throws Exception {
    int batchSize = 100;
    FixedBatchSpout spout = new FixedBatchSpout(batchSize);
    spout.setCycle(true);
    TridentTopology topology = new TridentTopology();
    Stream stream = topology.newStream("spout", spout);
    EsConfig esConfig = new EsConfig(EsConstants.clusterName, new String[] { "localhost:9300" });
    Fields esFields = new Fields("index", "type", "source");
    EsTupleMapper tupleMapper = EsTestUtil.generateDefaultTupleMapper();
    StateFactory factory = new EsStateFactory(esConfig, tupleMapper);
    TridentState state = stream.partitionPersist(factory, esFields, new EsUpdater(), new Fields());
    EsTestUtil.startEsNode();
    EsTestUtil.waitForSeconds(5);
    try (LocalCluster cluster = new LocalCluster();
        LocalTopology topo = cluster.submitTopology(TOPOLOGY_NAME, null, topology.build())) {
        EsTestUtil.waitForSeconds(20);
    }
    System.exit(0);
}
Also used : LocalCluster(org.apache.storm.LocalCluster) TridentState(org.apache.storm.trident.TridentState) LocalTopology(org.apache.storm.LocalCluster.LocalTopology) EsConfig(org.apache.storm.elasticsearch.common.EsConfig) Fields(org.apache.storm.tuple.Fields) StateFactory(org.apache.storm.trident.state.StateFactory) TridentTopology(org.apache.storm.trident.TridentTopology) EsTupleMapper(org.apache.storm.elasticsearch.common.EsTupleMapper) Stream(org.apache.storm.trident.Stream)

Example 12 with LocalTopology

use of org.apache.storm.LocalCluster.LocalTopology in project storm by apache.

the class WordCountTrident method main.

public static void main(String[] args) throws Exception {
    Config conf = new Config();
    conf.setMaxSpoutPending(5);
    if (args.length == 1) {
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("wordCounter", conf, buildTopology(args[0]))) {
            Thread.sleep(60 * 1000);
        }
        System.exit(0);
    } else if (args.length == 2) {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopology(args[1], conf, buildTopology(args[0]));
    } else {
        System.out.println("Usage: TridentFileTopology <hdfs url> [topology name]");
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Config(org.apache.storm.Config) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 13 with LocalTopology

use of org.apache.storm.LocalCluster.LocalTopology in project storm by apache.

the class SlidingTupleTsTopology method main.

public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    BaseWindowedBolt bolt = new SlidingWindowSumBolt().withWindow(new Duration(5, TimeUnit.SECONDS), new Duration(3, TimeUnit.SECONDS)).withTimestampField("ts").withLag(new Duration(5, TimeUnit.SECONDS));
    builder.setSpout("integer", new RandomIntegerSpout(), 1);
    builder.setBolt("slidingsum", bolt, 1).shuffleGrouping("integer");
    builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("slidingsum");
    Config conf = new Config();
    conf.setDebug(true);
    if (args != null && args.length > 0) {
        conf.setNumWorkers(1);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
    } else {
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("test", conf, builder.createTopology())) {
            Utils.sleep(40000);
        }
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) Config(org.apache.storm.Config) RandomIntegerSpout(org.apache.storm.starter.spout.RandomIntegerSpout) Duration(org.apache.storm.topology.base.BaseWindowedBolt.Duration) SlidingWindowSumBolt(org.apache.storm.starter.bolt.SlidingWindowSumBolt) PrinterBolt(org.apache.storm.starter.bolt.PrinterBolt) LocalTopology(org.apache.storm.LocalCluster.LocalTopology) BaseWindowedBolt(org.apache.storm.topology.base.BaseWindowedBolt)

Example 14 with LocalTopology

use of org.apache.storm.LocalCluster.LocalTopology in project storm by apache.

the class SlidingWindowTopology method main.

public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("integer", new RandomIntegerSpout(), 1);
    builder.setBolt("slidingsum", new SlidingWindowSumBolt().withWindow(Count.of(30), Count.of(10)), 1).shuffleGrouping("integer");
    builder.setBolt("tumblingavg", new TumblingWindowAvgBolt().withTumblingWindow(Count.of(3)), 1).shuffleGrouping("slidingsum");
    builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("tumblingavg");
    Config conf = new Config();
    conf.setDebug(true);
    if (args != null && args.length > 0) {
        conf.setNumWorkers(1);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
    } else {
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("test", conf, builder.createTopology())) {
            Utils.sleep(40000);
        }
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) Config(org.apache.storm.Config) RandomIntegerSpout(org.apache.storm.starter.spout.RandomIntegerSpout) SlidingWindowSumBolt(org.apache.storm.starter.bolt.SlidingWindowSumBolt) PrinterBolt(org.apache.storm.starter.bolt.PrinterBolt) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 15 with LocalTopology

use of org.apache.storm.LocalCluster.LocalTopology in project storm by apache.

the class TransactionalGlobalCount method main.

public static void main(String[] args) throws Exception {
    MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
    TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("global-count", "spout", spout, 3);
    builder.setBolt("partial-count", new BatchCount(), 5).noneGrouping("spout");
    builder.setBolt("sum", new UpdateGlobalCount()).globalGrouping("partial-count");
    Config config = new Config();
    config.setDebug(true);
    config.setMaxSpoutPending(3);
    try (LocalCluster cluster = new LocalCluster();
        LocalTopology topo = cluster.submitTopology("global-count-topology", config, builder.buildTopology())) {
        Thread.sleep(3000);
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) MemoryTransactionalSpout(org.apache.storm.testing.MemoryTransactionalSpout) Fields(org.apache.storm.tuple.Fields) Config(org.apache.storm.Config) TransactionalTopologyBuilder(org.apache.storm.transactional.TransactionalTopologyBuilder) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Aggregations

LocalTopology (org.apache.storm.LocalCluster.LocalTopology)54 LocalCluster (org.apache.storm.LocalCluster)52 Config (org.apache.storm.Config)50 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)24 Fields (org.apache.storm.tuple.Fields)17 Map (java.util.Map)7 HashMap (java.util.HashMap)6 JedisPoolConfig (org.apache.storm.redis.common.config.JedisPoolConfig)5 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)4 LocalDRPC (org.apache.storm.LocalDRPC)4 StormTopology (org.apache.storm.generated.StormTopology)4 RandomIntegerSpout (org.apache.storm.starter.spout.RandomIntegerSpout)4 Yaml (org.yaml.snakeyaml.Yaml)4 JedisClusterConfig (org.apache.storm.redis.common.config.JedisClusterConfig)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 DruidBeamFactory (org.apache.storm.druid.bolt.DruidBeamFactory)2 ITupleDruidEventMapper (org.apache.storm.druid.bolt.ITupleDruidEventMapper)2 TupleDruidEventMapper (org.apache.storm.druid.bolt.TupleDruidEventMapper)2 EsConfig (org.apache.storm.elasticsearch.common.EsConfig)2