2011-12-12 22:16:49 +00:00
|
|
|
require 'red_storm'
|
2011-11-16 21:47:37 +00:00
|
|
|
require 'examples/native/random_sentence_spout'
|
|
|
|
require 'examples/native/split_sentence_bolt'
|
|
|
|
require 'examples/native/word_count_bolt'
|
2011-11-04 21:47:14 +00:00
|
|
|
|
2011-12-12 22:16:49 +00:00
|
|
|
module RedStorm
|
|
|
|
module Examples
|
|
|
|
class ClusterWordCountTopology
|
|
|
|
RedStorm::Configuration.topology_class = self
|
2011-12-09 20:28:23 +00:00
|
|
|
|
2011-12-12 22:16:49 +00:00
|
|
|
def start(base_class_path, env)
|
|
|
|
builder = TopologyBuilder.new
|
2013-05-14 20:32:58 +00:00
|
|
|
builder.setSpout('RandomSentenceSpout', JRubySpout.new(base_class_path, "RedStorm::Examples::RandomSentenceSpout", []), 1)
|
|
|
|
builder.setBolt('SplitSentenceBolt', JRubyBolt.new(base_class_path, "RedStorm::Examples::SplitSentenceBolt", []), 2).shuffleGrouping('RandomSentenceSpout')
|
|
|
|
builder.setBolt('WordCountBolt', JRubyBolt.new(base_class_path, "RedStorm::Examples::WordCountBolt", []), 2).fieldsGrouping('SplitSentenceBolt', Fields.new("word"))
|
2011-11-04 21:47:14 +00:00
|
|
|
|
2012-06-05 21:11:02 +00:00
|
|
|
conf = Backtype::Config.new
|
2011-12-12 22:16:49 +00:00
|
|
|
conf.setDebug(true)
|
2013-05-14 20:32:58 +00:00
|
|
|
conf.setNumWorkers(4);
|
2011-12-12 22:16:49 +00:00
|
|
|
conf.setMaxSpoutPending(1000);
|
|
|
|
StormSubmitter.submitTopology("word_count", conf, builder.createTopology);
|
|
|
|
end
|
|
|
|
end
|
2011-11-04 21:47:14 +00:00
|
|
|
end
|
2013-01-10 09:28:59 +00:00
|
|
|
end
|