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));
}
}
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));
}
}
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;
}
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));
}
}
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);
}
}
Aggregations