Search in sources :

Example 31 with LocalCluster

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

the class TridentMapExample method main.

public static void main(String[] args) throws Exception {
    Config conf = new Config();
    conf.setMaxSpoutPending(20);
    if (args.length == 0) {
        try (LocalDRPC drpc = new LocalDRPC();
            LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("wordCounter", conf, buildTopology(drpc))) {
            for (int i = 0; i < 100; i++) {
                System.out.println("DRPC RESULT: " + drpc.execute("words", "CAT THE DOG JUMPED"));
                Thread.sleep(1000);
            }
        }
    } else {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, buildTopology(null));
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Config(org.apache.storm.Config) LocalDRPC(org.apache.storm.LocalDRPC) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 32 with LocalCluster

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

the class TridentMinMaxOfDevicesTopology method main.

public static void main(String[] args) throws Exception {
    StormTopology topology = buildDevicesTopology();
    Config conf = new Config();
    conf.setMaxSpoutPending(20);
    if (args.length == 0) {
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("devices-topology", conf, topology)) {
            Utils.sleep(60 * 1000);
        }
        System.exit(0);
    } else {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopologyWithProgressBar("devices-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 33 with LocalCluster

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

the class KafkaSpoutTopologyMainNamedTopics method submitTopologyLocalCluster.

protected void submitTopologyLocalCluster(StormTopology topology, Config config) throws Exception {
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("test", config, topology);
    stopWaitingForInput();
}
Also used : LocalCluster(org.apache.storm.LocalCluster)

Example 34 with LocalCluster

use of org.apache.storm.LocalCluster in project chuidiang-ejemplos by chuidiang.

the class StormMain method main.

public static void main(String[] args) throws InterruptedException, AlreadyAliveException, InvalidTopologyException, AuthorizationException {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(DATA_GENERATOR, new ASpout());
    builder.setBolt(DATA_CALCULATOR, new ABolt()).shuffleGrouping(DATA_GENERATOR);
    builder.setBolt(DATA_PRINTER, new DataPrinter()).shuffleGrouping(DATA_CALCULATOR).shuffleGrouping(DATA_GENERATOR);
    Config config = new Config();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology(TOPOLOGY_NAME, config, builder.createTopology());
    Thread.sleep(100000);
    cluster.killTopology(TOPOLOGY_NAME);
    cluster.shutdown();
}
Also used : LocalCluster(org.apache.storm.LocalCluster) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) Config(org.apache.storm.Config)

Example 35 with LocalCluster

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

the class TridentHBaseWindowingStoreTopology method main.

public static void main(String[] args) throws Exception {
    Config conf = new Config();
    conf.setMaxSpoutPending(20);
    conf.put(Config.TOPOLOGY_TRIDENT_WINDOWING_INMEMORY_CACHE_LIMIT, 100);
    // window-state table should already be created with cf:tuples column
    HBaseWindowsStoreFactory windowStoreFactory = new HBaseWindowsStoreFactory(new HashMap<String, Object>(), "window-state", "cf".getBytes("UTF-8"), "tuples".getBytes("UTF-8"));
    if (args.length == 0) {
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("wordCounterWithWindowing", conf, buildTopology(windowStoreFactory))) {
            Utils.sleep(120 * 1000);
        }
        System.exit(0);
    } else {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, buildTopology(windowStoreFactory));
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) HBaseWindowsStoreFactory(org.apache.storm.hbase.trident.windowing.HBaseWindowsStoreFactory) Config(org.apache.storm.Config) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Aggregations

LocalCluster (org.apache.storm.LocalCluster)79 Config (org.apache.storm.Config)71 LocalTopology (org.apache.storm.LocalCluster.LocalTopology)52 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)28 Fields (org.apache.storm.tuple.Fields)22 Map (java.util.Map)14 StreamBuilder (org.apache.storm.streams.StreamBuilder)9 HashMap (java.util.HashMap)7 RandomIntegerSpout (org.apache.storm.starter.spout.RandomIntegerSpout)7 LocalDRPC (org.apache.storm.LocalDRPC)6 JedisPoolConfig (org.apache.storm.redis.common.config.JedisPoolConfig)6 TestWordSpout (org.apache.storm.testing.TestWordSpout)5 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)4 StormSubmitter (org.apache.storm.StormSubmitter)4 StormTopology (org.apache.storm.generated.StormTopology)4 ValueMapper (org.apache.storm.streams.operations.mappers.ValueMapper)4 TopologyContext (org.apache.storm.task.TopologyContext)4 Utils (org.apache.storm.utils.Utils)4 Yaml (org.yaml.snakeyaml.Yaml)4