redstorm 0.6.5 → 0.6.6.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/CHANGELOG.md +12 -1
  2. data/README.md +66 -47
  3. data/Rakefile +1 -1
  4. data/examples/dsl/exclamation_bolt.rb +10 -0
  5. data/examples/{simple → dsl}/exclamation_topology.rb +5 -5
  6. data/examples/{simple → dsl}/exclamation_topology2.rb +5 -5
  7. data/examples/{simple → dsl}/hello_world_topology.rb +4 -4
  8. data/examples/{simple → dsl}/kafka_topology.rb +17 -18
  9. data/examples/{simple → dsl}/random_sentence_spout.rb +1 -1
  10. data/examples/{simple → dsl}/redis_word_count_topology.rb +6 -7
  11. data/examples/{simple → dsl}/ruby_version_topology.rb +9 -9
  12. data/examples/{simple → dsl}/split_sentence_bolt.rb +6 -6
  13. data/examples/{simple → dsl}/word_count_bolt.rb +2 -2
  14. data/examples/{simple → dsl}/word_count_topology.rb +6 -6
  15. data/examples/shell/shell_topology.rb +2 -2
  16. data/ivy/storm_dependencies.xml +2 -2
  17. data/ivy/topology_dependencies.xml +10 -2
  18. data/lib/red_storm.rb +6 -5
  19. data/lib/red_storm/application.rb +5 -5
  20. data/lib/red_storm/dsl/bolt.rb +155 -0
  21. data/lib/red_storm/dsl/drpc_topology.rb +92 -0
  22. data/lib/red_storm/dsl/spout.rb +194 -0
  23. data/lib/red_storm/dsl/topology.rb +227 -0
  24. data/lib/red_storm/dsl/tuple.rb +34 -0
  25. data/lib/red_storm/environment.rb +8 -8
  26. data/lib/red_storm/topology_launcher.rb +2 -2
  27. data/lib/red_storm/version.rb +1 -1
  28. data/lib/tasks/red_storm.rake +45 -27
  29. data/redstorm.gemspec +4 -4
  30. metadata +31 -34
  31. data/examples/simple/exclamation_bolt.rb +0 -10
  32. data/lib/red_storm/simple_bolt.rb +0 -135
  33. data/lib/red_storm/simple_drpc_topology.rb +0 -87
  34. data/lib/red_storm/simple_spout.rb +0 -184
  35. data/lib/red_storm/simple_topology.rb +0 -219
data/CHANGELOG.md CHANGED
@@ -80,4 +80,15 @@
80
80
  - issue #56 - make topology class configure statement optional
81
81
  - issue #57 - DRPC topologies
82
82
  - issue #73, external jars dependencies Ivy configurations completely externalized and configurable
