colinsurprenant/redstorm — Issue #5: redstorm should support namespaced class definition
Author: stonegao
Created: 2011-12-09 11:31:13+00:00
State: open

I tried add namespace to word_count_topology.rb in examples/simple/ :

```ruby
require 'examples/simple/random_sentence_spout'
require 'examples/simple/split_sentence_bolt'
require 'examples/simple/word_count_bolt'
module Example
module Simple
class WordCountTopology < RedStorm::SimpleTopology
spout RandomSentenceSpout, :parallelism => 5

bolt SplitSentenceBolt, :parallelism => 8 do
source RandomSentenceSpout, :shuffle
end

bolt WordCountBolt, :parallelism => 12 do
source SplitSentenceBolt, :fields => ["word"]
end

configure :word_count do |env|
case env
when :local
debug true
max_task_parallelism 3
when :cluster
debug true
num_workers 20
max_spout_pending(1000);
end
end

on_submit do |env|
if env == :local
sleep(5)
cluster.shutdown
end
end
end

end
end

```

But after adding namespace, redstorm can't find WordCountTopology anymore. For real projects, we need to use namespace to organize code, so redstorm should support namespaced class definition.

stone-laptop:redstorm-try stone$ redstorm local examples/simple/word_count_topology.rb
launching java -cp "/Users/stone/tmp/redstorm-try/target/classes:/Users/stone/tmp/redstorm-try/target/dependency/*" redstorm.TopologyLauncher local examples/simple/word_count_topology.rb
file:/Users/stone/tmp/redstorm-try/target/dependency/jruby-complete-1.6.5.jar!/builtin/javasupport/core_ext/object.rb:99 warning: already initialized constant Config
RedStorm v0.2.1 starting topology WordCountTopology in local environment
1 [main] ERROR org.apache.zookeeper.server.NIOServerCnxn - Thread Thread[main,5,main] died
org.jruby.exceptions.RaiseException: (NameError) uninitialized constant WordCountTopology
at org.jruby.RubyModule.const_missing(org/jruby/RubyModule.java:2590)
at #.(eval)((eval):1)
at org.jruby.RubyModule.module_eval(org/jruby/RubyModule.java:2246)
at #.main(/Users/stone/.rvm/gems/jruby-1.6.5/gems/redstorm-0.2.0/lib/red_storm/topology_launcher.rb:43)