redstorm 0.5.0 → 0.5.1
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 +5 -0
- data/README.md +24 -10
- data/examples/native/Gemfile +2 -0
- data/examples/native/cluster_word_count_topology.rb +1 -1
- data/examples/native/exclamation_bolt.rb +3 -0
- data/examples/native/local_exclamation_topology.rb +1 -1
- data/examples/native/local_exclamation_topology2.rb +4 -1
- data/examples/native/local_redis_word_count_topology.rb +5 -1
- data/examples/native/local_word_count_topology.rb +1 -1
- data/examples/native/random_sentence_spout.rb +3 -3
- data/examples/native/split_sentence_bolt.rb +3 -0
- data/examples/native/word_count_bolt.rb +3 -0
- data/lib/red_storm.rb +28 -31
- data/lib/red_storm/application.rb +2 -2
- data/lib/red_storm/environment.rb +28 -0
- data/lib/red_storm/topology_launcher.rb +30 -12
- data/lib/red_storm/version.rb +1 -1
- data/lib/tasks/red_storm.rake +67 -42
- data/pom.xml +1 -1
- metadata +4 -2
data/CHANGELOG.md
CHANGED
@@ -30,3 +30,8 @@
|
|
30
30
|
- JRuby 1.6.7
|
31
31
|
- DSL Support for per bolt/spout configuration and spout activate/deactivate in Storm 0.7.x
|
32
32
|
- consistent workflow using the redstorm command in local dev or gem mode
|
33
|
+
|
34
|
+
# 0.5.1, 06-05-2012
|
35
|
+
- better handling of enviroments and paths
|
36
|
+
- redstorm bundle command to install topology gems
|
37
|
+
- issue #26, fixed examples/native for 0.5.1 compatibility
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# RedStorm v0.5.
|
1
|
+
# RedStorm v0.5.1 - JRuby on Storm
|
2
2
|
|
3
3
|
[](http://travis-ci.org/colinsurprenant/redstorm)
|
4
4
|
|
@@ -8,9 +8,10 @@ RedStorm provides a Ruby DSL using JRuby integration for the [Storm][storm] dist
|
|
8
8
|
|
9
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. This README reflects the current/master developement state.
|
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
|
+
- [RedStorm Gem v0.5.0 Documentation](https://github.com/colinsurprenant/redstorm/wiki/RedStorm-Gem-v0.5.0-Documentation)
|
14
15
|
|
15
16
|
## Dependencies
|
16
17
|
|
@@ -28,7 +29,7 @@ For each of these contexts, 1.9 mode has to be explicitly specified to avoid any
|
|
28
29
|
|
29
30
|
## Installation
|
30
31
|
|
31
|
-
###
|
32
|
+
### Latest released gem
|
32
33
|
``` sh
|
33
34
|
$ gem install redstorm
|
34
35
|
```
|
@@ -69,12 +70,12 @@ $ gem install redstorm-x.y.z.gem
|
|
69
70
|
RedStorm now support [Bundler](http://gembundler.com/) for using gems in your topology. Basically supply a `Gemfile` in the root of your project directory and execute this command to install the gems into the `target/gems` directory. **Note that if you change the Gemfile you must rerun this command**.
|
70
71
|
|
71
72
|
``` sh
|
72
|
-
$ redstorm --1.9
|
73
|
+
$ redstorm --1.9 bundle [--gemfile=GEMFILE]
|
73
74
|
```
|
74
75
|
|
75
|
-
All `bundle install` command options can be passed as options to `redstorm --1.9
|
76
|
+
All `bundle install` command options can be passed as options to `redstorm --1.9 bundle` like `--gemfile=GEMFILE` to specify a Gemfile in an alternate path.
|
76
77
|
|
77
|
-
Basically, the `redstorm --1.9
|
78
|
+
Basically, the `redstorm --1.9 bundle` command installs the *Bundler* and *Rake* gems and all the gems specified in the Gemfile into the `target/gems` directory. The idea is that in order for the topology to run in a Storm cluster, everything, including the fully *installed* gems, must be packaged and self-contained into a single JAR file. 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 possibly 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 *native* C/FFI extensions.
|
78
79
|
|
79
80
|
### Run in local mode
|
80
81
|
|
@@ -123,7 +124,7 @@ $ redstorm --1.9 local examples/simple/word_count_topology.rb
|
|
123
124
|
To run `examples/simple/redis_word_count_topology.rb` you need a [Redis][redis] server running on `localhost:6379`
|
124
125
|
|
125
126
|
``` sh
|
126
|
-
$ redstorm --1.9
|
127
|
+
$ redstorm --1.9 bundle --gemfile examples/simple/Gemfile
|
127
128
|
```
|
128
129
|
|
129
130
|
Run the topology in local mode
|
@@ -155,7 +156,7 @@ All examples using the [simple DSL](https://github.com/colinsurprenant/redstorm/
|
|
155
156
|
- to run `examples/simple/redis_word_count_topology.rb` you need a [Redis][redis] server running on `localhost:6379`
|
156
157
|
|
157
158
|
``` sh
|
158
|
-
$ redstorm --1.9
|
159
|
+
$ redstorm --1.9 bundle --gemfile examples/simple/Gemfile
|
159
160
|
$ redstorm --1.9 jar examples
|
160
161
|
$ storm jar ./target/cluster-topology.jar -Djruby.compat.version=RUBY1_9 redstorm.TopologyLauncher cluster examples/simple/redis_word_count_topology.rb
|
161
162
|
```
|
@@ -179,25 +180,34 @@ It is possible to fork the RedStorm project and run local and remote/cluster top
|
|
179
180
|
### Workflow
|
180
181
|
|
181
182
|
- fork project and create branch
|
183
|
+
|
182
184
|
- install required gems
|
183
185
|
|
184
186
|
```sh
|
185
187
|
$ jruby --1.9 -S bundle install
|
186
188
|
```
|
187
189
|
|
190
|
+
---
|
191
|
+
|
188
192
|
- install dependencies in `target/dependencies`
|
189
193
|
|
190
194
|
```sh
|
191
195
|
$ bin/redstorm --1.9 deps
|
192
196
|
```
|
193
197
|
|
198
|
+
**if you modify any of the RedStorm Ruby code** in `lib/red_storm`, you need to run this to refresh code in `target/`.
|
199
|
+
|
200
|
+
---
|
201
|
+
|
194
202
|
- generate and build Java source into `target/classes`
|
195
203
|
|
196
204
|
```sh
|
197
205
|
$ bin/redstorm --1.9 build
|
198
206
|
```
|
199
207
|
|
200
|
-
if you modify any of the Java binding code
|
208
|
+
**if you modify any of the Java binding code**, you need to run this to rebuild the bindings
|
209
|
+
|
210
|
+
---
|
201
211
|
|
202
212
|
- run topology in **local** Storm mode
|
203
213
|
|
@@ -207,16 +217,20 @@ It is possible to fork the RedStorm project and run local and remote/cluster top
|
|
207
217
|
|
208
218
|
If you only make changes to your topology code, this is the only step you need to repeat to try your updated code.
|
209
219
|
|
220
|
+
---
|
221
|
+
|
210
222
|
- generate remote cluster topology jar into `target/cluster-topology.jar`, including the `mydir/` directory.
|
211
223
|
|
212
224
|
```sh
|
213
225
|
$ bin/redstorm --1.9 jar mydir otherdir1 otherdir2 ...
|
214
226
|
```
|
215
227
|
|
228
|
+
---
|
229
|
+
|
216
230
|
- **if you add/change** Gemfile for your topology, install gems in `target/gems`. Alternate gemfile path can be specified using --gemfile=GEMFILE
|
217
231
|
|
218
232
|
```sh
|
219
|
-
$ bin/redstorm --1.9
|
233
|
+
$ bin/redstorm --1.9 bundle [--gemfile=GEMFILE]
|
220
234
|
```
|
221
235
|
|
222
236
|
**do not forget** to rerurn `bin/redstorm --1.9 jar ...` to pick up these gems, before submitting your topology on a remote cluster.
|
@@ -14,7 +14,7 @@ module RedStorm
|
|
14
14
|
builder.setBolt('SplitSentenceBolt', JRubyBolt.new(base_class_path, "RedStorm::Examples::SplitSentenceBolt"), 4).shuffleGrouping('RandomSentenceSpout')
|
15
15
|
builder.setBolt('WordCountBolt', JRubyBolt.new(base_class_path, "RedStorm::Examples::WordCountBolt"), 4).fieldsGrouping('SplitSentenceBolt', Fields.new("word"))
|
16
16
|
|
17
|
-
conf = Config.new
|
17
|
+
conf = Backtype::Config.new
|
18
18
|
conf.setDebug(true)
|
19
19
|
conf.setNumWorkers(20);
|
20
20
|
conf.setMaxSpoutPending(1000);
|
@@ -17,7 +17,7 @@ module RedStorm
|
|
17
17
|
builder.setBolt('ExclamationBolt1', JRubyBolt.new(base_class_path, 'RedStorm::Examples::ExclamationBolt'), 3).shuffleGrouping('TestWordSpout')
|
18
18
|
builder.setBolt('ExclamationBolt2', JRubyBolt.new(base_class_path, 'RedStorm::Examples::ExclamationBolt'), 3).shuffleGrouping('ExclamationBolt1')
|
19
19
|
|
20
|
-
conf = Config.new
|
20
|
+
conf = Backtype::Config.new
|
21
21
|
conf.setDebug(true)
|
22
22
|
|
23
23
|
cluster = LocalCluster.new
|
@@ -14,6 +14,9 @@ module RedStorm
|
|
14
14
|
@collector.ack(tuple)
|
15
15
|
end
|
16
16
|
|
17
|
+
def get_component_configuration
|
18
|
+
end
|
19
|
+
|
17
20
|
def declare_output_fields(declarer)
|
18
21
|
declarer.declare(Fields.new("word"))
|
19
22
|
end
|
@@ -31,7 +34,7 @@ module RedStorm
|
|
31
34
|
builder.setBolt('ExclamationBolt21', JRubyBolt.new(base_class_path, "RedStorm::Examples::ExclamationBolt2"), 3).shuffleGrouping('TestWordSpout')
|
32
35
|
builder.setBolt('ExclamationBolt22', JRubyBolt.new(base_class_path, "RedStorm::Examples::ExclamationBolt2"), 2).shuffleGrouping('ExclamationBolt21')
|
33
36
|
|
34
|
-
conf = Config.new
|
37
|
+
conf = Backtype::Config.new
|
35
38
|
conf.setDebug(true)
|
36
39
|
|
37
40
|
cluster = LocalCluster.new
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'bundler/setup'
|
1
2
|
require 'redis'
|
2
3
|
require 'thread'
|
3
4
|
require 'lib/red_storm'
|
@@ -23,6 +24,9 @@ module RedStorm
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
27
|
+
def get_component_configuration
|
28
|
+
end
|
29
|
+
|
26
30
|
def declare_output_fields(declarer)
|
27
31
|
declarer.declare(Fields.new("word"))
|
28
32
|
end
|
@@ -51,7 +55,7 @@ module RedStorm
|
|
51
55
|
builder.setSpout('RedisWordSpout', JRubySpout.new(base_class_path, "RedStorm::Examples::RedisWordSpout"), 1)
|
52
56
|
builder.setBolt('WordCountBolt', JRubyBolt.new(base_class_path, "RedStorm::Examples::WordCountBolt"), 3).fieldsGrouping('RedisWordSpout', Fields.new("word"))
|
53
57
|
|
54
|
-
conf = Config.new
|
58
|
+
conf = Backtype::Config.new
|
55
59
|
conf.setDebug(true)
|
56
60
|
conf.setMaxTaskParallelism(3)
|
57
61
|
|
@@ -14,7 +14,7 @@ module Examples
|
|
14
14
|
builder.setBolt('SplitSentenceBolt', JRubyBolt.new(base_class_path, "RedStorm::Examples::SplitSentenceBolt"), 8).shuffleGrouping('RandomSentenceSpout')
|
15
15
|
builder.setBolt('WordCountBolt', JRubyBolt.new(base_class_path, "RedStorm::Examples::WordCountBolt"), 12).fieldsGrouping('SplitSentenceBolt', Fields.new("word"))
|
16
16
|
|
17
|
-
conf = Config.new
|
17
|
+
conf = Backtype::Config.new
|
18
18
|
conf.setDebug(true)
|
19
19
|
conf.setMaxTaskParallelism(3)
|
20
20
|
|
@@ -1,10 +1,7 @@
|
|
1
1
|
module RedStorm
|
2
2
|
module Examples
|
3
3
|
class RandomSentenceSpout
|
4
|
-
attr_reader :is_distributed
|
5
|
-
|
6
4
|
def initialize
|
7
|
-
@is_distributed = true
|
8
5
|
@sentences = [
|
9
6
|
"the cow jumped over the moon",
|
10
7
|
"an apple a day keeps the doctor away",
|
@@ -22,6 +19,9 @@ module RedStorm
|
|
22
19
|
@collector.emit(Values.new(@sentences[rand(@sentences.length)]))
|
23
20
|
end
|
24
21
|
|
22
|
+
def get_component_configuration
|
23
|
+
end
|
24
|
+
|
25
25
|
def declare_output_fields(declarer)
|
26
26
|
declarer.declare(Fields.new("word"))
|
27
27
|
end
|
data/lib/red_storm.rb
CHANGED
@@ -1,34 +1,41 @@
|
|
1
|
+
# this is the entry point for these two contexts:
|
2
|
+
# - running red_storm.rake
|
3
|
+
# - at remote cluster topology execution. Once topology_launcher.rb has submitted the topology
|
4
|
+
# the spouts and bolts classes will be instanciated and will require red_storm.rb
|
5
|
+
|
1
6
|
# we depends on rubygems begings loaded at this point for setting up gem/bundle environments
|
2
7
|
# explicitely requiring rubygems is required in remote cluster environment
|
3
8
|
require 'rubygems'
|
4
9
|
|
10
|
+
# setup some environment constants
|
11
|
+
# this is required here and in topology_launcher.rb which are both
|
12
|
+
# entry points in redstorm.
|
5
13
|
module RedStorm
|
6
|
-
|
7
|
-
JAR_CONTEXT = !!(LAUNCH_PATH =~ /\.jar!$/)
|
14
|
+
TOPOLOGY_LAUNCHED = defined?(LAUNCH_PATH)
|
8
15
|
|
9
|
-
if
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
BUNDLE_PATH = "#{TARGET_PATH}/bundler/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}/"
|
14
|
-
GEM_PATH = "#{TARGET_PATH}/gems/"
|
15
|
-
else
|
16
|
-
REDSTORM_HOME = File.expand_path(LAUNCH_PATH + '/..')
|
17
|
-
TARGET_PATH = Dir.pwd
|
18
|
-
BUNDLE_GEMFILE = "#{TARGET_PATH}/target/gems/bundler/Gemfile"
|
19
|
-
BUNDLE_PATH = "#{TARGET_PATH}/target/gems/bundler/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}/"
|
20
|
-
GEM_PATH = "#{TARGET_PATH}/target/gems/gems"
|
21
|
-
end
|
16
|
+
# do not redefine if already defined in topology_launcher.rb
|
17
|
+
unless TOPOLOGY_LAUNCHED
|
18
|
+
LAUNCH_PATH = File.expand_path(File.dirname(__FILE__))
|
19
|
+
JAR_CONTEXT = !!(LAUNCH_PATH =~ /\.jar!$/)
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
if JAR_CONTEXT
|
22
|
+
BASE_PATH = LAUNCH_PATH
|
23
|
+
else
|
24
|
+
BASE_PATH = Dir.pwd
|
25
|
+
end
|
26
|
+
end
|
28
27
|
end
|
29
28
|
|
30
|
-
|
29
|
+
unless RedStorm::JAR_CONTEXT
|
30
|
+
# in JAR context red_storm.rb and red_storm/* is in the JAR root.
|
31
|
+
# otherwise this is in lib/...
|
32
|
+
$:.unshift "#{RedStorm::BASE_PATH}/lib"
|
33
|
+
end
|
31
34
|
|
35
|
+
unless RedStorm::TOPOLOGY_LAUNCHED
|
36
|
+
require 'red_storm/environment'
|
37
|
+
RedStorm.setup_gems if RedStorm::JAR_CONTEXT
|
38
|
+
end
|
32
39
|
|
33
40
|
require 'red_storm/version'
|
34
41
|
require 'red_storm/configuration'
|
@@ -36,13 +43,3 @@ require 'red_storm/application'
|
|
36
43
|
require 'red_storm/simple_bolt'
|
37
44
|
require 'red_storm/simple_spout'
|
38
45
|
require 'red_storm/simple_topology'
|
39
|
-
|
40
|
-
# puts("************************ PWD=#{Dir.pwd}")
|
41
|
-
# puts("************************ RedStorm::JAR_CONTEXT=#{RedStorm::JAR_CONTEXT}")
|
42
|
-
# puts("************************ RedStorm::LAUNCH_PATH=#{RedStorm::LAUNCH_PATH}")
|
43
|
-
# puts("************************ RedStorm::REDSTORM_HOME=#{RedStorm::REDSTORM_HOME}")
|
44
|
-
# puts("************************ RedStorm::TARGET_PATH=#{RedStorm::TARGET_PATH}")
|
45
|
-
# puts("************************ RedStorm::GEM_PATH=#{RedStorm::GEM_PATH}")
|
46
|
-
# puts("************************ ENV['BUNDLE_GEMFILE']=#{ENV['BUNDLE_GEMFILE']}")
|
47
|
-
# puts("************************ ENV['BUNDLE_PATH']=#{ENV['BUNDLE_PATH']}")
|
48
|
-
# puts("************************ ENV['GEM_PATH']=#{ENV['GEM_PATH']}")
|
@@ -7,7 +7,7 @@ module RedStorm
|
|
7
7
|
TASKS_FILE = "#{RedStorm::REDSTORM_HOME}/lib/tasks/red_storm.rake"
|
8
8
|
|
9
9
|
def usage
|
10
|
-
puts("usage: redstorm [--1.8|--1.9] install | deps | build | examples | gems [--gemfile GEMFILE_PATH] | jar DIR1, DIR2, ... | local TOPOLOGY_CLASS_PATH")
|
10
|
+
puts("usage: redstorm [--1.8|--1.9] install | deps | build | examples | gems | bundle [--gemfile GEMFILE_PATH] | jar DIR1, DIR2, ... | local TOPOLOGY_CLASS_PATH")
|
11
11
|
exit(1)
|
12
12
|
end
|
13
13
|
|
@@ -16,7 +16,7 @@ module RedStorm
|
|
16
16
|
version = args.delete("--1.8") || args.delete("--1.9") || DEFAULT_RUBY_VERSION
|
17
17
|
RUNTIME['RUBY_VERSION'] = version
|
18
18
|
|
19
|
-
if ["install", "examples", "jar", "gems", "deps", "build"].include?(args[0])
|
19
|
+
if ["install", "examples", "jar", "gems", "bundle", "deps", "build"].include?(args[0])
|
20
20
|
load(TASKS_FILE)
|
21
21
|
Rake::Task[args.shift].invoke(args.join(":"))
|
22
22
|
exit
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module RedStorm
|
2
|
+
# LAUNCH_PATH, BASE_PATH and JAR_CONTEXT must be set before requiring this module
|
3
|
+
# typically, they must be set in either red_storm.rb and topology_launcher.rd
|
4
|
+
# which are the 2 entry points
|
5
|
+
|
6
|
+
if JAR_CONTEXT
|
7
|
+
REDSTORM_HOME = LAUNCH_PATH
|
8
|
+
TARGET_PATH = LAUNCH_PATH
|
9
|
+
BUNDLE_GEMFILE = "#{TARGET_PATH}/bundler/Gemfile"
|
10
|
+
BUNDLE_PATH = "#{TARGET_PATH}/bundler/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}/"
|
11
|
+
GEM_PATH = "#{TARGET_PATH}/gems/"
|
12
|
+
else
|
13
|
+
REDSTORM_HOME = File.expand_path(LAUNCH_PATH + '/..')
|
14
|
+
TARGET_PATH = "#{BASE_PATH}/target"
|
15
|
+
BUNDLE_GEMFILE = "#{TARGET_PATH}/gems/bundler/Gemfile"
|
16
|
+
BUNDLE_PATH = "#{TARGET_PATH}/gems/bundler/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}/"
|
17
|
+
GEM_PATH = "#{TARGET_PATH}/gems/gems"
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup_gems
|
21
|
+
ENV['BUNDLE_GEMFILE'] = RedStorm::BUNDLE_GEMFILE
|
22
|
+
ENV['BUNDLE_PATH'] = RedStorm::BUNDLE_PATH
|
23
|
+
ENV["GEM_PATH"] = RedStorm::GEM_PATH
|
24
|
+
ENV['BUNDLE_DISABLE_SHARED_GEMS'] = "1"
|
25
|
+
end
|
26
|
+
|
27
|
+
module_function :setup_gems
|
28
|
+
end
|
@@ -1,14 +1,4 @@
|
|
1
1
|
require 'java'
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
|
-
begin
|
5
|
-
# will work from gem, since lib dir is in gem require_paths
|
6
|
-
require 'red_storm'
|
7
|
-
rescue LoadError
|
8
|
-
# will work within RedStorm dev project
|
9
|
-
$:.unshift './lib'
|
10
|
-
require 'red_storm'
|
11
|
-
end
|
12
2
|
|
13
3
|
# see https://github.com/colinsurprenant/redstorm/issues/7
|
14
4
|
module Backtype
|
@@ -27,20 +17,48 @@ java_import 'redstorm.storm.jruby.JRubySpout'
|
|
27
17
|
|
28
18
|
java_package 'redstorm'
|
29
19
|
|
20
|
+
# setup some environment constants
|
21
|
+
# this is required here and in red_storm.rb which are both
|
22
|
+
# entry points in redstorm.
|
23
|
+
module RedStorm
|
24
|
+
LAUNCH_PATH = File.expand_path(File.dirname(__FILE__))
|
25
|
+
JAR_CONTEXT = !!(LAUNCH_PATH =~ /\.jar!$/)
|
26
|
+
|
27
|
+
if JAR_CONTEXT
|
28
|
+
BASE_PATH = LAUNCH_PATH
|
29
|
+
LIB_PATH = "#{BASE_PATH}/lib"
|
30
|
+
else
|
31
|
+
BASE_PATH = Dir.pwd
|
32
|
+
LIB_PATH = "#{BASE_PATH}/target/lib"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
30
36
|
# TopologyLauncher is the application entry point when launching a topology. Basically it will
|
31
37
|
# call require on the specified Ruby topology class file path and call its start method
|
32
38
|
class TopologyLauncher
|
33
39
|
|
34
40
|
java_signature 'void main(String[])'
|
35
41
|
def self.main(args)
|
36
|
-
|
42
|
+
# this is the entry point for these two contexts:
|
43
|
+
# - runnig a topology in local mode. the current Ruby env will stay the same at topology execution
|
44
|
+
# - submitting a topology in cluster mode. the current Ruby env will be valid only at topology submission. At topology execution
|
45
|
+
# in the cluster, the new entry point will be the red_storm.rb, topology_launcher will not be called
|
46
|
+
|
47
|
+
unless args.size > 1
|
37
48
|
puts("Usage: redstorm local|cluster topology_class_file_name")
|
38
49
|
exit(1)
|
39
50
|
end
|
51
|
+
|
40
52
|
env = args[0].to_sym
|
41
53
|
class_path = args[1]
|
42
54
|
|
43
|
-
|
55
|
+
$:.unshift "#{RedStorm::BASE_PATH}"
|
56
|
+
$:.unshift "#{RedStorm::LIB_PATH}"
|
57
|
+
|
58
|
+
require 'red_storm/environment'
|
59
|
+
RedStorm.setup_gems
|
60
|
+
|
61
|
+
require "#{class_path}"
|
44
62
|
|
45
63
|
topology_name = RedStorm::Configuration.topology_class.respond_to?(:topology_name) ? "/#{RedStorm::Configuration.topology_class.topology_name}" : ''
|
46
64
|
puts("RedStorm v#{RedStorm::VERSION} starting topology #{RedStorm::Configuration.topology_class.name}#{topology_name} in #{env.to_s} environment")
|
data/lib/red_storm/version.rb
CHANGED
data/lib/tasks/red_storm.rake
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
require 'ant'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
require 'red_storm'
|
3
|
+
|
4
|
+
# begin
|
5
|
+
# # will work from gem, since lib dir is in gem require_paths
|
6
|
+
# require 'red_storm'
|
7
|
+
# rescue LoadError
|
8
|
+
# # will work within RedStorm dev project
|
9
|
+
# $:.unshift './lib'
|
10
|
+
# require 'red_storm'
|
11
|
+
# end
|
12
|
+
|
12
13
|
INSTALL_STORM_VERSION = "0.7.1"
|
13
14
|
INSTALL_JRUBY_VERSION = "1.6.7"
|
14
15
|
DEFAULT_GEMFILE = "Gemfile"
|
15
16
|
|
16
17
|
CWD = Dir.pwd
|
17
18
|
TARGET_DIR = "#{CWD}/target"
|
19
|
+
TARGET_LIB_DIR = "#{TARGET_DIR}/lib"
|
18
20
|
TARGET_SRC_DIR = "#{TARGET_DIR}/src"
|
19
21
|
TARGET_CLASSES_DIR = "#{TARGET_DIR}/classes"
|
20
22
|
TARGET_DEPENDENCY_DIR = "#{TARGET_DIR}/dependency"
|
@@ -23,15 +25,16 @@ TARGET_MARKERS_DIR = "#{TARGET_DIR}/dependency-markers"
|
|
23
25
|
TARGET_GEMS_DIR = "#{TARGET_DIR}/gems"
|
24
26
|
TARGET_CLUSTER_JAR = "#{TARGET_DIR}/cluster-topology.jar"
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
REDSTORM_JAVA_SRC_DIR = "#{RedStorm::REDSTORM_HOME}/src/main"
|
29
|
+
REDSTORM_LIB_DIR = "#{RedStorm::REDSTORM_HOME}/lib"
|
28
30
|
|
29
31
|
SRC_EXAMPLES = "#{RedStorm::REDSTORM_HOME}/examples"
|
30
32
|
DST_EXAMPLES = "#{CWD}/examples"
|
31
33
|
|
32
34
|
task :launch, :env, :class_file do |t, args|
|
33
35
|
version_token = RedStorm::RUNTIME['RUBY_VERSION'] == "--1.9" ? "RUBY1_9" : "RUBY1_8"
|
34
|
-
gem_home = ENV["GEM_HOME"].to_s.empty? ? " -Djruby.gem.home=`gem env home`" : ""
|
36
|
+
# gem_home = ENV["GEM_HOME"].to_s.empty? ? " -Djruby.gem.home=`gem env home`" : ""
|
37
|
+
gem_home = " -Djruby.gem.home=#{RedStorm::GEM_PATH}"
|
35
38
|
command = "java -Djruby.compat.version=#{version_token} -cp \"#{TARGET_CLASSES_DIR}:#{TARGET_DEPENDENCY_DIR}/*\"#{gem_home} redstorm.TopologyLauncher #{args[:env]} #{args[:class_file]}"
|
36
39
|
puts("launching #{command}")
|
37
40
|
system(command)
|
@@ -64,15 +67,16 @@ task :install => [:deps, :build, :gems] do
|
|
64
67
|
end
|
65
68
|
|
66
69
|
task :unpack do
|
67
|
-
system("rmvn dependency:unpack \
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
system("rmvn dependency:unpack " + \
|
71
|
+
"-f #{RedStorm::REDSTORM_HOME}/pom.xml " + \
|
72
|
+
"-DoutputDirectory=#{TARGET_DEPENDENCY_UNPACKED_DIR} " + \
|
73
|
+
"-DmarkersDirectory=#{TARGET_MARKERS_DIR} " + \
|
74
|
+
"-Dstorm-storm.version=#{INSTALL_STORM_VERSION} " + \
|
75
|
+
"-Dorg.jruby-jruby-complete.version=#{INSTALL_JRUBY_VERSION}")
|
73
76
|
end
|
74
77
|
|
75
78
|
task :jar, [:include_dir] => [:unpack, :clean_jar] do |t, args|
|
79
|
+
puts("\n--> Generating JAR file #{TARGET_CLUSTER_JAR}")
|
76
80
|
ant.jar :destfile => TARGET_CLUSTER_JAR do
|
77
81
|
fileset :dir => TARGET_CLASSES_DIR
|
78
82
|
fileset :dir => TARGET_DEPENDENCY_UNPACKED_DIR
|
@@ -80,7 +84,9 @@ task :jar, [:include_dir] => [:unpack, :clean_jar] do |t, args|
|
|
80
84
|
# remove bundler config dir to avoid setting BUNDLE_PATH
|
81
85
|
exclude :name => "bundler/.bundle/**"
|
82
86
|
end
|
83
|
-
|
87
|
+
# red_storm.rb and red_storm/* must be in root of jar so that "require 'red_storm'"
|
88
|
+
# in bolts/spouts works in jar context
|
89
|
+
fileset :dir => TARGET_LIB_DIR do
|
84
90
|
exclude :name => "tasks/**"
|
85
91
|
end
|
86
92
|
fileset :dir => CWD do
|
@@ -90,7 +96,7 @@ task :jar, [:include_dir] => [:unpack, :clean_jar] do |t, args|
|
|
90
96
|
attribute :name => "Main-Class", :value => "redstorm.TopologyLauncher"
|
91
97
|
end
|
92
98
|
end
|
93
|
-
puts("\nRedStorm generated
|
99
|
+
puts("\nRedStorm generated JAR file #{TARGET_CLUSTER_JAR}")
|
94
100
|
end
|
95
101
|
|
96
102
|
task :examples do
|
@@ -103,63 +109,82 @@ task :examples do
|
|
103
109
|
exit(1)
|
104
110
|
end
|
105
111
|
|
106
|
-
puts("
|
112
|
+
puts("\n--> Installing examples into #{DST_EXAMPLES}")
|
107
113
|
system("mkdir #{DST_EXAMPLES}")
|
108
114
|
system("cp -r #{SRC_EXAMPLES}/* #{DST_EXAMPLES}")
|
109
|
-
puts("\nRedStorm examples completed. All examples copied in #{DST_EXAMPLES}")
|
110
115
|
end
|
111
116
|
|
112
117
|
task :deps => :setup do
|
113
118
|
puts("\n--> Installing dependencies")
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
119
|
+
# install maven dependencies in target
|
120
|
+
system("rmvn dependency:copy-dependencies " + \
|
121
|
+
"-f #{RedStorm::REDSTORM_HOME}/pom.xml " + \
|
122
|
+
"-DoutputDirectory=#{TARGET_DEPENDENCY_DIR} " + \
|
123
|
+
"-DmarkersDirectory=#{TARGET_MARKERS_DIR} " + \
|
124
|
+
"-Dstorm-storm.version=#{INSTALL_STORM_VERSION} " + \
|
125
|
+
"-Dorg.jruby-jruby-complete.version=#{INSTALL_JRUBY_VERSION}")
|
126
|
+
|
127
|
+
# copy RedStorm lib dir in target
|
128
|
+
system("cp -r #{REDSTORM_LIB_DIR} #{TARGET_DIR}")
|
120
129
|
end
|
121
130
|
|
122
131
|
task :build => :setup do
|
123
132
|
# compile the JRuby proxy classes to Java
|
124
|
-
build_jruby("#{
|
133
|
+
build_jruby("#{REDSTORM_LIB_DIR}/red_storm/proxy")
|
125
134
|
|
126
135
|
# compile the generated Java proxy classes
|
127
136
|
build_java_dir("#{TARGET_SRC_DIR}")
|
128
137
|
|
129
138
|
# generate the JRuby topology launcher
|
130
|
-
build_jruby("#{
|
139
|
+
build_jruby("#{REDSTORM_LIB_DIR}/red_storm/topology_launcher.rb")
|
131
140
|
|
132
141
|
# compile the JRuby proxy classes
|
133
|
-
build_java_dir("#{
|
142
|
+
build_java_dir("#{REDSTORM_JAVA_SRC_DIR}")
|
134
143
|
|
135
144
|
# compile the JRuby proxy classes
|
136
145
|
build_java_dir("#{TARGET_SRC_DIR}")
|
137
146
|
end
|
138
147
|
|
139
|
-
task :
|
148
|
+
task :bundle, [:bundler_options] => :gems do |t, args|
|
140
149
|
bundler_options = args[:bundler_options].to_s.split(":").join(" ")
|
141
150
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
bundler_options
|
151
|
+
gemfile = ""
|
152
|
+
if bundler_options.split(" ").size == 1
|
153
|
+
gemfile = bundler_options
|
154
|
+
bundler_options = ""
|
146
155
|
else
|
147
|
-
|
156
|
+
gemfile = (bundler_options =~ /--gemfile\s+([^\s]+)/) ? $1 : DEFAULT_GEMFILE
|
148
157
|
end
|
149
158
|
|
150
|
-
|
151
|
-
|
152
|
-
|
159
|
+
if bundler_options =~ /--gemfile\s+[^\s]+/
|
160
|
+
bundler_options.gsub!(/--gemfile\s+[^\s]+/, "--gemfile ./Gemfile ")
|
161
|
+
else
|
162
|
+
bundler_options = bundler_options + " --gemfile ./Gemfile"
|
163
|
+
end
|
164
|
+
bundler_options = bundler_options + " --path ./"
|
153
165
|
|
154
166
|
if File.exist?(gemfile)
|
155
167
|
puts("\n--> Bundling gems in #{TARGET_GEMS_DIR}/bundler using #{gemfile}")
|
156
168
|
system("cp #{gemfile} #{TARGET_GEMS_DIR}/bundler/Gemfile")
|
157
|
-
|
169
|
+
cmd = "(cd #{TARGET_GEMS_DIR}/bundler; " + \
|
170
|
+
"unset BUNDLE_GEMFILE; " + \
|
171
|
+
"unset BUNDLE_PATH; " + \
|
172
|
+
"unset RUBYOPT; " + \
|
173
|
+
"export GEM_PATH=#{RedStorm::GEM_PATH}; " + \
|
174
|
+
"export GEM_HOME=#{RedStorm::GEM_PATH}; " + \
|
175
|
+
"jruby #{RedStorm::RUNTIME['RUBY_VERSION']} -S bundle install #{bundler_options})"
|
176
|
+
system(cmd)
|
158
177
|
elsif gemfile != DEFAULT_GEMFILE
|
159
178
|
puts("WARNING: #{gemfile} not found, cannot bundle gems")
|
160
179
|
end
|
161
180
|
end
|
162
181
|
|
182
|
+
task :gems => :setup do
|
183
|
+
puts("\n--> Installing base gems in #{TARGET_GEMS_DIR}/gems")
|
184
|
+
system("gem install bundler --install-dir #{TARGET_GEMS_DIR}/gems --no-ri --no-rdoc --quiet --no-verbose")
|
185
|
+
system("gem install rake --install-dir #{TARGET_GEMS_DIR}/gems --no-ri --no-rdoc --quiet --no-verbose")
|
186
|
+
end
|
187
|
+
|
163
188
|
def build_java_dir(source_folder)
|
164
189
|
puts("\n--> Compiling Java")
|
165
190
|
ant.javac(
|
data/pom.xml
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: redstorm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Colin Surprenant
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-06-
|
13
|
+
date: 2012-06-05 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/red_storm/application.rb
|
60
60
|
- lib/red_storm/configuration.rb
|
61
61
|
- lib/red_storm/configurator.rb
|
62
|
+
- lib/red_storm/environment.rb
|
62
63
|
- lib/red_storm/loggable.rb
|
63
64
|
- lib/red_storm/simple_bolt.rb
|
64
65
|
- lib/red_storm/simple_spout.rb
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- lib/tasks/red_storm.rake
|
71
72
|
- examples/native/cluster_word_count_topology.rb
|
72
73
|
- examples/native/exclamation_bolt.rb
|
74
|
+
- examples/native/Gemfile
|
73
75
|
- examples/native/local_exclamation_topology.rb
|
74
76
|
- examples/native/local_exclamation_topology2.rb
|
75
77
|
- examples/native/local_redis_word_count_topology.rb
|