83
- - lots of other [bug fixes and improvements](https://github.com/colinsurprenant/redstorm/issues?milestone=9&page=1&state=closed)
83
+ - lots of other [bug fixes and improvements](https://github.com/colinsurprenant/redstorm/issues?milestone=9&page=1&state=closed)
84
+
85
+ # 0.6.6, WIP
86
+ - Storm 0.9.0-wip16 and JRuby 1.7.4
87
+ - [issue #79](https://github.com/colinsurprenant/redstorm/issues/79) - fix example Kafka topology dependency doc
88
+ - [issue #82](https://github.com/colinsurprenant/redstorm/issues/82) - configurable javac compilation source/target
89
+ - [issue #83](https://github.com/colinsurprenant/redstorm/issues/83) - syntactic sugar on the Tuple class
90
+ - [issue #84](https://github.com/colinsurprenant/redstorm/issues/84) - DSL classes naming and namespace
91
+ - improved DSL performance by refactoring closures invocation, see [redstorm-benchmark](https://github.com/colinsurprenant/redstorm-benchmark/)
92
+ - fixed FFI support
93
+ - exposed topology builder for specs
94
+ - [issue #11](https://github.com/colinsurprenant/redstorm/issues/11), [#17](https://github.com/colinsurprenant/redstorm/issues/17) - example specs using the Storm testing API see [redstorm-starter](https://github.com/colinsurprenant/redstorm-starter/)
data/README.md CHANGED
@@ -1,24 +1,23 @@
1
- # RedStorm v0.6.5 - JRuby on Storm
1
+ # RedStorm v0.6.6.beta1 - JRuby on Storm
2
2
 
3
3
  [![build status](https://secure.travis-ci.org/colinsurprenant/redstorm.png)](http://travis-ci.org/colinsurprenant/redstorm)
4
4
 
5
5
  RedStorm provides a Ruby DSL using JRuby integration for the [Storm](https://github.com/nathanmarz/storm/) distributed realtime computation system.
6
6
 
7
- ## Documentation
7
+ Like RedStorm? visit us on IRC at #redstorm on freenode
8
+
9
+ Check also these related projects:
8
10
 
9
- Chances are new versions of RedStorm will introduce changes that will break compatibility or change the developement workflow. To prevent out-of-sync documentation, per version specific documentation are kept in the wiki when necessary.
11
+ - [redstorm-starter](https://github.com/colinsurprenant/redstorm-starter/)
12
+ - [redstorm-benchmark](https://github.com/colinsurprenant/redstorm-benchmark/)
10
13
 
11
- ### Released gems
14
+ ## Documentation
12
15
 
13
- - [RedStorm Gem v0.4.x Documentation](https://github.com/colinsurprenant/redstorm/wiki/RedStorm-Gem-v0.4.x-Documentation)
14
- - [RedStorm Gem v0.5.0 Documentation](https://github.com/colinsurprenant/redstorm/wiki/RedStorm-Gem-v0.5.0-Documentation)
15
- - [RedStorm Gem v0.5.1 Documentation](https://github.com/colinsurprenant/redstorm/wiki/RedStorm-Gem-v0.5.1-Documentation)
16
- - [RedStorm Gem v0.6.3 Documentation](https://github.com/colinsurprenant/redstorm/wiki/RedStorm-Gem-v0.6.3-Documentation)
17
- - [RedStorm Gem v0.6.4 Documentation](https://github.com/colinsurprenant/redstorm/wiki/RedStorm-Gem-v0.6.4-Documentation)
16
+ Chances are new versions of RedStorm will introduce changes that will break compatibility or change the developement workflow. To prevent out-of-sync documentation, per version specific documentation are kept [in the wiki](https://github.com/colinsurprenant/redstorm/wiki) when necessary.
18
17
 
19
18
  ## Dependencies
20
19
 
21
- Tested on **OSX 10.8.3** and **Ubuntu Linux 12.10** using **Storm 0.8.2** and **JRuby 1.7.3** and **OpenJDK 7**
20
+ Tested on **OSX 10.8.3** and **Ubuntu Linux 12.10** using **Storm 0.9.0-wip16** and **JRuby 1.7.4** and **OpenJDK 7**
22
21
 
23
22
  ## Installation
24
23
 
@@ -32,7 +31,7 @@ Tested on **OSX 10.8.3** and **Ubuntu Linux 12.10** using **Storm 0.8.2** and **
32
31
 
33
32
  ``` ruby
34
33
  source "https://rubygems.org"
35
- gem "redstorm", "~> 0.6.5"
34
+ gem "redstorm", "~> 0.6.6.beta1"
36
35
  ```
37
36
 
38
37
  ## Usage
@@ -65,30 +64,30 @@ This will install default Java jar dependencies in `target/dependency`, generate
65
64
 
66
65
  Create a subdirectory for your topology code and create your topology class **using this naming convention**: *underscore* topology_class_file_name.rb **MUST** correspond to its *CamelCase* class name.
67
66
 
68
- Here's an example [hello_world_topology.rb](https://github.com/colinsurprenant/redstorm/tree/master/examples/simple/hello_world_topology.rb)
67
+ Here's an example [hello_world_topology.rb](https://github.com/colinsurprenant/redstorm/tree/master/examples/dsl/hello_world_topology.rb)
69
68
 
70
69
  ``` ruby
71
70
  require 'red_storm'
72
71
 
73
- class HelloWorldSpout < RedStorm::SimpleSpout
72
+ class HelloWorldSpout < RedStorm::DSL::Spout
74
73
  on_init {@words = ["hello", "world"]}
75
74
  on_send {@words.shift unless @words.empty?}
76
75
  end
77
76
 
78
- class HelloWorldBolt < RedStorm::SimpleBolt
77
+ class HelloWorldBolt < RedStorm::DSL::Bolt
79
78
  on_receive :emit => false do |tuple|
80
79
  log.info(tuple.getString(0))
81
80
  end
82
81
  end
83
82
 
84
- class HelloWorldTopology < RedStorm::SimpleTopology
83
+ class HelloWorldTopology < RedStorm::DSL::Topology
85
84
  spout HelloWorldSpout do
86
85
  output_fields :word
87
86
  end
88
87
 
89
88
  bolt HelloWorldBolt do
90
89
  source HelloWorldSpout, :global
91
- end
90
+ end
92
91
  end
93
92
  ```
94
93
 
@@ -110,7 +109,7 @@ Note that bundler is only used to help package the gems **prior** to running a t
110
109
  $ redstorm bundle [BUNDLER_GROUP]
111
110
  ```
112
111
 
113
- 3. make sure your topology class has `require "red_storm"`
112
+ 3. make sure your topology class has `require "red_storm"`
114
113
 
115
114
  ```ruby
116
115
  require 'red_storm'
@@ -120,7 +119,7 @@ The `redstorm bundle` command copy the gems specified in the Gemfile (in a speci
120
119
 
121
120
  ### Custom Jar dependencies in your topology (XML Warning! :P)
122
121
 
123
- By defaut, RedStorm installs Storm and JRuby jars dependencies into `target/dependency`. RedStorm uses [Ivy](https://ant.apache.org/ivy/) 2.3 to manage dependencies. You can fully control and customize these dependencies.
122
+ By defaut, RedStorm installs Storm and JRuby jars dependencies into `target/dependency`. RedStorm uses [Ivy](https://ant.apache.org/ivy/) 2.3 to manage dependencies. You can fully control and customize these dependencies.
124
123
 
125
124
  There are two distinct sets of dependencies: the `storm` dependencies manages the requirements (Storm jars) for the Storm **local mode** runtime. The `topology` dependencies manages the requirements (JRuby jars) for the **topology** runtime.
126
125
 
@@ -133,7 +132,7 @@ You can supply custom `storm` and `topology` dependencies by creating `ivy/storm
133
132
  <ivy-module version="2.0">
134
133
  <info organisation="redstorm" module="storm-deps"/>
135
134
  <dependencies>
136
- <dependency org="storm" name="storm" rev="0.8.2" conf="default" transitive="true" />
135
+ <dependency org="storm" name="storm" rev="0.9.0-wip16" conf="default" transitive="true" />
137
136
  <override org="org.slf4j" module="slf4j-log4j12" rev="1.6.3"/>
138
137
  </dependencies>
139
138
  </ivy-module>
@@ -146,7 +145,7 @@ You can supply custom `storm` and `topology` dependencies by creating `ivy/storm
146
145
  <ivy-module version="2.0">
147
146
  <info organisation="redstorm" module="topology-deps"/>
148
147
  <dependencies>
149
- <dependency org="org.jruby" name="jruby-core" rev="1.7.3" conf="default" transitive="true"/>
148
+ <dependency org="org.jruby" name="jruby-core" rev="1.7.4" conf="default" transitive="true"/>
150
149
  </dependencies>
151
150
  </ivy-module>
152
151
  ```
@@ -162,9 +161,9 @@ The jars repositories can be configured by adding the `ivy/settings.xml` file in
162
161
  <resolvers>
163
162
  <chain name="repositories">
164
163
  <ibiblio name="ibiblio" m2compatible="true"/>
165
- <ibiblio name="maven2" root="http://repo.maven.apache.org/maven2/" m2compatible="true"/>
166
- <ibiblio name="sonatype" root="http://repo.maven.apache.org/maven2/" m2compatible="true"/>
167
- <ibiblio name="clojars" root="http://clojars.org/repo/" m2compatible="true"/>
164
+ <ibiblio name="maven2" root="http://repo.maven.apache.org/maven2/" m2compatible="true"/>
165
+ <ibiblio name="sonatype" root="http://repo.maven.apache.org/maven2/" m2compatible="true"/>
166
+ <ibiblio name="clojars" root="http://clojars.org/repo/" m2compatible="true"/>
168
167
  </chain>
169
168
  </resolvers>
170
169
  </ivysettings>
@@ -173,7 +172,13 @@ The jars repositories can be configured by adding the `ivy/settings.xml` file in
173
172
  ### Run in local mode
174
173
 
175
174
  ``` sh
176
- $ redstorm local <path/to/topology_class_file_name.rb>
175
+ $ redstorm local <sources_directory_path/topology_class_file_name.rb>
176
+ ```
177
+
178
+ note that the topology can also be launched with the following command:
179
+
180
+ ``` sh
181
+ $ java -Djruby.compat.version=RUBY1_9 -cp "target/classes:target/dependency/storm/default/*:target/dependency/topology/default/*:<sources_directory_path>" redstorm.TopologyLauncher local <sources_directory_path/topology_class_file_name.rb>
177
182
  ```
178
183
 
179
184
  **See examples below** to run examples in local mode or on a production cluster.
@@ -182,20 +187,34 @@ $ redstorm local <path/to/topology_class_file_name.rb>
182
187
 
183
188
  The Storm distribution is currently required for the cluster topology submission.
184
189
 
185
- 1. download and unpack the [Storm 0.8.2 distribution](https://dl.dropbox.com/u/133901206/storm-0.8.2.zip) locally and **add** the Storm `bin/` directory to your `$PATH`.
190
+ 1. download and unpack the [Storm 0.9.0-wip16 distribution](https://dl.dropbox.com/u/133901206/storm-0.9.0-wip16.zip) locally
191
+
192
+ 2. add the Storm `bin/` directory to your `$PATH`
186
193
 
187
- 2. generate `target/cluster-topology.jar`. This jar file will include your sources directory plus the required dependencies
194
+ 3. create `~/.storm/storm.yaml` and add the following
195
+
196
+ ```yaml
197
+ nimbus.host: "host_name_or_ip"
198
+ ```
199
+
200
+ 4. generate `target/cluster-topology.jar`. This jar file will include your sources directory plus the required dependencies
188
201
 
189
202
  ``` sh
190
203
  $ redstorm jar <sources_directory1> <sources_directory2> ...
191
204
  ```
192
205
 
193
- 3. submit the cluster topology jar file to the cluster
206
+ 5. submit the cluster topology jar file to the cluster
194
207
 
195
208
  ``` sh
196
209
  $ redstorm cluster <sources_directory/topology_class_file_name.rb>
197
210
  ```
198
211
 
212
+ note that the cluster topology jar can also be submitted using the storm command with:
213
+
214
+ ``` sh
215
+ $ storm jar target/cluster-topology.jar -Djruby.compat.version=RUBY1_9 redstorm.TopologyLauncher cluster <sources_directory/topology_class_file_name.rb>
216
+ ```
217
+
199
218
  The [Storm wiki](https://github.com/nathanmarz/storm/wiki) has instructions on [setting up a production cluster](https://github.com/nathanmarz/storm/wiki/Setting-up-a-Storm-cluster). You can also [manually submit your topology](https://github.com/nathanmarz/storm/wiki/Running-topologies-on-a-production-cluster).
200
219
 
201
220
  ## Examples
@@ -206,21 +225,21 @@ Install the [example files](https://github.com/colinsurprenant/redstorm/tree/mas
206
225
  $ redstorm examples
207
226
  ```
208
227
 
209
- All examples using the [DSL](https://github.com/colinsurprenant/redstorm/wiki/Ruby-DSL-Documentation) are located in `examples/simple`. Examples using the standard Java interface are in `examples/native`.
228
+ All examples using the [DSL](https://github.com/colinsurprenant/redstorm/wiki/Ruby-DSL-Documentation) are located in `examples/dsl`. Examples using the standard Java interface are in `examples/native`.
210
229
 
211
230
  ### Local mode
212
231
 
213
- #### Example topologies without gems
232
+ #### Example topologies without gems
214
233
 
215
234
  ``` sh
216
- $ redstorm local examples/simple/exclamation_topology.rb
217
- $ redstorm local examples/simple/exclamation_topology2.rb
218
- $ redstorm local examples/simple/word_count_topology.rb
235
+ $ redstorm local examples/dsl/exclamation_topology.rb
236
+ $ redstorm local examples/dsl/exclamation_topology2.rb
237
+ $ redstorm local examples/dsl/word_count_topology.rb
219
238
  ```
220
239
 
221
- #### Example topologies with gems
240
+ #### Example topologies with gems
222
241
 
223
- For `examples/simple/redis_word_count_topology.rb` the `redis` gem is required and you need a [Redis](http://redis.io/) server running on `localhost:6379`
242
+ For `examples/dsl/redis_word_count_topology.rb` the `redis` gem is required and you need a [Redis](http://redis.io/) server running on `localhost:6379`
224
243
 
225
244
  1. create a `Gemfile`
226
245
 
@@ -242,7 +261,7 @@ For `examples/simple/redis_word_count_topology.rb` the `redis` gem is required a
242
261
  3. run the topology in local mode
243
262
 
244
263
  ``` sh
245
- $ redstorm local examples/simple/redis_word_count_topology.rb
264
+ $ redstorm local examples/dsl/redis_word_count_topology.rb
246
265
  ```
247
266
 
248
267
  Using `redis-cli` push words into the `test` list and watch Storm pick them up
@@ -252,7 +271,7 @@ Using `redis-cli` push words into the `test` list and watch Storm pick them up
252
271
  All examples using the [DSL](https://github.com/colinsurprenant/redstorm/wiki/Ruby-DSL-Documentation) can run in both local or on a remote cluster. The only **native** example compatible with a remote cluster is `examples/native/cluster_word_count_topology.rb`.
253
272
 
254
273
 
255
- #### Topologies without gems
274
+ #### Topologies without gems
256
275
 
257
276
  1. genererate the `target/cluster-topology.jar` and include the `examples/` directory.
258
277
 
@@ -263,15 +282,15 @@ All examples using the [DSL](https://github.com/colinsurprenant/redstorm/wiki/Ru
263
282
  2. submit the cluster topology jar file to the cluster, assuming you have the Storm distribution installed and the Storm `bin/` directory in your path:
264
283
 
265
284
  ``` sh
266
- $ redstorm cluster examples/simple/exclamation_topology.rb
267
- $ redstorm cluster examples/simple/exclamation_topology2.rb
268
- $ redstorm cluster examples/simple/word_count_topology.rb
285
+ $ redstorm cluster examples/dsl/exclamation_topology.rb
286
+ $ redstorm cluster examples/dsl/exclamation_topology2.rb
287
+ $ redstorm cluster examples/dsl/word_count_topology.rb
269
288
  ```
270
289
 
271
290
 
272
- #### Topologies with gems
291
+ #### Topologies with gems
273
292
 
274
- For `examples/simple/redis_word_count_topology.rb` the `redis` gem is required and you need a [Redis](http://redis.io/) server running on `localhost:6379`
293
+ For `examples/dsl/redis_word_count_topology.rb` the `redis` gem is required and you need a [Redis](http://redis.io/) server running on `localhost:6379`
275
294
 
276
295
  1. create a `Gemfile`
277
296
 
@@ -299,7 +318,7 @@ For `examples/simple/redis_word_count_topology.rb` the `redis` gem is required a
299
318
  4. submit the cluster topology jar file to the cluster, assuming you have the Storm distribution installed and the Storm `bin/` directory in your path:
300
319
 
301
320
  ``` sh
302
- $ redstorm cluster examples/simple/redis_word_count_topology.rb
321
+ $ redstorm cluster examples/dsl/redis_word_count_topology.rb
303
322
  ```
304
323
 
305
324
  Using `redis-cli` push words into the `test` list and watch Storm pick them up
@@ -337,7 +356,7 @@ Despite the fact that both transactional and linear DRPC topologies are now [dep
337
356
 
338
357
  - SnakeYAML conflict between Storm and JRuby
339
358
 
340
- See [issue](https://github.com/colinsurprenant/redstorm/issues/78). This is a classic Java world jar conflict. Storm 0.8.2 uses snakeyaml 1.9 and JRuby 1.7.3 uses snakeyaml 1.11. If you try to use YAML serialization in your topology it will crash with an exception. This problem is easy to solve when running topologies in **local** mode, simply override in the storm dependencies with the correct jar version. You can do this be creating a custom storm dependencies:
359
+ See [issue](https://github.com/colinsurprenant/redstorm/issues/78). This is a classic Java world jar conflict. Storm 0.9.0 uses snakeyaml 1.9 and JRuby 1.7.x uses snakeyaml 1.11. If you try to use YAML serialization in your topology it will crash with an exception. This problem is easy to solve when running topologies in **local** mode, simply override in the storm dependencies with the correct jar version. You can do this be creating a custom storm dependencies:
341
360
 
342
361
  - `ivy/storm_dependencies.xml`
343
362
 
@@ -346,7 +365,7 @@ Despite the fact that both transactional and linear DRPC topologies are now [dep
346
365
  <ivy-module version="2.0">
347
366
  <info organisation="redstorm" module="storm-deps"/>
348
367
  <dependencies>
349
- <dependency org="storm" name="storm" rev="0.8.2" conf="default" transitive="true" />
368
+ <dependency org="storm" name="storm" rev="0.9.0-wip16" conf="default" transitive="true" />
350
369
  <override org="org.slf4j" module="slf4j-log4j12" rev="1.6.3"/>
351
370
  <override org="org.yaml" module="snakeyaml" rev="1.11"/>
352
371
  </dependencies>
@@ -354,14 +373,14 @@ Despite the fact that both transactional and linear DRPC topologies are now [dep
354
373
  ```
355
374
 
356
375
  In remote **cluster** mode you will have to update snakeyaml manually or with your favorite deployment/provisioning tool.
357
-
376
+
358
377
  ## RedStorm Development
359
378
 
360
379
  It is possible to fork the RedStorm project and run local and remote/cluster topologies directly from the project sources without installing the gem. This is a useful setup when contributing to the project.
361
380
 
362
381
  ### Requirements
363
382
 
364
- - JRuby 1.7.3
383
+ - JRuby 1.7.4
365
384
 
366
385
  ### Workflow
367
386
 
@@ -412,7 +431,7 @@ If you require Ruby 1.8 support, there are two ways to have JRuby run in 1.8 run
412
431
  $ export JRUBY_OPTS=--1.8
413
432
  ```
414
433
 
415
- - by using the --1.8 option
434
+ - by using the --1.8 option
416
435
 
417
436
  ``` sh
418
437
  $ jruby --1.8 -S redstorm ...
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rspec/core/rake_task'
2
2
 
3
-
3
+ desc "run specs"
4
4
  RSpec::Core::RakeTask.new(:spec) do
5
5
  system("ruby -v")
6
6
  module RedStorm; SPECS_CONTEXT = true; end
@@ -0,0 +1,10 @@
1
+ require 'red_storm'
2
+
3
+ module RedStorm
4
+ module Examples
5
+ class ExclamationBolt < DSL::Bolt
6
+ output_fields :word
7
+ on_receive(:ack => true, :anchor => true) {|tuple| tuple[0] + "!!!"} # tuple[:word] or tuple["word"] are also valid
8
+ end
9
+ end
10
+ end
@@ -1,21 +1,21 @@
1
1
  java_import 'backtype.storm.testing.TestWordSpout'
2
2
 
3
3
  require 'red_storm'
4
- require 'examples/simple/exclamation_bolt'
4
+ require 'examples/dsl/exclamation_bolt'
5
5
 
6
6
  # this example topology uses the Storm TestWordSpout and our own JRuby ExclamationBolt
7
7
 
8
8
  module RedStorm
9
9
  module Examples
10
- class ExclamationTopology < SimpleTopology
10
+ class ExclamationTopology < DSL::Topology
11
11
  spout TestWordSpout, :parallelism => 2 do
12
12
  debug true
13
13
  end
14
-
14
+
15
15
  bolt ExclamationBolt, :parallelism => 2 do
16
16
  source TestWordSpout, :shuffle
17
17
  end
18
-
18
+
19
19
  bolt ExclamationBolt, :id => :ExclamationBolt2, :parallelism => 2 do
20
20
  source ExclamationBolt, :shuffle
21
21
  debug true
@@ -32,7 +32,7 @@ module RedStorm
32
32
 
33
33
  on_submit do |env|
34
34
  if env == :local
35
- sleep(5)
35
+ sleep(10)
36
36
  cluster.shutdown
37
37
  end
38
38
  end
@@ -7,18 +7,18 @@ require 'red_storm'
7
7
 
8
8
  module RedStorm
9
9
  module Examples
10
- class ExclamationBolt < RedStorm::SimpleBolt
10
+ class ExclamationBolt < DSL::Bolt
11
11
  output_fields :word
12
- on_receive(:ack => true, :anchor => true) {|tuple| "!#{tuple.getString(0)}!"}
12
+ on_receive(:ack => true, :anchor => true) {|tuple| "!#{tuple[0]}!"} # tuple[:word] or tuple["word"] are also valid
13
13
  end
14
14
 
15
- class ExclamationTopology2 < RedStorm::SimpleTopology
15
+ class ExclamationTopology2 < DSL::Topology
16
16
  spout TestWordSpout, :parallelism => 2
17
-
17
+
18
18
  bolt ExclamationBolt, :parallelism => 2 do
19
19
  source TestWordSpout, :shuffle
20
20
  end
21
-
21
+
22
22
  bolt ExclamationBolt, :id => :ExclamationBolt2, :parallelism => 2 do
23
23
  source ExclamationBolt, :shuffle
24
24
  end
@@ -1,17 +1,17 @@
1
1
  require 'red_storm'
2
2
 
3
- class HelloWorldSpout < RedStorm::SimpleSpout
3
+ class HelloWorldSpout < RedStorm::DSL::Spout
4
4
  on_init {@words = ["hello", "world"]}
5
5
  on_send {@words.shift unless @words.empty?}
6
6
  end
7
7
 
8
- class HelloWorldBolt < RedStorm::SimpleBolt
8
+ class HelloWorldBolt < RedStorm::DSL::Bolt
9
9
  on_receive :emit => false do |tuple|
10
- log.info(tuple.getString(0))
10
+ log.info(tuple[0]) # tuple[:word] or tuple["word"] are also valid
11
11
  end
12
12
  end
13
13
 
14
- class HelloWorldTopology < RedStorm::SimpleTopology
14
+ class HelloWorldTopology < RedStorm::DSL::Topology
15
15
  spout HelloWorldSpout do
16
16
  output_fields :word
17
17
  end
@@ -6,24 +6,23 @@ java_import 'storm.kafka.KafkaSpout'
6
6
  require 'red_storm'
7
7
 
8
8
  # the KafkaTopology obviously requires a Kafka server running, you can ajust the
9
- # host and port below.
9
+ # host and port below.
10
10
  #
11
11
  # custom dependencies are required for the Kafka and Scala jars. put the following
12
- # dependencies in the "Dependencies" file in the root of your RedStorm project:
12
+ # dependencies in the "ivy/topology_dependencies.xml" file in the root of your RedStorm project:
13
13
  #
14
- # {
15
- # :storm_artifacts => [
16
- # "storm:storm:0.8.1, transitive=true",
17
- # ],
18
- # :topology_artifacts => [
19
- # "org.jruby:jruby-complete:1.6.8, transitive=false",
20
- # "org.scala-lang:scala-library:2.8.0, transitive=false",
21
- # "storm:kafka:0.7.0-incubating, transitive=false",
22
- # "storm:storm-kafka:0.8.0-wip4, transitive=false",
23
- # ],
24
- # }
25
-
26
- class KafkaTopology < RedStorm::SimpleTopology
14
+ # <?xml version="1.0"?>
15
+ # <ivy-module version="2.0">
16
+ # <info organisation="redstorm" module="topology-deps"/>
17
+ # <dependencies>
18
+ # <dependency org="org.jruby" name="jruby-core" rev="1.7.4" conf="default" transitive="true"/>
19
+ # <dependency org="org.scala-lang" name="scala-library" rev="2.8.0" conf="default" transitive="false"/>
20
+ # <dependency org="storm" name="kafka" rev="0.7.0-incubating" conf="default" transitive="false"/>
21
+ # <dependency org="storm" name="storm-kafka" rev="0.8.0-wip4" conf="default" transitive="false"/>
22
+ # </dependencies>
23
+ # </ivy-module>
24
+
25
+ class KafkaTopology < RedStorm::DSL::Topology
27
26
  spout_config = SpoutConfig.new(
28
27
  KafkaConfig::ZkHosts.new("localhost:2181", "/brokers"),
29
28
  "words", # topic to read from
@@ -32,12 +31,12 @@ class KafkaTopology < RedStorm::SimpleTopology
32
31
  )
33
32
  spout_config.scheme = StringScheme.new
34
33
 
35
- class SplitStringBolt < RedStorm::SimpleBolt
36
- on_receive {|tuple| tuple.getString(0).split.map{|w| [w]}}
34
+ class SplitStringBolt < RedStorm::DSL::Bolt
35
+ on_receive {|tuple| tuple[0].split.map{|w| [w]}}
37
36
  end
38
37
 
39
38
  spout KafkaSpout, [spout_config]
40
-
39
+
41
40
  bolt SplitStringBolt do
42
41
  output_fields :word
43
42
  source KafkaSpout, :shuffle