hbase-jruby 0.4.5-java → 0.4.6-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/CHANGELOG.md +5 -0
- data/lib/hbase-jruby/dependency.rb +3 -0
- data/lib/hbase-jruby/hbase.rb +31 -14
- data/lib/hbase-jruby/table.rb +8 -2
- data/lib/hbase-jruby/version.rb +1 -1
- data/lib/hbase-jruby.rb +4 -1
- data/test/test_hbase.rb +2 -1
- data/test/test_table.rb +40 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35894372ec9c361c225d9dc621f09769f66c1815
|
4
|
+
data.tar.gz: 4e86e949fd9d8200bf4c790c58988b43dc621db5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d58ba2c67f70d04177b7c36d85739bbbcf54c58f41f74e3fa62a270b02bfc38bd0bf3aaf42c27fc756f004ff2cd7a38f66d2471e5c6babe62b859d7b94182df3
|
7
|
+
data.tar.gz: f61b4bece92dd25907524849d638633c9df30d4fede814b8d0373a937cd410e8e0f967f846d57c3fe28043b2322908a82186affe1649768b6a0c64460bf550d2
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
0.4.6
|
5
|
+
-----
|
6
|
+
- [#29 Fix possible HTable leaks](https://github.com/junegunn/hbase-jruby/issues/29)
|
7
|
+
- [#30 Make `HBase.log4j=` callable before dependencies are met](https://github.com/junegunn/hbase-jruby/issues/30)
|
8
|
+
|
4
9
|
0.4.5
|
5
10
|
-----
|
6
11
|
- Fixed HBase 0.96 compatibily issues and tested on HBase 0.96 and 0.98
|
data/lib/hbase-jruby/hbase.rb
CHANGED
@@ -13,29 +13,34 @@ class HBase
|
|
13
13
|
# @overload HBase.log4j=(filename)
|
14
14
|
# Configure Log4j logging with the given file
|
15
15
|
# @param [String] filename Path to log4j.properties or log4j.xml file
|
16
|
-
# @return [
|
16
|
+
# @return [String]
|
17
17
|
# @overload HBase.log4j=(hash)
|
18
18
|
# Configure Log4j logging with the given Hash
|
19
19
|
# @param [Hash] hash Log4j properties in Ruby Hash
|
20
|
-
# @return [
|
20
|
+
# @return [Hash]
|
21
21
|
# @overload HBase.log4j=(props)
|
22
22
|
# Configure Log4j logging with the given Properties
|
23
23
|
# @param [java.util.Properties] props Properties object
|
24
|
-
# @return [
|
24
|
+
# @return [java.util.Properties]
|
25
25
|
def self.log4j= arg
|
26
|
-
|
27
|
-
|
28
|
-
arg.
|
29
|
-
props
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
when '.xml'
|
35
|
-
org.apache.log4j.xml.DOMConfigurator.configure arg
|
26
|
+
org.apache.log4j.PropertyConfigurator rescue nil
|
27
|
+
if defined?(org.apache.log4j.PropertyConfigurator)
|
28
|
+
if arg.is_a?(Hash)
|
29
|
+
props = java.util.Properties.new
|
30
|
+
arg.each do |k, v|
|
31
|
+
props.setProperty k.to_s, v.to_s
|
32
|
+
end
|
33
|
+
org.apache.log4j.PropertyConfigurator.configure props
|
36
34
|
else
|
37
|
-
|
35
|
+
case File.extname(arg).downcase
|
36
|
+
when '.xml'
|
37
|
+
org.apache.log4j.xml.DOMConfigurator.configure arg
|
38
|
+
else
|
39
|
+
org.apache.log4j.PropertyConfigurator.configure arg
|
40
|
+
end
|
38
41
|
end
|
42
|
+
else
|
43
|
+
@@log4j = arg
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
@@ -173,9 +178,21 @@ class HBase
|
|
173
178
|
|
174
179
|
private
|
175
180
|
def register_thread t
|
181
|
+
# (NOTE) The cleanup routine can be inefficient when the number of
|
182
|
+
# concurrent threads becomes large. However, since it is not likely that
|
183
|
+
# there will be more than a few hundred threads in a typical JRuby process
|
184
|
+
# and the code is executed only once per thread, let's simply assume that
|
185
|
+
# it's okay.
|
176
186
|
@mutex.synchronize do
|
177
187
|
check_closed
|
178
188
|
@threads << t
|
189
|
+
alives, deads = @threads.partition { |e| e.alive? }
|
190
|
+
@threads = Set.new(alives)
|
191
|
+
deads.each do |dead|
|
192
|
+
(dead[:hbase_jruby].delete(self) || {}).each do |_, htable|
|
193
|
+
htable.close rescue nil
|
194
|
+
end
|
195
|
+
end
|
179
196
|
end
|
180
197
|
end
|
181
198
|
|
data/lib/hbase-jruby/table.rb
CHANGED
@@ -29,10 +29,16 @@ class Table
|
|
29
29
|
local_htables[@name] ||= @hbase.send :get_htable, @name
|
30
30
|
end
|
31
31
|
|
32
|
-
#
|
32
|
+
# Return HTable instance back to the table pool.
|
33
|
+
# Generally this is not required unless you use unlimited number of threads
|
33
34
|
# @return [nil]
|
34
35
|
def close
|
35
|
-
|
36
|
+
check_closed
|
37
|
+
|
38
|
+
(t = Thread.current[:hbase_jruby]) &&
|
39
|
+
(t = t[@hbase]) &&
|
40
|
+
(t = t.delete @name) &&
|
41
|
+
t.close
|
36
42
|
end
|
37
43
|
|
38
44
|
# Returns whether if the connection is closed
|
data/lib/hbase-jruby/version.rb
CHANGED
data/lib/hbase-jruby.rb
CHANGED
@@ -2,6 +2,10 @@ unless RUBY_PLATFORM =~ /java/
|
|
2
2
|
raise LoadError, 'Only supports JRuby'
|
3
3
|
end
|
4
4
|
|
5
|
+
class HBase
|
6
|
+
@@log4j = nil
|
7
|
+
end
|
8
|
+
|
5
9
|
require 'hbase-jruby/version'
|
6
10
|
require 'hbase-jruby/dependency'
|
7
11
|
require 'hbase-jruby/util'
|
@@ -21,4 +25,3 @@ require 'hbase-jruby/table/checked_operation'
|
|
21
25
|
require 'hbase-jruby/row'
|
22
26
|
require 'hbase-jruby/hbase'
|
23
27
|
|
24
|
-
HBase.import_java_classes!
|
data/test/test_hbase.rb
CHANGED
data/test/test_table.rb
CHANGED
@@ -23,16 +23,56 @@ class TestTable < TestHBaseJRubyBase
|
|
23
23
|
# Multi-threaded
|
24
24
|
htables = []
|
25
25
|
table = @hbase.table(TABLE)
|
26
|
+
nthr = num_managed_threads
|
26
27
|
4.times do
|
27
28
|
Thread.new {
|
28
29
|
htables << table.htable
|
30
|
+
assert_equal nthr + 1, num_managed_threads
|
29
31
|
}.join
|
30
32
|
end
|
31
33
|
assert_equal 4, htables.uniq.length
|
34
|
+
# XXX Implementation detail
|
35
|
+
assert_equal nthr + 1, num_managed_threads
|
32
36
|
|
33
37
|
assert_equal @hbase.table(TABLE).htable, @hbase[TABLE].htable
|
34
38
|
end
|
35
39
|
|
40
|
+
def test_table_close
|
41
|
+
htables = Set.new
|
42
|
+
htables << @hbase[TABLE].htable
|
43
|
+
htables << @hbase[TABLE].htable
|
44
|
+
assert_equal 1, htables.length
|
45
|
+
|
46
|
+
@hbase[TABLE].close
|
47
|
+
htables << @hbase[TABLE].htable
|
48
|
+
htables << @hbase[TABLE].htable
|
49
|
+
assert_equal 2, htables.length
|
50
|
+
end
|
51
|
+
|
52
|
+
def num_managed_threads
|
53
|
+
@hbase.instance_variable_get(:@threads).length
|
54
|
+
end
|
55
|
+
|
56
|
+
# FIXME
|
57
|
+
# - Implementation detail
|
58
|
+
# - Naive assertion
|
59
|
+
# - Race condition
|
60
|
+
def test_autoclose_htables
|
61
|
+
nthr = num_managed_threads
|
62
|
+
threads = 50.times.map { |i|
|
63
|
+
Thread.new {
|
64
|
+
@hbase[TABLE].htable
|
65
|
+
sleep 0.5
|
66
|
+
}
|
67
|
+
}
|
68
|
+
sleep 1
|
69
|
+
assert num_managed_threads > nthr
|
70
|
+
|
71
|
+
nthr = num_managed_threads
|
72
|
+
Thread.new { @hbase[TABLE].htable }.join
|
73
|
+
assert num_managed_threads < nthr
|
74
|
+
end
|
75
|
+
|
36
76
|
def test_put_then_get
|
37
77
|
row1 = next_rowkey.to_s
|
38
78
|
row2 = next_rowkey.to_s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hbase-jruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Junegunn Choi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
104
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.2.
|
105
|
+
rubygems_version: 2.2.1
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: A JRuby binding for HBase
|