kb-redstorm 0.6.4

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.
Files changed (53) hide show
  1. data/CHANGELOG.md +74 -0
  2. data/LICENSE.md +13 -0
  3. data/README.md +375 -0
  4. data/Rakefile +11 -0
  5. data/bin/redstorm +15 -0
  6. data/examples/native/Gemfile +2 -0
  7. data/examples/native/cluster_word_count_topology.rb +25 -0
  8. data/examples/native/exclamation_bolt.rb +21 -0
  9. data/examples/native/local_exclamation_topology.rb +31 -0
  10. data/examples/native/local_exclamation_topology2.rb +48 -0
  11. data/examples/native/local_redis_word_count_topology.rb +69 -0
  12. data/examples/native/local_word_count_topology.rb +27 -0
  13. data/examples/native/random_sentence_spout.rb +30 -0
  14. data/examples/native/split_sentence_bolt.rb +20 -0
  15. data/examples/native/word_count_bolt.rb +26 -0
  16. data/examples/shell/resources/splitsentence.py +9 -0
  17. data/examples/shell/resources/storm.py +206 -0
  18. data/examples/shell/shell_topology.rb +41 -0
  19. data/examples/simple/exclamation_bolt.rb +10 -0
  20. data/examples/simple/exclamation_topology.rb +45 -0
  21. data/examples/simple/exclamation_topology2.rb +45 -0
  22. data/examples/simple/kafka_topology.rb +55 -0
  23. data/examples/simple/random_sentence_spout.rb +21 -0
  24. data/examples/simple/redis_word_count_topology.rb +61 -0
  25. data/examples/simple/ruby_version_topology.rb +32 -0
  26. data/examples/simple/split_sentence_bolt.rb +33 -0
  27. data/examples/simple/word_count_bolt.rb +19 -0
  28. data/examples/simple/word_count_topology.rb +38 -0
  29. data/ivy/settings.xml +11 -0
  30. data/lib/red_storm.rb +9 -0
  31. data/lib/red_storm/application.rb +85 -0
  32. data/lib/red_storm/configuration.rb +16 -0
  33. data/lib/red_storm/configurator.rb +26 -0
  34. data/lib/red_storm/environment.rb +41 -0
  35. data/lib/red_storm/loggable.rb +15 -0
  36. data/lib/red_storm/proxy/batch_spout.rb +71 -0
  37. data/lib/red_storm/proxy/bolt.rb +63 -0
  38. data/lib/red_storm/proxy/proxy_function.rb +48 -0
  39. data/lib/red_storm/proxy/spout.rb +87 -0
  40. data/lib/red_storm/simple_bolt.rb +135 -0
  41. data/lib/red_storm/simple_drpc_topology.rb +87 -0
  42. data/lib/red_storm/simple_spout.rb +184 -0
  43. data/lib/red_storm/simple_topology.rb +209 -0
  44. data/lib/red_storm/topology_launcher.rb +54 -0
  45. data/lib/red_storm/version.rb +3 -0
  46. data/lib/tasks/red_storm.rake +272 -0
  47. data/src/main/redstorm/storm/jruby/JRubyBatchSpout.java +89 -0
  48. data/src/main/redstorm/storm/jruby/JRubyBolt.java +88 -0
  49. data/src/main/redstorm/storm/jruby/JRubyProxyFunction.java +59 -0
  50. data/src/main/redstorm/storm/jruby/JRubyShellBolt.java +26 -0
  51. data/src/main/redstorm/storm/jruby/JRubyShellSpout.java +26 -0
  52. data/src/main/redstorm/storm/jruby/JRubySpout.java +107 -0
  53. metadata +134 -0
