hermann 0.19.0-java → 0.20.0-java
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.
- checksums.yaml +4 -4
- data/Rakefile +8 -4
- data/lib/hermann/discovery/zookeeper.rb +3 -4
- data/lib/hermann/errors.rb +7 -5
- data/lib/hermann/producer.rb +1 -1
- data/lib/hermann/provider/java_producer.rb +4 -2
- data/lib/hermann/provider/java_simple_consumer.rb +2 -1
- data/lib/hermann/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34aa174c3645cce1f7bc1df218e72a00063b5264
|
4
|
+
data.tar.gz: e05f7192889002138624e8c3b8826f8ae0031660
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb665839477beea15207e8f5030708f3771c754f75a5f09f8e907f33043d9226f47aa09ac2be9b3ea701bb1b9dbae2ce4390147787f19d9c2c25af4a20e07f59
|
7
|
+
data.tar.gz: 74dd000daab4034ba6ce79d73c99bb57fbda367bcfe49cc78dcb26e30cf4e52314049632794b515208a33092ccfd1bf52a7463770d3f1847f60e2d4ca91e12b5
|
data/Rakefile
CHANGED
@@ -11,21 +11,25 @@ Rake::ExtensionTask.new do |t|
|
|
11
11
|
t.gem_spec = Gem::Specification.load('hermann.gemspec')
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
options = ['--tag ~type:integration']
|
16
|
-
|
14
|
+
def add_rspec_options(options)
|
17
15
|
if RUBY_PLATFORM == 'java'
|
18
16
|
options << '--tag ~platform:mri'
|
19
17
|
else
|
20
18
|
options << '--tag ~platform:java'
|
21
19
|
end
|
20
|
+
return options
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec::Core::RakeTask.new(:spec) do |r|
|
24
|
+
options = add_rspec_options(['--tag ~type:integration'])
|
22
25
|
|
23
26
|
r.rspec_opts = options.join(' ')
|
24
27
|
end
|
25
28
|
|
26
29
|
namespace :spec do
|
27
30
|
RSpec::Core::RakeTask.new(:integration) do |r|
|
28
|
-
|
31
|
+
options = add_rspec_options(['--tag type:integration'])
|
32
|
+
r.rspec_opts = options.join(' ')
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
@@ -24,8 +24,7 @@ module Hermann
|
|
24
24
|
# tickTime (as set in the server configuration) and a maximum
|
25
25
|
# of 20 times the tickTime2 times the tick time set on server"
|
26
26
|
#
|
27
|
-
# @return [
|
28
|
-
#
|
27
|
+
# @return [Array] List of brokers from ZK
|
29
28
|
# @raises [NoBrokersError] if could not discover brokers thru zookeeper
|
30
29
|
def get_brokers(timeout=0)
|
31
30
|
brokers = []
|
@@ -35,7 +34,7 @@ module Hermann
|
|
35
34
|
if brokers.empty?
|
36
35
|
raise Hermann::Errors::NoBrokersError
|
37
36
|
end
|
38
|
-
brokers
|
37
|
+
return brokers
|
39
38
|
end
|
40
39
|
|
41
40
|
private
|
@@ -82,4 +81,4 @@ module Hermann
|
|
82
81
|
end
|
83
82
|
end
|
84
83
|
end
|
85
|
-
end
|
84
|
+
end
|
data/lib/hermann/errors.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
|
2
2
|
module Hermann
|
3
3
|
module Errors
|
4
|
-
|
5
|
-
class ConnectivityError < StandardError
|
4
|
+
class GeneralError < StandardError
|
6
5
|
attr_reader :java_exception
|
7
6
|
|
8
7
|
# Initialize a connectivity error
|
@@ -11,17 +10,20 @@ module Hermann
|
|
11
10
|
# @param [Hash[ options
|
12
11
|
# @option options [Java::Lang::RuntimeException] :java_exception An
|
13
12
|
# underlying Java exception
|
14
|
-
def initialize(message, options={})
|
13
|
+
def initialize(message='', options={})
|
15
14
|
super(message)
|
16
15
|
@java_exception = options[:java_exception]
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
19
|
+
# Error for connectivity problems with the Kafka brokers
|
20
|
+
class ConnectivityError < GeneralError; end
|
21
|
+
|
20
22
|
# For passing incorrect config and options to kafka
|
21
|
-
class ConfigurationError <
|
23
|
+
class ConfigurationError < GeneralError; end
|
22
24
|
|
23
25
|
# cannot discover brokers from zookeeper
|
24
|
-
class NoBrokersError <
|
26
|
+
class NoBrokersError < GeneralError; end
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
data/lib/hermann/producer.rb
CHANGED
@@ -21,7 +21,7 @@ module Hermann
|
|
21
21
|
@topic = topic
|
22
22
|
@brokers = ThreadSafe::Array.new(brokers)
|
23
23
|
if Hermann.jruby?
|
24
|
-
@internal = Hermann::Provider::JavaProducer.new(brokers, opts)
|
24
|
+
@internal = Hermann::Provider::JavaProducer.new(brokers.join(','), opts)
|
25
25
|
else
|
26
26
|
@internal = Hermann::Lib::Producer.new(brokers.join(','))
|
27
27
|
end
|
@@ -13,7 +13,6 @@ module Hermann
|
|
13
13
|
|
14
14
|
#default kafka Producer options
|
15
15
|
DEFAULTS = {
|
16
|
-
'serializer.class' => 'kafka.serializer.StringEncoder',
|
17
16
|
'partitioner.class' => 'kafka.producer.DefaultPartitioner',
|
18
17
|
'request.required.acks' => '1',
|
19
18
|
'message.send.max.retries' => '0'
|
@@ -46,12 +45,15 @@ module Hermann
|
|
46
45
|
# will be set
|
47
46
|
def push_single(msg, topic, unused)
|
48
47
|
Concurrent::Promise.execute {
|
49
|
-
data = ProducerUtil::KeyedMessage.new(topic, msg)
|
48
|
+
data = ProducerUtil::KeyedMessage.new(topic, msg.to_java_bytes)
|
50
49
|
begin
|
51
50
|
@producer.send(data)
|
52
51
|
rescue Java::KafkaCommon::FailedToSendMessageException => jexc
|
53
52
|
raise Hermann::Errors::ConnectivityError.new(jexc.message,
|
54
53
|
:java_exception => jexc)
|
54
|
+
rescue => e
|
55
|
+
raise Hermann::Errors::GeneralError.new(e.message,
|
56
|
+
:java_exception => e)
|
55
57
|
end
|
56
58
|
}
|
57
59
|
end
|
@@ -60,7 +60,8 @@ module Hermann
|
|
60
60
|
stream = get_stream(topic)
|
61
61
|
it = stream.iterator
|
62
62
|
while it.hasNext do
|
63
|
-
|
63
|
+
message = it.next.message
|
64
|
+
yield String.from_java_bytes(message)
|
64
65
|
end
|
65
66
|
rescue Exception => e
|
66
67
|
puts "#{self.class.name}#consume exception: #{e.class.name}"
|
data/lib/hermann/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hermann
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- R. Tyler Croy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|