redstorm 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +11 -1
- data/README.md +162 -100
- data/examples/simple/redis_word_count_topology.rb +4 -4
- data/examples/simple/ruby_version_topology.rb +4 -4
- data/examples/simple/word_count_bolt.rb +1 -1
- data/lib/red_storm.rb +1 -37
- data/lib/red_storm/application.rb +14 -11
- data/lib/red_storm/configurator.rb +3 -2
- data/lib/red_storm/environment.rb +27 -17
- data/lib/red_storm/simple_topology.rb +11 -13
- data/lib/red_storm/topology_launcher.rb +3 -26
- data/lib/red_storm/version.rb +1 -1
- data/lib/tasks/red_storm.rake +100 -87
- metadata +119 -112
- data/TODO.md +0 -1
- data/pom.xml +0 -71
data/CHANGELOG.md
CHANGED
@@ -34,4 +34,14 @@
|
|
34
34
|
# 0.5.1, 06-05-2012
|
35
35
|
- better handling of enviroments and paths
|
36
36
|
- redstorm bundle command to install topology gems
|
37
|
-
- issue #26, fixed examples/native for 0.5.1 compatibility
|
37
|
+
- issue #26, fixed examples/native for 0.5.1 compatibility
|
38
|
+
|
39
|
+
# 0.6.0, 06-27-2012
|
40
|
+
- issue #29, updated to Storm 0.7.3
|
41
|
+
- issue #30, add redstorm cluster command for remote topology submission
|
42
|
+
- issue #31, added support for localOrShuffleGrouping
|
43
|
+
- issue #33, avoid forking or shelling out on redstorm commands
|
44
|
+
- JRuby 1.6.7.2
|
45
|
+
- better handling of JRuby 1.8/1.9 mode
|
46
|
+
- topology gems are now specified using a Bundler group in the project Gemfile
|
47
|
+
- refactored environment/paths handling for local vs cluster context
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# RedStorm v0.
|
1
|
+
# RedStorm v0.6.0 - JRuby on Storm
|
2
2
|
|
3
3
|
[](http://travis-ci.org/colinsurprenant/redstorm)
|
4
4
|
|
@@ -6,102 +6,142 @@ RedStorm provides a Ruby DSL using JRuby integration for the [Storm][storm] dist
|
|
6
6
|
|
7
7
|
## Documentation
|
8
8
|
|
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.
|
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.
|
10
10
|
|
11
11
|
### Released gems
|
12
12
|
|
13
13
|
- [RedStorm Gem v0.4.x Documentation](https://github.com/colinsurprenant/redstorm/wiki/RedStorm-Gem-v0.4.x-Documentation)
|
14
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)
|
15
16
|
|
16
17
|
## Dependencies
|
17
18
|
|
18
|
-
Tested on OSX 10.6.8 and Linux 10.04 using Storm 0.
|
19
|
+
Tested on OSX 10.6.8 and Linux 10.04 & 11.10 using Storm 0.7.3 and JRuby 1.6.7.2
|
19
20
|
|
20
21
|
## Notes about 1.8/1.9 JRuby compatibility
|
21
22
|
|
22
|
-
Up until the upcoming JRuby 1.7, JRuby runs in 1.8 Ruby compatibility mode by default. Unless you have a specific need to run topologies in 1.8 mode, you should use 1.9 mode, which will become the default in JRuby.
|
23
|
+
Up until the upcoming JRuby 1.7, JRuby runs in 1.8 Ruby compatibility mode by default. Unless you have a specific need to run topologies in 1.8 mode, you should use 1.9 mode, which will become the default in JRuby.
|
23
24
|
|
24
|
-
|
25
|
-
-
|
26
|
-
- when Storm runs the topology in remote/cluster mode
|
25
|
+
There are two ways to have JRuby 1.6.x run in 1.9 mode by default:
|
26
|
+
- by setting the JRUBY_OPTS env variable
|
27
27
|
|
28
|
-
|
28
|
+
``` sh
|
29
|
+
$ export JRUBY_OPTS=--1.9
|
30
|
+
```
|
31
|
+
- by installing JRuby using RVM with 1.9 mode by default
|
29
32
|
|
30
|
-
|
33
|
+
``` sh
|
34
|
+
$ rvm install jruby --1.9
|
35
|
+
```
|
36
|
+
|
37
|
+
Otherwise, to manually choose the JRuby compatibility mode, this JRuby syntax can be used
|
31
38
|
|
32
|
-
### Latest released gem
|
33
39
|
``` sh
|
34
|
-
$
|
40
|
+
$ jruby --1.9 -S redstorm ...
|
35
41
|
```
|
36
42
|
|
37
|
-
|
38
|
-
|
39
|
-
- clone/fork project
|
43
|
+
By defaut, a topology will be executed in the **same mode** as the interpreter running the `$ redstorm` command. You can force RedStorm to choose a specific JRuby compatibility mode using the [--1.8|--1.9] parameter for the topology execution in local or remote cluster.
|
40
44
|
|
41
45
|
``` sh
|
42
|
-
$
|
43
|
-
$ gem install redstorm-x.y.z.gem
|
46
|
+
$ redstorm local|cluster [--1.8|--1.9] ...
|
44
47
|
```
|
45
48
|
|
49
|
+
## Installation
|
50
|
+
|
51
|
+
- RubyGems
|
52
|
+
|
53
|
+
``` sh
|
54
|
+
$ gem install redstorm
|
55
|
+
```
|
56
|
+
|
57
|
+
- Bundler
|
58
|
+
|
59
|
+
``` ruby
|
60
|
+
source :rubygems
|
61
|
+
gem "redstorm", "~> 0.6.0"
|
62
|
+
```
|
63
|
+
|
46
64
|
## Usage overview
|
47
65
|
|
48
|
-
- create a
|
66
|
+
- create a project directory.
|
49
67
|
- install the [RedStorm gem](http://rubygems.org/gems/redstorm).
|
50
|
-
- create a subdirectory
|
51
|
-
- perform the initial setup as described below to install
|
52
|
-
- run your topology in local mode and/or on a
|
68
|
+
- create a subdirectory for your topology code.
|
69
|
+
- perform the initial setup as described below to build and install dependencies.
|
70
|
+
- run your topology in local mode and/or on a remote cluster as described below.
|
53
71
|
|
54
72
|
### Initial setup
|
55
73
|
|
56
|
-
|
74
|
+
``` sh
|
75
|
+
$ redstorm install
|
76
|
+
```
|
57
77
|
|
58
|
-
|
59
|
-
|
60
|
-
|
78
|
+
or if your default JRuby mode is 1.8 but you want to use 1.9 for your topology development, use
|
79
|
+
|
80
|
+
``` sh
|
81
|
+
$ jruby --1.9 -S redstorm install
|
82
|
+
```
|
61
83
|
|
62
|
-
|
84
|
+
This will basically install all Java jar dependencies in `target/dependency`, generate & compile the Java bindings in `target/classes`.
|
63
85
|
|
64
|
-
|
86
|
+
### Create a topology
|
65
87
|
|
66
|
-
|
88
|
+
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
89
|
|
68
90
|
### Gems in your topology
|
69
91
|
|
70
|
-
RedStorm
|
92
|
+
RedStorm requires [Bundler](http://gembundler.com/) **if gems are needed** in your topology. Basically supply a `Gemfile` in the root of your project directory with the gems required in your topology. If you are using Bundler for other gems **you should** group the topology gems in a Bunder group of your choice.
|
93
|
+
|
94
|
+
1. have Bundler install the gems locally
|
95
|
+
|
96
|
+
``` sh
|
97
|
+
$ bundle install
|
98
|
+
```
|
99
|
+
|
100
|
+
or if your default JRuby mode is 1.8 but you want to use 1.9 for your topology development, use
|
101
|
+
|
102
|
+
``` sh
|
103
|
+
$ jruby --1.9 -S bundle install
|
104
|
+
```
|
105
|
+
|
106
|
+
2. copy the topology gems into the `target/gems` directory
|
71
107
|
|
72
108
|
``` sh
|
73
|
-
$ redstorm
|
109
|
+
$ redstorm bundle [BUNDLER_GROUP]
|
74
110
|
```
|
75
111
|
|
76
|
-
|
112
|
+
Basically, the `redstorm bundle` command copy the gems specified in the Gemfile (in a specific group if specified) into the `target/gems` directory. In order for the topology to run in a Storm cluster, the fully *installed* gems must be packaged and self-contained into a single jar file. **Note** you should **NOT** `require 'bundler/setup'` in the topology.
|
77
113
|
|
78
|
-
|
114
|
+
This has an important consequence: the gems will not be *installed* on the cluster target machines, they are already *installed* in the jar file. This **could lead to problems** if the machine used to *install* the gems is of a different architecture than the cluster target machines **and** some of these gems have **C or FFI** extensions.
|
79
115
|
|
80
116
|
### Run in local mode
|
81
117
|
|
82
118
|
``` sh
|
83
|
-
$ redstorm --1.9
|
119
|
+
$ redstorm local [--1.8|--1.9] <path/to/topology_class_file_name.rb>
|
84
120
|
```
|
85
121
|
|
122
|
+
By defaut, a topology will be executed in the **same mode** as the interpreter running the `$ redstorm` command. You can force RedStorm to choose a specific JRuby compatibility mode using the [--1.8|--1.9] parameter for the topology execution in local or remote cluster.
|
123
|
+
|
86
124
|
**See examples below** to run examples in local mode or on a production cluster.
|
87
125
|
|
88
126
|
### Run on production cluster
|
89
127
|
|
90
|
-
|
128
|
+
1. download and unpack the [Storm 0.7.3 distribution](https://github.com/downloads/nathanmarz/storm/storm-0.7.3.zip) locally and **add** the Storm `bin/` directory to your path
|
129
|
+
|
130
|
+
2. generate `target/cluster-topology.jar`. This jar file will include your sources directory plus the required dependencies
|
91
131
|
|
92
132
|
``` sh
|
93
|
-
$ redstorm
|
133
|
+
$ redstorm jar <sources_directory1> <sources_directory2> ...
|
94
134
|
```
|
95
135
|
|
96
|
-
|
136
|
+
3. submit the cluster topology jar file to the cluster
|
97
137
|
|
98
138
|
``` sh
|
99
|
-
|
139
|
+
$ redstorm cluster [--1.8|--1.9] <path/to/topology_class_file_name.rb>
|
100
140
|
```
|
101
141
|
|
102
|
-
|
142
|
+
By defaut, a topology will be executed in the **same mode** as the interpreter running the `$ redstorm` command. You can force RedStorm to choose a specific JRuby compatibility mode using the [--1.8|--1.9] parameter for the topology execution in local or remote cluster.
|
103
143
|
|
104
|
-
|
144
|
+
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).
|
105
145
|
|
106
146
|
## Examples
|
107
147
|
|
@@ -115,126 +155,139 @@ All examples using the [simple DSL](https://github.com/colinsurprenant/redstorm/
|
|
115
155
|
|
116
156
|
### Local mode
|
117
157
|
|
118
|
-
|
119
|
-
$ redstorm --1.9 local examples/simple/exclamation_topology.rb
|
120
|
-
$ redstorm --1.9 local examples/simple/exclamation_topology2.rb
|
121
|
-
$ redstorm --1.9 local examples/simple/word_count_topology.rb
|
122
|
-
```
|
123
|
-
|
124
|
-
To run `examples/simple/redis_word_count_topology.rb` you need a [Redis][redis] server running on `localhost:6379`
|
158
|
+
#### Example topologies without gems
|
125
159
|
|
126
160
|
``` sh
|
127
|
-
$ redstorm --1.9
|
161
|
+
$ redstorm local --1.9 examples/simple/exclamation_topology.rb
|
162
|
+
$ redstorm local --1.9 examples/simple/exclamation_topology2.rb
|
163
|
+
$ redstorm local --1.9 examples/simple/word_count_topology.rb
|
128
164
|
```
|
129
165
|
|
130
|
-
|
166
|
+
#### Example topologies with gems
|
131
167
|
|
132
|
-
|
133
|
-
$ redstorm --1.9 local examples/simple/redis_word_count_topology.rb
|
134
|
-
```
|
168
|
+
For `examples/simple/redis_word_count_topology.rb` the `redis` gem is required and you need a [Redis][redis] server running on `localhost:6379`
|
135
169
|
|
136
|
-
|
170
|
+
1. create a `Gemfile`
|
137
171
|
|
138
|
-
|
172
|
+
``` ruby
|
173
|
+
source :rubygems
|
139
174
|
|
140
|
-
|
175
|
+
group :word_count do
|
176
|
+
gem "redis"
|
177
|
+
end
|
178
|
+
```
|
141
179
|
|
142
|
-
|
180
|
+
2. install the topology gems
|
143
181
|
|
144
182
|
``` sh
|
145
|
-
$
|
183
|
+
$ jruby --1.9 -S bundle install
|
184
|
+
$ redstorm bundle word_count
|
146
185
|
```
|
147
186
|
|
148
|
-
|
187
|
+
3. run the topology in local mode
|
149
188
|
|
150
189
|
``` sh
|
151
|
-
$
|
190
|
+
$ redstorm local --1.9 examples/simple/redis_word_count_topology.rb
|
152
191
|
```
|
153
192
|
|
154
|
-
|
193
|
+
Using `redis-cli` push words into the `test` list and watch Storm pick them up
|
155
194
|
|
156
|
-
|
195
|
+
### Remote cluster
|
157
196
|
|
158
|
-
|
159
|
-
$ redstorm --1.9 bundle --gemfile examples/simple/Gemfile
|
160
|
-
$ redstorm --1.9 jar examples
|
161
|
-
$ storm jar ./target/cluster-topology.jar -Djruby.compat.version=RUBY1_9 redstorm.TopologyLauncher cluster examples/simple/redis_word_count_topology.rb
|
162
|
-
```
|
197
|
+
All examples using the [simple 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`.
|
163
198
|
|
164
|
-
- using `redis-cli`, push words into the `test` list and watch Storm pick them up
|
165
199
|
|
166
|
-
|
200
|
+
#### Topologies without gems
|
167
201
|
|
168
|
-
|
202
|
+
1. genererate the `target/cluster-topology.jar` and include the `examples/` directory.
|
169
203
|
|
170
|
-
|
204
|
+
``` sh
|
205
|
+
$ redstorm jar examples
|
206
|
+
```
|
171
207
|
|
172
|
-
|
208
|
+
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:
|
173
209
|
|
174
|
-
|
210
|
+
``` sh
|
211
|
+
$ redstorm cluster --1.9 examples/simple/exclamation_topology.rb
|
212
|
+
$ redstorm cluster --1.9 examples/simple/exclamation_topology2.rb
|
213
|
+
$ redstorm cluster --1.9 examples/simple/word_count_topology.rb
|
214
|
+
```
|
175
215
|
|
176
|
-
### Requirements
|
177
216
|
|
178
|
-
|
217
|
+
#### Topologies with gems
|
179
218
|
|
180
|
-
|
219
|
+
For `examples/simple/redis_word_count_topology.rb` the `redis` gem is required and you need a [Redis][redis] server running on `localhost:6379`
|
181
220
|
|
182
|
-
|
221
|
+
1. create a `Gemfile`
|
183
222
|
|
184
|
-
|
223
|
+
``` ruby
|
224
|
+
source :rubygems
|
185
225
|
|
186
|
-
|
226
|
+
group :word_count do
|
227
|
+
gem "redis"
|
228
|
+
end
|
229
|
+
```
|
230
|
+
|
231
|
+
2. install the topology gems
|
232
|
+
|
233
|
+
``` sh
|
187
234
|
$ jruby --1.9 -S bundle install
|
235
|
+
$ redstorm bundle word_count
|
188
236
|
```
|
189
237
|
|
190
|
-
|
238
|
+
3. genererate the `target/cluster-topology.jar` and include the `examples/` directory.
|
191
239
|
|
192
|
-
|
240
|
+
``` sh
|
241
|
+
$ redstorm jar examples
|
242
|
+
```
|
193
243
|
|
194
|
-
|
195
|
-
|
244
|
+
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:
|
245
|
+
|
246
|
+
``` sh
|
247
|
+
$ redstorm cluster --1.9 examples/simple/redis_word_count_topology.rb
|
196
248
|
```
|
197
249
|
|
198
|
-
|
250
|
+
Using `redis-cli` push words into the `test` list and watch Storm pick them up
|
199
251
|
|
200
|
-
|
252
|
+
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).
|
201
253
|
|
202
|
-
|
254
|
+
## Ruby DSL
|
203
255
|
|
204
|
-
|
205
|
-
$ bin/redstorm --1.9 build
|
206
|
-
```
|
256
|
+
[Ruby DSL Documentation](https://github.com/colinsurprenant/redstorm/wiki/Ruby-DSL-Documentation)
|
207
257
|
|
208
|
-
|
258
|
+
## RedStorm Development
|
209
259
|
|
210
|
-
|
260
|
+
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.
|
211
261
|
|
212
|
-
|
262
|
+
### Requirements
|
213
263
|
|
214
|
-
|
215
|
-
$ bin/redstorm --1.9 local path/to/topology_class.rb
|
216
|
-
```
|
264
|
+
- JRuby 1.6.7.x
|
217
265
|
|
218
|
-
|
266
|
+
### Workflow
|
219
267
|
|
220
|
-
|
268
|
+
- fork project and create branch
|
221
269
|
|
222
|
-
-
|
270
|
+
- install RedStorm required gems
|
223
271
|
|
224
272
|
```sh
|
225
|
-
$
|
273
|
+
$ jruby --1.9 -S bundle install
|
226
274
|
```
|
227
275
|
|
228
|
-
|
276
|
+
- install dependencies in `target/dependencies`
|
277
|
+
|
278
|
+
```sh
|
279
|
+
$ bin/redstorm deps
|
280
|
+
```
|
229
281
|
|
230
|
-
-
|
282
|
+
- generate and build Java source into `target/classes`
|
231
283
|
|
232
284
|
```sh
|
233
|
-
$
|
285
|
+
$ jruby --1.9 -S bin/redstorm build
|
234
286
|
```
|
235
287
|
|
236
|
-
**
|
288
|
+
**if you modify any of the RedStorm Ruby code or Java binding code**, you need to run this to refresh code and rebuild the bindings
|
237
289
|
|
290
|
+
- follow the normal usage patterns to run the topology in local or remote cluster.
|
238
291
|
|
239
292
|
### How to Contribute
|
240
293
|
|
@@ -250,9 +303,18 @@ Some ways you can contribute:
|
|
250
303
|
- by refactoring code
|
251
304
|
- ...
|
252
305
|
|
306
|
+
## Projects using RedStorm
|
307
|
+
|
308
|
+
If you want to list your RedStorm project here, contact me.
|
309
|
+
|
310
|
+
- [Tweigeist](https://github.com/colinsurprenant/tweitgeist) - realtime computation of the top trending hashtags on Twitter. [Live Demo](http://tweitgeist.needium.com).
|
311
|
+
|
253
312
|
## Author
|
254
313
|
Colin Surprenant, [@colinsurprenant][twitter], [http://github.com/colinsurprenant][github], colin.surprenant@gmail.com, colin.surprenant@needium.com
|
255
314
|
|
315
|
+
## Contributors
|
316
|
+
Theo Hultberg, https://github.com/iconara
|
317
|
+
|
256
318
|
## License
|
257
319
|
Apache License, Version 2.0. See the LICENSE.md file.
|
258
320
|
|
@@ -1,6 +1,5 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'red_storm'
|
3
|
-
require 'bundler/setup'
|
1
|
+
require 'rubygems'
|
2
|
+
require 'red_storm'
|
4
3
|
|
5
4
|
require 'redis'
|
6
5
|
require 'thread'
|
@@ -15,7 +14,7 @@ module RedStorm
|
|
15
14
|
class RedisWordSpout < RedStorm::SimpleSpout
|
16
15
|
output_fields :word
|
17
16
|
|
18
|
-
on_send {@q.pop if @q.size > 0}
|
17
|
+
on_send {@q.pop.to_s if @q.size > 0}
|
19
18
|
|
20
19
|
on_init do
|
21
20
|
@q = Queue.new
|
@@ -52,6 +51,7 @@ module RedStorm
|
|
52
51
|
when :local
|
53
52
|
max_task_parallelism 3
|
54
53
|
when :cluster
|
54
|
+
max_task_parallelism 5
|
55
55
|
num_workers 20
|
56
56
|
max_spout_pending(1000);
|
57
57
|
end
|
@@ -6,7 +6,7 @@ module RedStorm
|
|
6
6
|
module Examples
|
7
7
|
class VersionSpout < RedStorm::SimpleSpout
|
8
8
|
output_fields :dummy
|
9
|
-
on_init {log.info("
|
9
|
+
on_init {log.info("***************** RUBY_VERSION=#{RUBY_VERSION}")}
|
10
10
|
on_send {}
|
11
11
|
end
|
12
12
|
|
@@ -16,14 +16,14 @@ module RedStorm
|
|
16
16
|
configure do |env|
|
17
17
|
debug true
|
18
18
|
|
19
|
-
#
|
19
|
+
# force the JRuby version property for this topology. this will only affect remote cluster execution
|
20
20
|
# for local execution use the --1.8|--1.9 switch when launching
|
21
|
-
set "topology.worker.childopts", "-Djruby.compat.version=RUBY1_9"
|
21
|
+
# set "topology.worker.childopts", "-Djruby.compat.version=RUBY1_9"
|
22
22
|
end
|
23
23
|
|
24
24
|
on_submit do |env|
|
25
25
|
if env == :local
|
26
|
-
sleep(
|
26
|
+
sleep(5)
|
27
27
|
cluster.shutdown
|
28
28
|
end
|
29
29
|
end
|