use of backtype.storm.LocalCluster in project heron by twitter.
the class ComponentJVMOptionsTopology method main.
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new TestWordSpout(), 2);
builder.setBolt("exclaim1", new ExclamationBolt(), 2).shuffleGrouping("word");
Config conf = new Config();
conf.setDebug(true);
conf.setMaxSpoutPending(10);
conf.setComponentRam("word", ByteAmount.fromMegabytes(500));
conf.setComponentRam("exclaim1", ByteAmount.fromGigabytes(1));
// TOPOLOGY_WORKER_CHILDOPTS will be a global one
conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
// For each component, both the global and if any the component one will be appended.
// And the component one will take precedence
conf.setComponentJvmOptions("word", "-XX:NewSize=300m");
conf.setComponentJvmOptions("exclaim1", "-XX:NewSize=800m");
if (args != null && args.length > 0) {
conf.setNumStmgrs(1);
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
} else {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
cluster.killTopology("test");
cluster.shutdown();
}
}
use of backtype.storm.LocalCluster in project storm-signals by ptgoetz.
the class SignalTopology method main.
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("signal-spout", new TestSignalSpout("test-signal-spout"));
Config conf = new Config();
conf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(120000);
cluster.killTopology("test");
cluster.shutdown();
}
use of backtype.storm.LocalCluster in project ud381 by udacity.
the class TopNTweetTopology method main.
public static void main(String[] args) throws Exception {
// Variable TOP_N number of words
int TOP_N = 5;
// create the topology
TopologyBuilder builder = new TopologyBuilder();
/*
* In order to create the spout, you need to get twitter credentials
* If you need to use Twitter firehose/Tweet stream for your idea,
* create a set of credentials by following the instructions at
*
* https://dev.twitter.com/discussions/631
*
*/
// now create the tweet spout with the credentials
// credential
TweetSpout tweetSpout = new TweetSpout("", "", "", "");
// attach the tweet spout to the topology - parallelism of 1
builder.setSpout("tweet-spout", tweetSpout, 1);
// attach the parse tweet bolt using shuffle grouping
builder.setBolt("parse-tweet-bolt", new ParseTweetBolt(), 10).shuffleGrouping("tweet-spout");
builder.setBolt("infoBolt", new InfoBolt(), 10).fieldsGrouping("parse-tweet-bolt", new Fields("county_id"));
builder.setBolt("top-words", new TopWords(), 10).fieldsGrouping("infoBolt", new Fields("county_id"));
builder.setBolt("report-bolt", new ReportBolt(), 1).globalGrouping("top-words");
// attach rolling count bolt using fields grouping - parallelism of 5
// builder.setBolt("rolling-count-bolt", new RollingCountBolt(1000, 10), 1).fieldsGrouping("parse-tweet-bolt", new Fields("tweet-word"));
// from incubator-storm/.../storm/starter/RollingTopWords.java
// builder.setBolt("intermediate-ranker", new IntermediateRankingsBolt(TOP_N, 10), 2).fieldsGrouping("rolling-count-bolt", new Fields("obj"));
// builder.setBolt("total-ranker", new TotalRankingsBolt(TOP_N, 2)).globalGrouping("intermediate-ranker");
/*
* total-ranker bolt output is broadcast (allGrouping) to all the top-tweets bolt instances so
* that every one of them have access to the top hashtags
* tweet-spout tweet stream will be distributed randomly to the top-tweets bolt instances
*/
// builder.setBolt("top-tweets", new TweetsWithTopHashtagsBolt(), 4)
// .allGrouping("total-ranker")
// .shuffleGrouping("tweet-spout");
// attach the report bolt using global grouping - parallelism of 1
// builder.setBolt("report-bolt", new ReportBolt(), 1).globalGrouping("top-tweets");
// create the default config object
Config conf = new Config();
// set the config in debugging mode
conf.setDebug(true);
if (args != null && args.length > 0) {
// run it in a live cluster
// set the number of workers for running all spout and bolt tasks
conf.setNumWorkers(3);
// create the topology and submit with config
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
} else {
// run it in a simulated local cluster
// set the number of threads to run - similar to setting number of workers in live cluster
conf.setMaxTaskParallelism(4);
// create the local cluster instance
LocalCluster cluster = new LocalCluster();
// submit the topology to the local cluster
cluster.submitTopology("tweet-word-count", conf, builder.createTopology());
// let the topology run for 300 seconds. note topologies never terminate!
Utils.sleep(300000000);
// now kill the topology
cluster.killTopology("tweet-word-count");
// we are done, so shutdown the local cluster
cluster.shutdown();
}
}
use of backtype.storm.LocalCluster in project ud381 by udacity.
the class SentenceCountTopology method main.
public static void main(String[] args) throws Exception {
// create the topology
TopologyBuilder builder = new TopologyBuilder();
// attach the word spout to the topology - parallelism of 5
// builder.setSpout("word-spout", new WordSpout(), 5);
// attach sentence spout to the topology - parallelism of 1
builder.setSpout("sentence-spout", new RandomSentenceSpout(), 1);
// attach the count bolt using fields grouping - parallelism of 15
builder.setBolt("count-bolt", new CountBolt(), 15).fieldsGrouping("sentence-spout", new Fields("sentence"));
// attach the report bolt using global grouping - parallelism of 1
// ***************************************************
// BEGIN YOUR CODE - part 2
builder.setBolt("report-bolt", new ReportBolt(), 1).globalGrouping("count-bolt");
// END YOUR CODE
// ***************************************************
// create the default config object
Config conf = new Config();
// set the config in debugging mode
conf.setDebug(true);
if (args != null && args.length > 0) {
// run it in a live cluster
// set the number of workers for running all spout and bolt tasks
conf.setNumWorkers(3);
// create the topology and submit with config
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
} else {
// run it in a simulated local cluster
// set the number of threads to run - similar to setting number of workers in live cluster
conf.setMaxTaskParallelism(3);
// create the local cluster instance
LocalCluster cluster = new LocalCluster();
// submit the topology to the local cluster
// name topology
cluster.submitTopology("sentence-count", conf, builder.createTopology());
// **********************************************************************
// let the topology run for 30 seconds. note topologies never terminate!
Thread.sleep(30000);
// **********************************************************************
// we are done, so shutdown the local cluster
cluster.shutdown();
}
}
use of backtype.storm.LocalCluster in project storm-hbase by ypf412.
the class OutputTopology method main.
/**
* HBase Data Output Topology
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
PropConfig pc = new PropConfig("storm.properties");
int topoWorkers = Integer.valueOf(pc.getProperty("storm.topolopy.workers"));
int spoutTasks = Integer.valueOf(pc.getProperty("storm.spout.tasks"));
builder.setSpout("hbaseSpout", new HBaseSpout(), spoutTasks);
int boltTasks = spoutTasks;
builder.setBolt("outputBolt", new OutputBolt(), boltTasks).fieldsGrouping("hbaseSpout", new Fields("sharding"));
Config conf = new Config();
conf.put(Constants.STORM_PROP_CONF_FILE, "storm.properties");
conf.put(Constants.HBASE_PROP_CONF_FILE, "hbase.properties");
if (args != null && args.length > 0) {
// run on storm cluster
conf.setNumAckers(1);
conf.setNumWorkers(topoWorkers);
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
} else {
// run on local cluster
conf.setMaxTaskParallelism(3);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
cluster.killTopology("test");
cluster.shutdown();
}
}
Aggregations