@@ -0,0 +1,59 @@
1
+ package redstorm.storm.jruby;
2
+
3
+ import storm.trident.tuple.TridentTuple;
4
+ import storm.trident.operation.TridentCollector;
5
+ import java.util.Map;
6
+ import storm.trident.operation.TridentOperationContext;
7
+ import storm.trident.operation.Function;
8
+
9
+ public class JRubyProxyFunction implements Function {
10
+ Function _proxy;
11
+ String _realClassName;
12
+ String _baseClassPath;
13
+ String[] _fields;
14
+
15
+ public JRubyProxyFunction(final String baseClassPath, final String realClassName, final String[] fields) {
16
+ _baseClassPath = baseClassPath;
17
+ _realClassName = realClassName;
18
+ _fields = fields;
19
+ }
20
+
21
+
22
+ @Override
23
+ public void execute(final TridentTuple _tridentTuple, final TridentCollector _tridentCollector) {
24
+
25
+ if(_proxy == null) {
26
+ _proxy = newProxy(_baseClassPath, _realClassName);
27
+ }
28
+ _proxy.execute(_tridentTuple, _tridentCollector);
29
+
30
+ }
31
+
32
+ @Override
33
+ public void cleanup() {
34
+
35
+ _proxy.cleanup();
36
+
37
+ }
38
+
39
+ @Override
40
+ public void prepare(final Map _map, final TridentOperationContext _tridentOperationContext) {
41
+
42
+ if(_proxy == null) {
43
+ _proxy = newProxy(_baseClassPath, _realClassName);
44
+ }
45
+ _proxy.prepare(_map, _tridentOperationContext);
46
+
47
+ }
48
+
49
+
50
+ private static Function newProxy(final String baseClassPath, final String realClassName) {
51
+ try {
52
+ redstorm.proxy.ProxyFunction proxy = new redstorm.proxy.ProxyFunction(baseClassPath, realClassName);
53
+ return proxy;
54
+ }
55
+ catch (Exception e) {
56
+ throw new RuntimeException(e);
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,26 @@
1
+ package redstorm.storm.jruby;
2
+
3
+ import backtype.storm.task.ShellBolt;
4
+ import backtype.storm.topology.IRichBolt;
5
+ import backtype.storm.topology.OutputFieldsDeclarer;
6
+ import backtype.storm.tuple.Fields;
7
+ import java.util.Map;
8
+
9
+ public class JRubyShellBolt extends ShellBolt implements IRichBolt {
10
+ private String[] _fields;
11
+
12
+ public JRubyShellBolt(String[] command, String[] fields) {
13
+ super(command);
14
+ _fields = fields;
15
+ }
16
+
17
+ @Override
18
+ public void declareOutputFields(OutputFieldsDeclarer declarer) {
19
+ declarer.declare(new Fields(_fields));
20
+ }
21
+
22
+ @Override
23
+ public Map<String, Object> getComponentConfiguration() {
24
+ return null;
25
+ }
26
+ }
@@ -0,0 +1,26 @@
1
+ package redstorm.storm.jruby;
2
+
3
+ import backtype.storm.spout.ShellSpout;
4
+ import backtype.storm.topology.IRichSpout;
5
+ import backtype.storm.topology.OutputFieldsDeclarer;
6
+ import backtype.storm.tuple.Fields;
7
+ import java.util.Map;
8
+
9
+ public class JRubyShellSpout extends ShellSpout implements IRichSpout {
10
+ private String[] _fields;
11
+
12
+ public JRubyShellSpout(String[] command, String[] fields) {
13
+ super(command);
14
+ _fields = fields;
15
+ }
16
+
17
+ @Override
18
+ public void declareOutputFields(OutputFieldsDeclarer declarer) {
19
+ declarer.declare(new Fields(_fields));
20
+ }
21
+
22
+ @Override
23
+ public Map<String, Object> getComponentConfiguration() {
24
+ return null;
25
+ }
26
+ }
@@ -0,0 +1,107 @@
1
+ package redstorm.storm.jruby;
2
+
3
+ import backtype.storm.spout.SpoutOutputCollector;
4
+ import backtype.storm.task.TopologyContext;
5
+ import backtype.storm.topology.IRichSpout;
6
+ import backtype.storm.topology.OutputFieldsDeclarer;
7
+ import backtype.storm.tuple.Tuple;
8
+ import backtype.storm.tuple.Fields;
9
+ import java.util.Map;
10
+
11
+ /**
12
+ * the JRubySpout class is a simple proxy class to the actual spout implementation in JRuby.
13
+ * this proxy is required to bypass the serialization/deserialization process when dispatching
14
+ * the spout to the workers. JRuby does not yet support serialization from Java
15
+ * (Java serialization call on a JRuby class).
16
+ *
17
+ * Note that the JRuby spout proxy class is instanciated in the open method which is called after
18
+ * deserialization at the worker and in both the declareOutputFields and isDistributed methods which
19
+ * are called once before serialization at topology creation.
20
+ */
21
+ public class JRubySpout implements IRichSpout {
22
+ IRichSpout _proxySpout;
23
+ String _realSpoutClassName;
24
+ String _baseClassPath;
25
+ String[] _fields;
26
+
27
+ /**
28
+ * create a new JRubySpout
29
+ *
30
+ * @param baseClassPath the topology/project base JRuby class file path
31
+ * @param realSpoutClassName the fully qualified JRuby spout implementation class name
32
+ */
33
+ public JRubySpout(String baseClassPath, String realSpoutClassName, String[] fields) {
34
+ _baseClassPath = baseClassPath;
35
+ _realSpoutClassName = realSpoutClassName;
36
+ _fields = fields;
37
+ }
38
+
39
+ @Override
40
+ public void open(final Map conf, final TopologyContext context, final SpoutOutputCollector collector) {
41
+ // create instance of the jruby proxy class here, after deserialization in the workers.
42
+ _proxySpout = newProxySpout(_baseClassPath, _realSpoutClassName);
43
+ _proxySpout.open(conf, context, collector);
44
+ }
45
+
46
+ @Override
47
+ public void close() {
48
+ _proxySpout.close();
49
+ }
50
+
51
+ @Override
52
+ public void activate() {
53
+ _proxySpout.activate();
54
+ }
55
+
56
+ @Override
57
+ public void deactivate() {
58
+ _proxySpout.deactivate();
59
+ }
60
+
61
+ @Override
62
+ public void nextTuple() {
63
+ _proxySpout.nextTuple();
64
+ }
65
+
66
+ @Override
67
+ public void ack(Object msgId) {
68
+ _proxySpout.ack(msgId);
69
+ }
70
+
71
+ @Override
72
+ public void fail(Object msgId) {
73
+ _proxySpout.fail(msgId);
74
+ }
75
+
76
+ @Override
77
+ public void declareOutputFields(OutputFieldsDeclarer declarer) {
78
+ // declareOutputFields is executed in the topology creation time before serialisation.
79
+ // do not set the _proxySpout instance variable here to avoid JRuby serialization
80
+ // issues. Just create tmp spout instance to call declareOutputFields.
81
+ if (_fields.length > 0) {
82
+ declarer.declare(new Fields(_fields));
83
+ } else {
84
+ IRichSpout spout = newProxySpout(_baseClassPath, _realSpoutClassName);
85
+ spout.declareOutputFields(declarer);
86
+ }
87
+ }
88
+
89
+ @Override
90
+ public Map<String, Object> getComponentConfiguration() {
91
+ // getComponentConfiguration is executed in the topology creation time before serialisation.
92
+ // do not set the _proxySpout instance variable here to avoid JRuby serialization
93
+ // issues. Just create tmp spout instance to call declareOutputFields.
94
+ IRichSpout spout = newProxySpout(_baseClassPath, _realSpoutClassName);
95
+ return spout.getComponentConfiguration();
96
+ }
97
+
98
+ private static IRichSpout newProxySpout(String baseClassPath, String realSpoutClassName) {
99
+ try {
100
+ redstorm.proxy.Spout proxy = new redstorm.proxy.Spout(baseClassPath, realSpoutClassName);
101
+ return proxy;
102
+ }
103
+ catch (Exception e) {
104
+ throw new RuntimeException(e);
105
+ }
106
+ }
107
+ }
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kb-redstorm
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.6.4
6
+ platform: ruby
7
+ authors:
8
+ - Colin Surprenant
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 2.11.0
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.11.0
27
+ none: false
28
+ prerelease: false
29
+ type: :development
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: !binary |-
37
+ MA==
38
+ none: false
39
+ requirement: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: !binary |-
44
+ MA==
45
+ none: false
46
+ prerelease: false
47
+ type: :runtime
48
+ description: JRuby integration & DSL for the Storm distributed realtime computation system
49
+ email:
50
+ - colin.surprenant@gmail.com
51
+ executables:
52
+ - redstorm
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - lib/red_storm.rb
57
+ - lib/red_storm/application.rb
58
+ - lib/red_storm/configuration.rb
59
+ - lib/red_storm/configurator.rb
60
+ - lib/red_storm/environment.rb
61
+ - lib/red_storm/loggable.rb
62
+ - lib/red_storm/simple_bolt.rb
63
+ - lib/red_storm/simple_drpc_topology.rb
64
+ - lib/red_storm/simple_spout.rb
65
+ - lib/red_storm/simple_topology.rb
66
+ - lib/red_storm/topology_launcher.rb
67
+ - lib/red_storm/version.rb
68
+ - lib/red_storm/proxy/batch_spout.rb
69
+ - lib/red_storm/proxy/bolt.rb
70
+ - lib/red_storm/proxy/proxy_function.rb
71
+ - lib/red_storm/proxy/spout.rb
72
+ - lib/tasks/red_storm.rake
73
+ - ivy/settings.xml
74
+ - examples/native/cluster_word_count_topology.rb
75
+ - examples/native/exclamation_bolt.rb
76
+ - examples/native/Gemfile
77
+ - examples/native/local_exclamation_topology.rb
78
+ - examples/native/local_exclamation_topology2.rb
79
+ - examples/native/local_redis_word_count_topology.rb
80
+ - examples/native/local_word_count_topology.rb
81
+ - examples/native/random_sentence_spout.rb
82
+ - examples/native/split_sentence_bolt.rb
83
+ - examples/native/word_count_bolt.rb
84
+ - examples/shell/shell_topology.rb
85
+ - examples/shell/resources/splitsentence.py
86
+ - examples/shell/resources/storm.py
87
+ - examples/simple/exclamation_bolt.rb
88
+ - examples/simple/exclamation_topology.rb
89
+ - examples/simple/exclamation_topology2.rb
90
+ - examples/simple/kafka_topology.rb
91
+ - examples/simple/random_sentence_spout.rb
92
+ - examples/simple/redis_word_count_topology.rb
93
+ - examples/simple/ruby_version_topology.rb
94
+ - examples/simple/split_sentence_bolt.rb
95
+ - examples/simple/word_count_bolt.rb
96
+ - examples/simple/word_count_topology.rb
97
+ - src/main/redstorm/storm/jruby/JRubyBatchSpout.java
98
+ - src/main/redstorm/storm/jruby/JRubyBolt.java
99
+ - src/main/redstorm/storm/jruby/JRubyProxyFunction.java
100
+ - src/main/redstorm/storm/jruby/JRubyShellBolt.java
101
+ - src/main/redstorm/storm/jruby/JRubyShellSpout.java
102
+ - src/main/redstorm/storm/jruby/JRubySpout.java
103
+ - bin/redstorm
104
+ - Rakefile
105
+ - README.md
106
+ - CHANGELOG.md
107
+ - LICENSE.md
108
+ homepage: https://github.com/colinsurprenant/redstorm
109
+ licenses: []
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: !binary |-
119
+ MA==
120
+ none: false
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: !binary |-
126
+ MA==
127
+ none: false
128
+ requirements: []
129
+ rubyforge_project: redstorm
130
+ rubygems_version: 1.8.24
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: JRuby on Storm
134
+ test_files: []