30 lines
610 B
Ruby
30 lines
610 B
Ruby
|
require 'red_storm'
|
||
|
|
||
|
class HelloWorldSpout < RedStorm::DSL::Spout
|
||
|
on_init {@words = ["hello", "world"]}
|
||
|
on_send {@words.shift unless @words.empty?}
|
||
|
end
|
||
|
|
||
|
class HelloWorldBolt < RedStorm::DSL::Bolt
|
||
|
on_receive :emit => false do |tuple|
|
||
|
log.info(tuple[0]) # tuple[:word] or tuple["word"] are also valid
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class HelloWorldTopology < RedStorm::DSL::Topology
|
||
|
spout HelloWorldSpout do
|
||
|
output_fields :word
|
||
|
end
|
||
|
|
||
|
bolt HelloWorldBolt do
|
||
|
source HelloWorldSpout, :global
|
||
|
end
|
||
|
|
||
|
configure do
|
||
|
debug false
|
||
|
max_task_parallelism 4
|
||
|
num_workers 1
|
||
|
max_spout_pending 1000
|
||
|
end
|
||
|
end
|