redstorm/examples/simple/exclamation_topology2.rb

43 lines
1.0 KiB
Ruby
Raw Normal View History

2011-11-16 18:52:13 +00:00
# this example topology uses the Storm TestWordSpout and our own JRuby ExclamationBolt
# and a locally defined ExclamationBolt
2013-05-14 20:32:58 +00:00
java_import 'backtype.storm.testing.TestWordSpout'
require 'red_storm'
module RedStorm
module Examples
class ExclamationBolt < RedStorm::SimpleBolt
output_fields :word
on_receive(:ack => true, :anchor => true) {|tuple| "!#{tuple.getString(0)}!"}
end
2011-11-16 18:52:13 +00:00
class ExclamationTopology2 < RedStorm::SimpleTopology
2013-05-14 20:32:58 +00:00
spout TestWordSpout, :parallelism => 2
2013-05-14 20:32:58 +00:00
bolt ExclamationBolt, :parallelism => 2 do
source TestWordSpout, :shuffle
end
bolt ExclamationBolt, :id => :ExclamationBolt2, :parallelism => 2 do
source ExclamationBolt, :shuffle
end
2011-11-16 18:52:13 +00:00
configure do |env|
debug true
2013-05-14 20:32:58 +00:00
max_task_parallelism 4
if env == :cluster
num_workers 4
max_spout_pending(1000)
end
end
2011-11-16 18:52:13 +00:00
on_submit do |env|
if env == :local
sleep(5)
cluster.shutdown
end
end
2011-11-16 18:52:13 +00:00
end
end
end