redstorm 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/README.md +363 -32
- data/Rakefile +10 -125
- data/bin/redstorm +1 -0
- data/examples/{cluster_word_count_topology.rb → native/cluster_word_count_topology.rb} +4 -4
- data/examples/{exclamation_bolt.rb → native/exclamation_bolt.rb} +0 -0
- data/examples/{local_exclamation_topology.rb → native/local_exclamation_topology.rb} +2 -2
- data/examples/{local_exclamation_topology2.rb → native/local_exclamation_topology2.rb} +1 -1
- data/examples/{local_redis_word_count_topology.rb → native/local_redis_word_count_topology.rb} +2 -2
- data/examples/{local_word_count_topology.rb → native/local_word_count_topology.rb} +4 -4
- data/examples/{random_sentence_spout.rb → native/random_sentence_spout.rb} +0 -0
- data/examples/{split_sentence_bolt.rb → native/split_sentence_bolt.rb} +0 -0
- data/examples/{word_count_bolt.rb → native/word_count_bolt.rb} +0 -0
- data/examples/simple/exclamation_bolt.rb +6 -0
- data/examples/simple/exclamation_topology.rb +36 -0
- data/examples/simple/exclamation_topology2.rb +41 -0
- data/examples/simple/random_sentence_spout.rb +18 -0
- data/examples/simple/redis_word_count_topology.rb +54 -0
- data/examples/simple/split_sentence_bolt.rb +29 -0
- data/examples/simple/word_count_bolt.rb +15 -0
- data/examples/simple/word_count_topology.rb +34 -0
- data/lib/red_storm.rb +3 -0
- data/lib/red_storm/application.rb +20 -13
- data/lib/red_storm/simple_bolt.rb +106 -0
- data/lib/red_storm/simple_spout.rb +136 -0
- data/lib/red_storm/simple_topology.rb +191 -0
- data/lib/red_storm/topology_launcher.rb +10 -7
- data/lib/red_storm/version.rb +1 -1
- data/lib/tasks/red_storm.rake +151 -0
- data/pom.xml +1 -1
- metadata +24 -12
@@ -3,11 +3,11 @@ require 'rubygems'
|
|
3
3
|
|
4
4
|
begin
|
5
5
|
# will work from gem, since lib dir is in gem require_paths
|
6
|
-
require 'red_storm
|
6
|
+
require 'red_storm'
|
7
7
|
rescue LoadError
|
8
8
|
# will work within RedStorm dev project
|
9
9
|
$:.unshift './lib'
|
10
|
-
require 'red_storm
|
10
|
+
require 'red_storm'
|
11
11
|
end
|
12
12
|
|
13
13
|
java_import 'backtype.storm.Config'
|
@@ -29,15 +29,18 @@ class TopologyLauncher
|
|
29
29
|
|
30
30
|
java_signature 'void main(String[])'
|
31
31
|
def self.main(args)
|
32
|
-
unless args.size >
|
33
|
-
puts("Usage: redstorm topology_class_file_name")
|
32
|
+
unless args.size > 1
|
33
|
+
puts("Usage: redstorm local|cluster topology_class_file_name")
|
34
34
|
exit(1)
|
35
35
|
end
|
36
|
-
|
36
|
+
env = args[0].to_sym
|
37
|
+
class_path = args[1]
|
37
38
|
clazz = camel_case(class_path.split('/').last.split('.').first)
|
38
|
-
|
39
|
+
|
40
|
+
puts("RedStorm v#{RedStorm::VERSION} starting topology #{clazz} in #{env.to_s} environment")
|
41
|
+
|
39
42
|
require class_path
|
40
|
-
Object.module_eval(clazz).new.start(class_path)
|
43
|
+
Object.module_eval(clazz).new.start(class_path, env)
|
41
44
|
end
|
42
45
|
|
43
46
|
private
|
data/lib/red_storm/version.rb
CHANGED
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'ant'
|
2
|
+
|
3
|
+
begin
|
4
|
+
# will work from gem, since lib dir is in gem require_paths
|
5
|
+
require 'red_storm'
|
6
|
+
rescue LoadError
|
7
|
+
# will work within RedStorm dev project
|
8
|
+
$:.unshift './lib'
|
9
|
+
require 'red_storm'
|
10
|
+
end
|
11
|
+
|
12
|
+
CWD = Dir.pwd
|
13
|
+
TARGET_DIR = "#{CWD}/target"
|
14
|
+
TARGET_SRC_DIR = "#{TARGET_DIR}/src"
|
15
|
+
TARGET_CLASSES_DIR = "#{TARGET_DIR}/classes"
|
16
|
+
TARGET_DEPENDENCY_DIR = "#{TARGET_DIR}/dependency"
|
17
|
+
TARGET_DEPENDENCY_UNPACKED_DIR = "#{TARGET_DIR}/dependency-unpacked"
|
18
|
+
TARGET_CLUSTER_JAR = "#{TARGET_DIR}/cluster-topology.jar"
|
19
|
+
|
20
|
+
JAVA_SRC_DIR = "#{RedStorm::REDSTORM_HOME}/src/main"
|
21
|
+
JRUBY_SRC_DIR = "#{RedStorm::REDSTORM_HOME}/lib"
|
22
|
+
|
23
|
+
SRC_EXAMPLES = "#{RedStorm::REDSTORM_HOME}/examples"
|
24
|
+
DST_EXAMPLES = "#{CWD}/examples"
|
25
|
+
|
26
|
+
task :launch, :env, :class_file do |t, args|
|
27
|
+
gem_home = ENV["GEM_HOME"].to_s.empty? ? " -Djruby.gem.home=`gem env home`" : ""
|
28
|
+
command = "java -cp \"#{TARGET_CLASSES_DIR}:#{TARGET_DEPENDENCY_DIR}/*\"#{gem_home} redstorm.TopologyLauncher #{args[:env]} #{args[:class_file]}"
|
29
|
+
puts("launching #{command}")
|
30
|
+
system(command)
|
31
|
+
end
|
32
|
+
|
33
|
+
task :clean do
|
34
|
+
ant.delete :dir => TARGET_DIR
|
35
|
+
end
|
36
|
+
|
37
|
+
task :clean_jar do
|
38
|
+
ant.delete :file => TARGET_CLUSTER_JAR
|
39
|
+
end
|
40
|
+
|
41
|
+
task :setup do
|
42
|
+
ant.mkdir :dir => TARGET_DIR
|
43
|
+
ant.mkdir :dir => TARGET_CLASSES_DIR
|
44
|
+
ant.mkdir :dir => TARGET_SRC_DIR
|
45
|
+
ant.path :id => 'classpath' do
|
46
|
+
fileset :dir => TARGET_DEPENDENCY_DIR
|
47
|
+
fileset :dir => TARGET_CLASSES_DIR
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
task :install => [:deps, :build] do
|
52
|
+
puts("\nRedStorm install completed. All dependencies installed in #{TARGET_DIR}")
|
53
|
+
end
|
54
|
+
|
55
|
+
task :unpack do
|
56
|
+
system("rmvn dependency:unpack -f #{RedStorm::REDSTORM_HOME}/pom.xml -DoutputDirectory=#{TARGET_DEPENDENCY_UNPACKED_DIR}")
|
57
|
+
end
|
58
|
+
|
59
|
+
task :devjar => [:unpack, :clean_jar] do
|
60
|
+
ant.jar :destfile => TARGET_CLUSTER_JAR do
|
61
|
+
fileset :dir => TARGET_CLASSES_DIR
|
62
|
+
fileset :dir => TARGET_DEPENDENCY_UNPACKED_DIR
|
63
|
+
fileset :dir => RedStorm::REDSTORM_HOME do
|
64
|
+
include :name => "examples/**/*"
|
65
|
+
end
|
66
|
+
fileset :dir => JRUBY_SRC_DIR do
|
67
|
+
exclude :name => "tasks/**"
|
68
|
+
end
|
69
|
+
manifest do
|
70
|
+
attribute :name => "Main-Class", :value => "redstorm.TopologyLauncher"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
puts("\nRedStorm generated dev jar file #{TARGET_CLUSTER_JAR}")
|
74
|
+
end
|
75
|
+
|
76
|
+
task :jar, [:dir] => [:unpack, :clean_jar] do |t, args|
|
77
|
+
ant.jar :destfile => TARGET_CLUSTER_JAR do
|
78
|
+
fileset :dir => TARGET_CLASSES_DIR
|
79
|
+
fileset :dir => TARGET_DEPENDENCY_UNPACKED_DIR
|
80
|
+
fileset :dir => RedStorm::REDSTORM_HOME do
|
81
|
+
include :name => "examples/**/*"
|
82
|
+
end
|
83
|
+
fileset :dir => JRUBY_SRC_DIR do
|
84
|
+
exclude :name => "tasks/**"
|
85
|
+
end
|
86
|
+
fileset :dir => CWD do
|
87
|
+
include :name => "#{args[:dir]}/**/*"
|
88
|
+
end
|
89
|
+
manifest do
|
90
|
+
attribute :name => "Main-Class", :value => "redstorm.TopologyLauncher"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
puts("\nRedStorm generated jar file #{TARGET_CLUSTER_JAR}")
|
94
|
+
end
|
95
|
+
|
96
|
+
task :examples do
|
97
|
+
if File.identical?(SRC_EXAMPLES, DST_EXAMPLES)
|
98
|
+
STDERR.puts("error: cannot copy examples into itself")
|
99
|
+
exit(1)
|
100
|
+
end
|
101
|
+
if File.exist?(DST_EXAMPLES)
|
102
|
+
STDERR.puts("error: directory #{DST_EXAMPLES} already exists")
|
103
|
+
exit(1)
|
104
|
+
end
|
105
|
+
|
106
|
+
puts("copying examples into #{DST_EXAMPLES}")
|
107
|
+
system("mkdir #{DST_EXAMPLES}")
|
108
|
+
system("cp -r #{SRC_EXAMPLES}/* #{DST_EXAMPLES}")
|
109
|
+
puts("\nRedStorm examples completed. All examples copied in #{DST_EXAMPLES}")
|
110
|
+
end
|
111
|
+
|
112
|
+
task :deps do
|
113
|
+
system("rmvn dependency:copy-dependencies -f #{RedStorm::REDSTORM_HOME}/pom.xml -DoutputDirectory=#{TARGET_DEPENDENCY_DIR}")
|
114
|
+
end
|
115
|
+
|
116
|
+
task :build => :setup do
|
117
|
+
# compile the JRuby proxy classes to Java
|
118
|
+
build_jruby("#{JRUBY_SRC_DIR}/red_storm/proxy")
|
119
|
+
|
120
|
+
# compile the generated Java proxy classes
|
121
|
+
build_java_dir("#{TARGET_SRC_DIR}")
|
122
|
+
|
123
|
+
# generate the JRuby topology launcher
|
124
|
+
build_jruby("#{JRUBY_SRC_DIR}/red_storm/topology_launcher.rb")
|
125
|
+
|
126
|
+
# compile the JRuby proxy classes
|
127
|
+
build_java_dir("#{JAVA_SRC_DIR}")
|
128
|
+
|
129
|
+
# compile the JRuby proxy classes
|
130
|
+
build_java_dir("#{TARGET_SRC_DIR}")
|
131
|
+
end
|
132
|
+
|
133
|
+
def build_java_dir(source_folder)
|
134
|
+
puts("\n--> Compiling Java")
|
135
|
+
ant.javac(
|
136
|
+
:srcdir => source_folder,
|
137
|
+
:destdir => TARGET_CLASSES_DIR,
|
138
|
+
:classpathref => 'classpath',
|
139
|
+
:source => "1.6",
|
140
|
+
:target => "1.6",
|
141
|
+
:debug => "yes",
|
142
|
+
:includeantruntime => "no",
|
143
|
+
:verbose => false,
|
144
|
+
:listfiles => true
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
def build_jruby(source_path)
|
149
|
+
puts("\n--> Compiling JRuby")
|
150
|
+
system("cd #{RedStorm::REDSTORM_HOME}; jrubyc -t #{TARGET_SRC_DIR} --verbose --java -c \"#{TARGET_DEPENDENCY_DIR}/storm-0.5.3.jar\" -c \"#{TARGET_CLASSES_DIR}\" #{source_path}")
|
151
|
+
end
|
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
|
+
version: 0.2.0
|
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: 2011-11-
|
13
|
+
date: 2011-11-17 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubyforge
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
version: 3.0.3.0.28.5
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id003
|
48
|
-
description: JRuby integration for the Storm distributed realtime computation system
|
48
|
+
description: JRuby integration & DSL for the Storm distributed realtime computation system
|
49
49
|
email:
|
50
50
|
- colin.surprenant@gmail.com
|
51
51
|
executables:
|
@@ -57,19 +57,31 @@ extra_rdoc_files: []
|
|
57
57
|
files:
|
58
58
|
- lib/red_storm.rb
|
59
59
|
- lib/red_storm/application.rb
|
60
|
+
- lib/red_storm/simple_bolt.rb
|
61
|
+
- lib/red_storm/simple_spout.rb
|
62
|
+
- lib/red_storm/simple_topology.rb
|
60
63
|
- lib/red_storm/topology_launcher.rb
|
61
64
|
- lib/red_storm/version.rb
|
62
65
|
- lib/red_storm/proxy/bolt.rb
|
63
66
|
- lib/red_storm/proxy/spout.rb
|
64
|
-
-
|
65
|
-
- examples/
|
66
|
-
- examples/
|
67
|
-
- examples/
|
68
|
-
- examples/
|
69
|
-
- examples/
|
70
|
-
- examples/
|
71
|
-
- examples/
|
72
|
-
- examples/
|
67
|
+
- lib/tasks/red_storm.rake
|
68
|
+
- examples/native/cluster_word_count_topology.rb
|
69
|
+
- examples/native/exclamation_bolt.rb
|
70
|
+
- examples/native/local_exclamation_topology.rb
|
71
|
+
- examples/native/local_exclamation_topology2.rb
|
72
|
+
- examples/native/local_redis_word_count_topology.rb
|
73
|
+
- examples/native/local_word_count_topology.rb
|
74
|
+
- examples/native/random_sentence_spout.rb
|
75
|
+
- examples/native/split_sentence_bolt.rb
|
76
|
+
- examples/native/word_count_bolt.rb
|
77
|
+
- examples/simple/exclamation_bolt.rb
|
78
|
+
- examples/simple/exclamation_topology.rb
|
79
|
+
- examples/simple/exclamation_topology2.rb
|
80
|
+
- examples/simple/random_sentence_spout.rb
|
81
|
+
- examples/simple/redis_word_count_topology.rb
|
82
|
+
- examples/simple/split_sentence_bolt.rb
|
83
|
+
- examples/simple/word_count_bolt.rb
|
84
|
+
- examples/simple/word_count_topology.rb
|
73
85
|
- src/main/redstorm/storm/jruby/JRubyBolt.java
|
74
86
|
- src/main/redstorm/storm/jruby/JRubySpout.java
|
75
87
|
- bin/redstorm
|