Search in sources :

Example 26 with LocalTopology

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

the class TridentMinMaxOfVehiclesTopology method main.

public static void main(String[] args) throws Exception {
    StormTopology topology = buildVehiclesTopology();
    Config conf = new Config();
    conf.setMaxSpoutPending(20);
    if (args.length == 0) {
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("vehicles-topology", conf, topology)) {
            Utils.sleep(60 * 1000);
        }
        System.exit(0);
    } else {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopologyWithProgressBar("vehicles-topology", conf, topology);
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 27 with LocalTopology

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

the class TridentReach method main.

public static void main(String[] args) throws Exception {
    Config conf = new Config();
    try (LocalDRPC drpc = new LocalDRPC();
        LocalCluster cluster = new LocalCluster();
        LocalTopology topo = cluster.submitTopology("reach", conf, buildTopology(drpc))) {
        Thread.sleep(2000);
        System.out.println("REACH: " + drpc.execute("reach", "aaa"));
        System.out.println("REACH: " + drpc.execute("reach", "foo.com/blog/1"));
        System.out.println("REACH: " + drpc.execute("reach", "engineering.twitter.com/blog/5"));
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Config(org.apache.storm.Config) LocalDRPC(org.apache.storm.LocalDRPC) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 28 with LocalTopology

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

the class TridentWindowingInmemoryStoreTopology method main.

public static void main(String[] args) throws Exception {
    Config conf = new Config();
    WindowsStoreFactory mapState = new InMemoryWindowsStoreFactory();
    if (args.length == 0) {
        List<? extends WindowConfig> list = Arrays.asList(SlidingCountWindow.of(1000, 100), TumblingCountWindow.of(1000), SlidingDurationWindow.of(new BaseWindowedBolt.Duration(6, TimeUnit.SECONDS), new BaseWindowedBolt.Duration(3, TimeUnit.SECONDS)), TumblingDurationWindow.of(new BaseWindowedBolt.Duration(3, TimeUnit.SECONDS)));
        for (WindowConfig windowConfig : list) {
            try (LocalCluster cluster = new LocalCluster();
                LocalTopology topo = cluster.submitTopology("wordCounter", conf, buildTopology(mapState, windowConfig))) {
                Utils.sleep(60 * 1000);
            }
        }
        System.exit(0);
    } else {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, buildTopology(mapState, SlidingCountWindow.of(1000, 100)));
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Config(org.apache.storm.Config) InMemoryWindowsStoreFactory(org.apache.storm.trident.windowing.InMemoryWindowsStoreFactory) WindowsStoreFactory(org.apache.storm.trident.windowing.WindowsStoreFactory) InMemoryWindowsStoreFactory(org.apache.storm.trident.windowing.InMemoryWindowsStoreFactory) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 29 with LocalTopology

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

the class StatefulTopology method main.

public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("spout", new RandomIntegerSpout());
    builder.setBolt("partialsum", new StatefulSumBolt("partial"), 1).shuffleGrouping("spout");
    builder.setBolt("printer", new PrinterBolt(), 2).shuffleGrouping("partialsum");
    builder.setBolt("total", new StatefulSumBolt("total"), 1).shuffleGrouping("printer");
    Config conf = new Config();
    conf.setDebug(false);
    if (args != null && args.length > 0) {
        conf.setNumWorkers(1);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
    } else {
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topology = 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) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 30 with LocalTopology

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

the class StatefulWindowingTopology method main.

public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("spout", new RandomIntegerSpout());
    builder.setBolt("sumbolt", new WindowSumBolt().withWindow(new Count(5), new Count(3)).withMessageIdField("msgid"), 1).shuffleGrouping("spout");
    builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("sumbolt");
    Config conf = new Config();
    conf.setDebug(false);
    //conf.put(Config.TOPOLOGY_STATE_PROVIDER, "org.apache.storm.redis.state.RedisKeyValueStateProvider");
    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) Count(org.apache.storm.topology.base.BaseWindowedBolt.Count) PrinterBolt(org.apache.storm.starter.bolt.PrinterBolt) 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