Search in sources :

Example 61 with LocalCluster

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

the class FileReadWordCountTopo method main.

public static void main(String[] args) throws Exception {
    if (args.length <= 0) {
        // For IDE based profiling ... submit topology to local cluster
        Config conf = new Config();
        conf.put(INPUT_FILE, "resources/randomwords.txt");
        LocalCluster cluster = Helper.runOnLocalCluster(TOPOLOGY_NAME, getTopology(conf));
        Helper.setupShutdownHook(cluster, TOPOLOGY_NAME);
        while (true) {
            //  run indefinitely till Ctrl-C
            Thread.sleep(20_000_000);
        }
    } else {
        //  Submit to Storm cluster
        if (args.length != 2) {
            System.err.println("args: runDurationSec  confFile");
            return;
        }
        Integer durationSec = Integer.parseInt(args[0]);
        Map topoConf = Utils.findAndReadConfigFile(args[1]);
        Helper.runOnClusterAndPrintMetrics(durationSec, TOPOLOGY_NAME, topoConf, getTopology(topoConf));
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Config(org.apache.storm.Config) Map(java.util.Map)

Example 62 with LocalCluster

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

the class StrGenSpoutHdfsBoltTopo method main.

/** Spout generates random strings and HDFS bolt writes them to a text file */
public static void main(String[] args) throws Exception {
    if (args.length <= 0) {
        // submit to local cluster
        Map topoConf = Utils.findAndReadConfigFile("conf/HdfsSpoutTopo.yaml");
        LocalCluster cluster = Helper.runOnLocalCluster(TOPOLOGY_NAME, getTopology(topoConf));
        Helper.setupShutdownHook(cluster, TOPOLOGY_NAME);
        while (true) {
            //  run indefinitely till Ctrl-C
            Thread.sleep(20_000_000);
        }
    } else {
        //  Submit to Storm cluster
        if (args.length != 2) {
            System.err.println("args: runDurationSec confFile");
            return;
        }
        Integer durationSec = Integer.parseInt(args[0]);
        Map topoConf = Utils.findAndReadConfigFile(args[1]);
        Helper.runOnClusterAndPrintMetrics(durationSec, TOPOLOGY_NAME, topoConf, getTopology(topoConf));
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Map(java.util.Map)

Example 63 with LocalCluster

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

the class Helper method runOnLocalCluster.

public static LocalCluster runOnLocalCluster(String topoName, StormTopology topology) throws Exception {
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology(topoName, new Config(), topology);
    return cluster;
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Config(org.apache.storm.Config)

Example 64 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)

Example 65 with LocalCluster

use of org.apache.storm.LocalCluster 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)

Aggregations

LocalCluster (org.apache.storm.LocalCluster)76 Config (org.apache.storm.Config)70 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 RandomIntegerSpout (org.apache.storm.starter.spout.RandomIntegerSpout)7 HashMap (java.util.HashMap)6 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