kb-redstorm 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -0
- data/README.md +206 -103
- data/examples/native/cluster_word_count_topology.rb +5 -5
- data/examples/native/local_exclamation_topology.rb +8 -8
- data/examples/native/local_exclamation_topology2.rb +7 -7
- data/examples/native/local_redis_word_count_topology.rb +7 -8
- data/examples/native/local_word_count_topology.rb +5 -5
- data/examples/simple/exclamation_topology.rb +7 -11
- data/examples/simple/exclamation_topology2.rb +10 -12
- data/examples/simple/hello_world_topology.rb +22 -0
- data/examples/simple/kafka_topology.rb +15 -15
- data/examples/simple/redis_word_count_topology.rb +3 -5
- data/examples/simple/ruby_version_topology.rb +7 -1
- data/examples/simple/word_count_topology.rb +8 -10
- data/ivy/settings.xml +1 -0
- data/ivy/storm_dependencies.xml +8 -0
- data/ivy/topology_dependencies.xml +7 -0
- data/lib/red_storm/application.rb +7 -5
- data/lib/red_storm/configurator.rb +1 -1
- data/lib/red_storm/proxy/batch_bolt.rb +63 -0
- data/lib/red_storm/proxy/batch_committer_bolt.rb +52 -0
- data/lib/red_storm/proxy/batch_spout.rb +12 -24
- data/lib/red_storm/proxy/proxy_function.rb +1 -9
- data/lib/red_storm/proxy/transactional_committer_spout.rb +47 -0
- data/lib/red_storm/proxy/transactional_spout.rb +46 -0
- data/lib/red_storm/simple_drpc_topology.rb +2 -2
- data/lib/red_storm/simple_topology.rb +14 -4
- data/lib/red_storm/topology_launcher.rb +16 -0
- data/lib/red_storm/version.rb +1 -1
- data/lib/tasks/red_storm.rake +69 -108
- data/redstorm.gemspec +24 -0
- data/src/main/redstorm/storm/jruby/JRubyBatchBolt.java +90 -0
- data/src/main/redstorm/storm/jruby/JRubyBatchCommitterBolt.java +9 -0
- data/src/main/redstorm/storm/jruby/JRubyBatchSpout.java +25 -26
- data/src/main/redstorm/storm/jruby/JRubyProxyFunction.java +1 -9
- data/src/main/redstorm/storm/jruby/JRubyTransactionalBolt.java +90 -0
- data/src/main/redstorm/storm/jruby/JRubyTransactionalCommitterBolt.java +31 -0
- data/src/main/redstorm/storm/jruby/JRubyTransactionalCommitterSpout.java +44 -0
- data/src/main/redstorm/storm/jruby/JRubyTransactionalSpout.java +89 -0
- metadata +80 -62
- data/examples/native/Gemfile +0 -2
@@ -1,36 +1,32 @@
|
|
1
1
|
java_import 'backtype.storm.testing.TestWordSpout'
|
2
2
|
|
3
|
+
require 'red_storm'
|
3
4
|
require 'examples/simple/exclamation_bolt'
|
4
5
|
|
5
6
|
# this example topology uses the Storm TestWordSpout and our own JRuby ExclamationBolt
|
6
7
|
|
7
8
|
module RedStorm
|
8
9
|
module Examples
|
9
|
-
class ExclamationTopology <
|
10
|
-
spout TestWordSpout, :parallelism =>
|
10
|
+
class ExclamationTopology < SimpleTopology
|
11
|
+
spout TestWordSpout, :parallelism => 2 do
|
11
12
|
debug true
|
12
13
|
end
|
13
14
|
|
14
15
|
bolt ExclamationBolt, :parallelism => 2 do
|
15
16
|
source TestWordSpout, :shuffle
|
16
|
-
# max_task_parallelism 1
|
17
17
|
end
|
18
18
|
|
19
19
|
bolt ExclamationBolt, :id => :ExclamationBolt2, :parallelism => 2 do
|
20
20
|
source ExclamationBolt, :shuffle
|
21
|
-
# max_task_parallelism 1
|
22
21
|
debug true
|
23
22
|
end
|
24
23
|
|
25
24
|
configure do |env|
|
26
25
|
debug false
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
when :cluster
|
32
|
-
num_workers 20
|
33
|
-
max_spout_pending(1000);
|
26
|
+
max_task_parallelism 4
|
27
|
+
if env == :cluster
|
28
|
+
num_workers 4
|
29
|
+
max_spout_pending(1000)
|
34
30
|
end
|
35
31
|
end
|
36
32
|
|
@@ -1,9 +1,10 @@
|
|
1
|
-
java_import 'backtype.storm.testing.TestWordSpout'
|
2
|
-
require 'red_storm'
|
3
|
-
|
4
1
|
# this example topology uses the Storm TestWordSpout and our own JRuby ExclamationBolt
|
5
2
|
# and a locally defined ExclamationBolt
|
6
3
|
|
4
|
+
java_import 'backtype.storm.testing.TestWordSpout'
|
5
|
+
|
6
|
+
require 'red_storm'
|
7
|
+
|
7
8
|
module RedStorm
|
8
9
|
module Examples
|
9
10
|
class ExclamationBolt < RedStorm::SimpleBolt
|
@@ -12,9 +13,9 @@ module RedStorm
|
|
12
13
|
end
|
13
14
|
|
14
15
|
class ExclamationTopology2 < RedStorm::SimpleTopology
|
15
|
-
spout TestWordSpout, :parallelism =>
|
16
|
+
spout TestWordSpout, :parallelism => 2
|
16
17
|
|
17
|
-
bolt ExclamationBolt, :parallelism =>
|
18
|
+
bolt ExclamationBolt, :parallelism => 2 do
|
18
19
|
source TestWordSpout, :shuffle
|
19
20
|
end
|
20
21
|
|
@@ -24,13 +25,10 @@ module RedStorm
|
|
24
25
|
|
25
26
|
configure do |env|
|
26
27
|
debug true
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
when :cluster
|
32
|
-
num_workers 20
|
33
|
-
max_spout_pending(1000);
|
28
|
+
max_task_parallelism 4
|
29
|
+
if env == :cluster
|
30
|
+
num_workers 4
|
31
|
+
max_spout_pending(1000)
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'red_storm'
|
2
|
+
|
3
|
+
class HelloWorldSpout < RedStorm::SimpleSpout
|
4
|
+
on_init {@words = ["hello", "world"]}
|
5
|
+
on_send {@words.shift unless @words.empty?}
|
6
|
+
end
|
7
|
+
|
8
|
+
class HelloWorldBolt < RedStorm::SimpleBolt
|
9
|
+
on_receive :emit => false do |tuple|
|
10
|
+
log.info(tuple.getString(0))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class HelloWorldTopology < RedStorm::SimpleTopology
|
15
|
+
spout HelloWorldSpout do
|
16
|
+
output_fields :word
|
17
|
+
end
|
18
|
+
|
19
|
+
bolt HelloWorldBolt do
|
20
|
+
source HelloWorldSpout, :global
|
21
|
+
end
|
22
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
require 'red_storm'
|
2
1
|
java_import 'storm.kafka.KafkaConfig'
|
3
2
|
java_import 'storm.kafka.SpoutConfig'
|
4
3
|
java_import 'storm.kafka.StringScheme'
|
5
4
|
java_import 'storm.kafka.KafkaSpout'
|
6
5
|
|
6
|
+
require 'red_storm'
|
7
|
+
|
7
8
|
# the KafkaTopology obviously requires a Kafka server running, you can ajust the
|
8
|
-
# host and port below.
|
9
|
+
# host and port below.
|
9
10
|
#
|
10
11
|
# custom dependencies are required for the Kafka and Scala jars. put the following
|
11
|
-
# dependencies in the "
|
12
|
+
# dependencies in the "ivy/topology_dependencies.xml" file in the root of your RedStorm project:
|
12
13
|
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
# "org.
|
19
|
-
# "
|
20
|
-
# "storm
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# }
|
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.3" 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
24
|
|
25
25
|
class KafkaTopology < RedStorm::SimpleTopology
|
26
26
|
spout_config = SpoutConfig.new(
|
@@ -36,7 +36,7 @@ class KafkaTopology < RedStorm::SimpleTopology
|
|
36
36
|
end
|
37
37
|
|
38
38
|
spout KafkaSpout, [spout_config]
|
39
|
-
|
39
|
+
|
40
40
|
bolt SplitStringBolt do
|
41
41
|
output_fields :word
|
42
42
|
source KafkaSpout, :shuffle
|
@@ -1,9 +1,7 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'red_storm'
|
3
|
-
|
2
|
+
require 'examples/simple/word_count_bolt'
|
4
3
|
require 'redis'
|
5
4
|
require 'thread'
|
6
|
-
require 'examples/simple/word_count_bolt'
|
7
5
|
|
8
6
|
module RedStorm
|
9
7
|
module Examples
|
@@ -46,14 +44,14 @@ module RedStorm
|
|
46
44
|
|
47
45
|
configure do |env|
|
48
46
|
debug true
|
49
|
-
set "topology.worker.childopts", "-Djruby.compat.version=RUBY1_9"
|
47
|
+
# set "topology.worker.childopts", "-Djruby.compat.version=RUBY1_9"
|
50
48
|
case env
|
51
49
|
when :local
|
52
50
|
max_task_parallelism 3
|
53
51
|
when :cluster
|
54
52
|
max_task_parallelism 5
|
55
53
|
num_workers 20
|
56
|
-
max_spout_pending(1000)
|
54
|
+
max_spout_pending(1000)
|
57
55
|
end
|
58
56
|
end
|
59
57
|
end
|
@@ -6,7 +6,13 @@ module RedStorm
|
|
6
6
|
module Examples
|
7
7
|
class VersionSpout < RedStorm::SimpleSpout
|
8
8
|
output_fields :dummy
|
9
|
-
on_init
|
9
|
+
on_init do
|
10
|
+
log.info("***************** RUBY_VERSION=#{RUBY_VERSION}")
|
11
|
+
log.info("***************** JRUBY_VERSION=#{JRUBY_VERSION}")
|
12
|
+
log.info("***************** VERSION=#{VERSION}")
|
13
|
+
log.info("***************** RUBY_ENGINE=#{RUBY_ENGINE}")
|
14
|
+
log.info("***************** RUBY_PLATFORM=#{RUBY_PLATFORM}")
|
15
|
+
end
|
10
16
|
on_send {}
|
11
17
|
end
|
12
18
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'red_storm'
|
1
2
|
require 'examples/simple/random_sentence_spout'
|
2
3
|
require 'examples/simple/split_sentence_bolt'
|
3
4
|
require 'examples/simple/word_count_bolt'
|
@@ -5,25 +6,22 @@ require 'examples/simple/word_count_bolt'
|
|
5
6
|
module RedStorm
|
6
7
|
module Examples
|
7
8
|
class WordCountTopology < SimpleTopology
|
8
|
-
spout RandomSentenceSpout, :parallelism =>
|
9
|
+
spout RandomSentenceSpout, :parallelism => 2
|
9
10
|
|
10
|
-
bolt SplitSentenceBolt, :parallelism =>
|
11
|
+
bolt SplitSentenceBolt, :parallelism => 2 do
|
11
12
|
source RandomSentenceSpout, :shuffle
|
12
13
|
end
|
13
14
|
|
14
|
-
bolt WordCountBolt, :parallelism =>
|
15
|
+
bolt WordCountBolt, :parallelism => 2 do
|
15
16
|
source SplitSentenceBolt, :fields => ["word"]
|
16
17
|
end
|
17
18
|
|
18
19
|
configure :word_count do |env|
|
19
20
|
debug true
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
when :cluster
|
25
|
-
num_workers 20
|
26
|
-
max_spout_pending(1000);
|
21
|
+
max_task_parallelism 4
|
22
|
+
if env == :cluster
|
23
|
+
num_workers 6
|
24
|
+
max_spout_pending(1000)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
data/ivy/settings.xml
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<ivy-module version="2.0">
|
3
|
+
<info organisation="redstorm" module="storm-deps"/>
|
4
|
+
<dependencies>
|
5
|
+
<dependency org="storm" name="storm" rev="0.8.2" conf="default" transitive="true" />
|
6
|
+
<override org="org.slf4j" module="slf4j-log4j12" rev="1.6.3"/>
|
7
|
+
</dependencies>
|
8
|
+
</ivy-module>
|
@@ -20,15 +20,17 @@ DST_EXAMPLES = "#{CWD}/examples"
|
|
20
20
|
|
21
21
|
SRC_IVY_DIR = "#{RedStorm::REDSTORM_HOME}/ivy"
|
22
22
|
DST_IVY_DIR = "#{CWD}/ivy"
|
23
|
-
CUSTOM_DEPENDENCIES = "#{CWD}/Dependencies"
|
24
23
|
DEFAULT_IVY_SETTINGS = "#{SRC_IVY_DIR}/settings.xml"
|
25
24
|
CUSTOM_IVY_SETTINGS = "#{DST_IVY_DIR}/settings.xml"
|
26
|
-
|
25
|
+
DEFAULT_IVY_STORM_DEPENDENCIES = "#{SRC_IVY_DIR}/storm_dependencies.xml"
|
26
|
+
CUSTOM_IVY_STORM_DEPENDENCIES = "#{DST_IVY_DIR}/storm_dependencies.xml"
|
27
|
+
DEFAULT_IVY_TOPOLOGY_DEPENDENCIES = "#{SRC_IVY_DIR}/topology_dependencies.xml"
|
28
|
+
CUSTOM_IVY_TOPOLOGY_DEPENDENCIES = "#{DST_IVY_DIR}/topology_dependencies.xml"
|
27
29
|
|
28
30
|
module RedStorm
|
29
31
|
|
30
|
-
class Application
|
31
|
-
TASKS_FILE = "#{RedStorm::REDSTORM_HOME}/lib/tasks/red_storm.rake"
|
32
|
+
class Application
|
33
|
+
TASKS_FILE = "#{RedStorm::REDSTORM_HOME}/lib/tasks/red_storm.rake"
|
32
34
|
|
33
35
|
def self.local_storm_command(class_file, ruby_mode = nil)
|
34
36
|
src_dir = File.expand_path(File.dirname(class_file))
|
@@ -76,7 +78,7 @@ module RedStorm
|
|
76
78
|
end
|
77
79
|
|
78
80
|
def self.subshell(command)
|
79
|
-
out = IO.popen(command,
|
81
|
+
out = IO.popen(command, STDERR => STDOUT) {|io| io.read}
|
80
82
|
[!!$?.success?, out]
|
81
83
|
end
|
82
84
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
java_import 'backtype.storm.coordination.BatchOutputCollector'
|
4
|
+
java_import 'backtype.storm.task.TopologyContext'
|
5
|
+
java_import 'backtype.storm.topology.IRichBolt'
|
6
|
+
java_import 'backtype.storm.coordination.IBatchBolt'
|
7
|
+
java_import 'backtype.storm.topology.OutputFieldsDeclarer'
|
8
|
+
java_import 'backtype.storm.tuple.Tuple'
|
9
|
+
java_import 'java.util.Map'
|
10
|
+
|
11
|
+
module Backtype
|
12
|
+
java_import 'backtype.storm.Config'
|
13
|
+
end
|
14
|
+
|
15
|
+
java_package 'redstorm.proxy'
|
16
|
+
|
17
|
+
# the Bolt class is a proxy to the real bolt to avoid having to deal with all the
|
18
|
+
# Java artifacts when creating a bolt.
|
19
|
+
#
|
20
|
+
# The real bolt class implementation must define these methods:
|
21
|
+
# - prepare(conf, context, collector)
|
22
|
+
# - execute(tuple)
|
23
|
+
# - declare_output_fields
|
24
|
+
#
|
25
|
+
# and optionnaly:
|
26
|
+
# - cleanup
|
27
|
+
#
|
28
|
+
class BatchBolt
|
29
|
+
java_implements IBatchBolt
|
30
|
+
|
31
|
+
java_signature 'IBatchBolt (String base_class_path, String real_bolt_class_name)'
|
32
|
+
def initialize(base_class_path, real_bolt_class_name)
|
33
|
+
@real_bolt = Object.module_eval(real_bolt_class_name).new
|
34
|
+
rescue NameError
|
35
|
+
require base_class_path
|
36
|
+
@real_bolt = Object.module_eval(real_bolt_class_name).new
|
37
|
+
end
|
38
|
+
|
39
|
+
java_signature 'void prepare(Map, TopologyContext, BatchOutputCollector, Object)'
|
40
|
+
def prepare(conf, context, collector, id)
|
41
|
+
@real_bolt.prepare(conf, context, collector, id)
|
42
|
+
end
|
43
|
+
|
44
|
+
java_signature 'void execute(Tuple)'
|
45
|
+
def execute(tuple)
|
46
|
+
@real_bolt.execute(tuple)
|
47
|
+
end
|
48
|
+
|
49
|
+
java_signature 'void finishBatch()'
|
50
|
+
def finishBatch
|
51
|
+
@real_bolt.finish_batch if @real_bolt.respond_to?(:finish_batch)
|
52
|
+
end
|
53
|
+
|
54
|
+
java_signature 'void declareOutputFields(OutputFieldsDeclarer)'
|
55
|
+
def declareOutputFields(declarer)
|
56
|
+
@real_bolt.declare_output_fields(declarer)
|
57
|
+
end
|
58
|
+
|
59
|
+
java_signature 'Map<String, Object> getComponentConfiguration()'
|
60
|
+
def getComponentConfiguration
|
61
|
+
@real_bolt.get_component_configuration
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
java_import 'backtype.storm.coordination.BatchOutputCollector'
|
4
|
+
java_import 'backtype.storm.task.TopologyContext'
|
5
|
+
java_import 'backtype.storm.coordination.IBatchBolt'
|
6
|
+
java_import 'backtype.storm.transactional.ICommitter'
|
7
|
+
java_import 'backtype.storm.topology.OutputFieldsDeclarer'
|
8
|
+
java_import 'backtype.storm.tuple.Tuple'
|
9
|
+
java_import 'java.util.Map'
|
10
|
+
|
11
|
+
module Backtype
|
12
|
+
java_import 'backtype.storm.Config'
|
13
|
+
end
|
14
|
+
|
15
|
+
java_package 'redstorm.proxy'
|
16
|
+
|
17
|
+
class BatchCommitterBolt
|
18
|
+
java_implements 'ICommitter, IBatchBolt'
|
19
|
+
|
20
|
+
java_signature 'IBatchCommitterBolt (String base_class_path, String real_bolt_class_name)'
|
21
|
+
def initialize(base_class_path, real_bolt_class_name)
|
22
|
+
@real_bolt = Object.module_eval(real_bolt_class_name).new
|
23
|
+
rescue NameError
|
24
|
+
require base_class_path
|
25
|
+
@real_bolt = Object.module_eval(real_bolt_class_name).new
|
26
|
+
end
|
27
|
+
|
28
|
+
java_signature 'void prepare(Map, TopologyContext, BatchOutputCollector, Object)'
|
29
|
+
def prepare(conf, context, collector, id)
|
30
|
+
@real_bolt.prepare(conf, context, collector, id)
|
31
|
+
end
|
32
|
+
|
33
|
+
java_signature 'void execute(Tuple)'
|
34
|
+
def execute(tuple)
|
35
|
+
@real_bolt.execute(tuple)
|
36
|
+
end
|
37
|
+
|
38
|
+
java_signature 'void finishBatch()'
|
39
|
+
def finishBatch
|
40
|
+
@real_bolt.finish_batch if @real_bolt.respond_to?(:finish_batch)
|
41
|
+
end
|
42
|
+
|
43
|
+
java_signature 'void declareOutputFields(OutputFieldsDeclarer)'
|
44
|
+
def declareOutputFields(declarer)
|
45
|
+
@real_bolt.declare_output_fields(declarer)
|
46
|
+
end
|
47
|
+
|
48
|
+
java_signature 'Map<String, Object> getComponentConfiguration()'
|
49
|
+
def getComponentConfiguration
|
50
|
+
@real_bolt.get_component_configuration
|
51
|
+
end
|
52
|
+
end
|
@@ -1,31 +1,19 @@
|
|
1
1
|
require 'java'
|
2
2
|
|
3
|
-
java_import 'storm.trident.operation.TridentCollector'
|
4
3
|
java_import 'backtype.storm.task.TopologyContext'
|
4
|
+
java_import 'storm.trident.operation.TridentCollector'
|
5
5
|
java_import 'storm.trident.spout.IBatchSpout'
|
6
|
-
java_import 'backtype.storm.topology.OutputFieldsDeclarer'
|
7
|
-
java_import 'backtype.storm.tuple.Tuple'
|
8
6
|
java_import 'backtype.storm.tuple.Fields'
|
9
|
-
java_import 'backtype.storm.tuple.Values'
|
10
7
|
java_import 'java.util.Map'
|
8
|
+
|
11
9
|
module Backtype
|
12
10
|
java_import 'backtype.storm.Config'
|
13
11
|
end
|
14
12
|
|
15
13
|
java_package 'redstorm.proxy'
|
16
14
|
|
17
|
-
# the
|
15
|
+
# the Spout class is a proxy to the real spout to avoid having to deal with all the
|
18
16
|
# Java artifacts when creating a spout.
|
19
|
-
#
|
20
|
-
# The real batch spout class implementation must define these methods:
|
21
|
-
# - open(conf, context, collector)
|
22
|
-
# - emitBatch
|
23
|
-
# - getOutputFields
|
24
|
-
# - ack(batch_id)
|
25
|
-
#
|
26
|
-
# and optionnaly:
|
27
|
-
# - close
|
28
|
-
#
|
29
17
|
|
30
18
|
class BatchSpout
|
31
19
|
java_implements IBatchSpout
|
@@ -40,7 +28,12 @@ class BatchSpout
|
|
40
28
|
|
41
29
|
java_signature 'void open(Map, TopologyContext)'
|
42
30
|
def open(conf, context)
|
43
|
-
@real_spout.open(conf, context)
|
31
|
+
@real_spout.open(conf, context) if @real_spout.respond_to?(:open)
|
32
|
+
end
|
33
|
+
|
34
|
+
java_signature 'void emitBatch(long, TridentCollector)'
|
35
|
+
def emitBatch(batch_id, collector)
|
36
|
+
@real_spout.emit_batch(batch_id, collector)
|
44
37
|
end
|
45
38
|
|
46
39
|
java_signature 'void close()'
|
@@ -48,19 +41,14 @@ class BatchSpout
|
|
48
41
|
@real_spout.close if @real_spout.respond_to?(:close)
|
49
42
|
end
|
50
43
|
|
51
|
-
java_signature 'void emitBatch(long, TridentCollector)'
|
52
|
-
def emitBatch(batch_id, collector)
|
53
|
-
@real_spout.emit_batch(batch_id, collector)
|
54
|
-
end
|
55
|
-
|
56
44
|
java_signature 'void ack(long)'
|
57
45
|
def ack(batch_id)
|
58
|
-
@real_spout.ack(batch_id)
|
46
|
+
@real_spout.ack(batch_id) if @real_spout.respond_to?(:ack)
|
59
47
|
end
|
60
48
|
|
61
49
|
java_signature 'Fields getOutputFields()'
|
62
|
-
def getOutputFields
|
63
|
-
@real_spout.get_output_fields
|
50
|
+
def getOutputFields()
|
51
|
+
@real_spout.get_output_fields
|
64
52
|
end
|
65
53
|
|
66
54
|
java_signature 'Map<String, Object> getComponentConfiguration()'
|
@@ -1,16 +1,10 @@
|
|
1
1
|
require 'java'
|
2
2
|
|
3
|
-
|
4
3
|
java_import 'storm.trident.tuple.TridentTuple'
|
5
|
-
|
6
4
|
java_import 'storm.trident.operation.TridentCollector'
|
7
|
-
|
8
|
-
java_import 'java.util.Map'
|
9
|
-
|
10
5
|
java_import 'storm.trident.operation.TridentOperationContext'
|
11
|
-
|
12
6
|
java_import 'storm.trident.operation.Function'
|
13
|
-
|
7
|
+
java_import 'java.util.Map'
|
14
8
|
|
15
9
|
module Backtype
|
16
10
|
java_import 'backtype.storm.Config'
|
@@ -43,6 +37,4 @@ class ProxyFunction
|
|
43
37
|
def prepare(_map, _trident_operation_context)
|
44
38
|
@real.prepare(_map, _trident_operation_context)
|
45
39
|
end
|
46
|
-
|
47
|
-
|
48
40
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
java_import 'backtype.storm.task.TopologyContext'
|
4
|
+
java_import 'backtype.storm.transactional.ITransactionalSpout'
|
5
|
+
java_import 'backtype.storm.transactional.ICommitterTransactionalSpout'
|
6
|
+
java_import 'backtype.storm.topology.OutputFieldsDeclarer'
|
7
|
+
java_import 'java.util.Map'
|
8
|
+
|
9
|
+
module Backtype
|
10
|
+
java_import 'backtype.storm.Config'
|
11
|
+
end
|
12
|
+
|
13
|
+
java_package 'redstorm.proxy'
|
14
|
+
|
15
|
+
|
16
|
+
class TransactionalCommitterSpout
|
17
|
+
java_implements 'ICommitterTransactionalSpout'
|
18
|
+
|
19
|
+
java_signature 'ICommitterTransactionalSpout (String base_class_path, String real_spout_class_name)'
|
20
|
+
def initialize(base_class_path, real_spout_class_name)
|
21
|
+
@real_spout = Object.module_eval(real_spout_class_name).new
|
22
|
+
rescue NameError
|
23
|
+
require base_class_path
|
24
|
+
@real_spout = Object.module_eval(real_spout_class_name).new
|
25
|
+
end
|
26
|
+
|
27
|
+
java_signature 'ICommitterTransactionalSpout.Emitter getEmitter(Map, TopologyContext)'
|
28
|
+
def getEmitter(conf, context)
|
29
|
+
@real_spout.get_emitter(conf, context)
|
30
|
+
end
|
31
|
+
|
32
|
+
java_signature 'ITransactionalSpout.Coordinator getCoordinator(Map, TopologyContext)'
|
33
|
+
def getCoordinator(conf, context)
|
34
|
+
@real_spout.get_coordinator(conf, context)
|
35
|
+
end
|
36
|
+
|
37
|
+
java_signature 'void declareOutputFields(OutputFieldsDeclarer)'
|
38
|
+
def declareOutputFields(declarer)
|
39
|
+
@real_spout.declare_output_fields(declarer)
|
40
|
+
end
|
41
|
+
|
42
|
+
java_signature 'Map<String, Object> getComponentConfiguration()'
|
43
|
+
def getComponentConfiguration
|
44
|
+
@real_spout.get_component_configuration
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
java_import 'backtype.storm.task.TopologyContext'
|
4
|
+
java_import 'backtype.storm.transactional.ITransactionalSpout'
|
5
|
+
java_import 'backtype.storm.topology.OutputFieldsDeclarer'
|
6
|
+
java_import 'java.util.Map'
|
7
|
+
|
8
|
+
module Backtype
|
9
|
+
java_import 'backtype.storm.Config'
|
10
|
+
end
|
11
|
+
|
12
|
+
java_package 'redstorm.proxy'
|
13
|
+
|
14
|
+
|
15
|
+
class TransactionalSpout
|
16
|
+
java_implements 'ITransactionalSpout'
|
17
|
+
|
18
|
+
java_signature 'ITransactionalSpout (String base_class_path, String real_spout_class_name)'
|
19
|
+
def initialize(base_class_path, real_spout_class_name)
|
20
|
+
@real_spout = Object.module_eval(real_spout_class_name).new
|
21
|
+
rescue NameError
|
22
|
+
require base_class_path
|
23
|
+
@real_spout = Object.module_eval(real_spout_class_name).new
|
24
|
+
end
|
25
|
+
|
26
|
+
java_signature 'ITransactionalSpout.Emitter getEmitter(Map, TopologyContext)'
|
27
|
+
def getEmitter(conf, context)
|
28
|
+
@real_spout.get_emitter(conf, context)
|
29
|
+
end
|
30
|
+
|
31
|
+
java_signature 'ITransactionalSpout.Coordinator getCoordinator(Map, TopologyContext)'
|
32
|
+
def getCoordinator(conf, context)
|
33
|
+
@real_spout.get_coordinator(conf, context)
|
34
|
+
end
|
35
|
+
|
36
|
+
java_signature 'void declareOutputFields(OutputFieldsDeclarer)'
|
37
|
+
def declareOutputFields(declarer)
|
38
|
+
@real_spout.declare_output_fields(declarer)
|
39
|
+
end
|
40
|
+
|
41
|
+
java_signature 'Map<String, Object> getComponentConfiguration()'
|
42
|
+
def getComponentConfiguration
|
43
|
+
@real_spout.get_component_configuration
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -13,11 +13,10 @@ module RedStorm
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def grouping(grouping)
|
16
|
-
@grouping =
|
16
|
+
@grouping = grouping
|
17
17
|
end
|
18
18
|
|
19
19
|
def define_grouping(declarer)
|
20
|
-
|
21
20
|
case @grouping
|
22
21
|
when :fields
|
23
22
|
declarer.fieldsGrouping(Fields.new(*([params].flatten.map(&:to_s))))
|
@@ -73,6 +72,7 @@ module RedStorm
|
|
73
72
|
end
|
74
73
|
|
75
74
|
def self.input_bolt(bolt_class, *args, &bolt_block)
|
75
|
+
set_topology_class!
|
76
76
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
77
77
|
contructor_args = !args.empty? ? args.pop : []
|
78
78
|
bolt_options = {:id => self.underscore(bolt_class), :parallelism => DEFAULT_BOLT_PARALLELISM}.merge(options)
|