slyphon-zookeeper 0.8.0.rc.1-java → 0.8.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +34 -0
- data/ext/zookeeper_base.rb +4 -1
- data/java/zookeeper_base.rb +2 -2
- data/lib/zookeeper.rb +10 -0
- data/lib/zookeeper/common.rb +4 -0
- data/lib/zookeeper/em_client.rb +15 -7
- data/slyphon-zookeeper.gemspec +1 -1
- data/spec/shared/connection_examples.rb +18 -1
- metadata +9 -13
data/CHANGELOG
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
v0.8.0 Refactor C implementaion, EventMachine client
|
2
|
+
|
3
|
+
* separated CZookeeper and ZookeeperBase implementation
|
4
|
+
|
5
|
+
This solves issues with reopen not working properly, makes for a much
|
6
|
+
cleaner event delivery implementation. ZookeeperBase controls the lifecycle
|
7
|
+
of the event dispatch thread now, rather than it being tied to CZookeeper.
|
8
|
+
|
9
|
+
* added support for the 'sync' API call
|
10
|
+
|
11
|
+
* Refactored zookeeper_c.c and zookeeper_lib.c
|
12
|
+
|
13
|
+
More error checking in zookeeper_lib.c and restructure some things to make
|
14
|
+
logic easier to follow
|
15
|
+
|
16
|
+
Fix bug in method_get_next_event that made the shutdown case so complicated
|
17
|
+
|
18
|
+
* Massively simplified EMClient implementation
|
19
|
+
|
20
|
+
Rather than trying to hook the IO used by zookeeper_lib to notify zookeeper_c
|
21
|
+
about event availabiltiy directly into EventMachine, use the same event delivery
|
22
|
+
thread, but wrap the dispatch call in EM.schedule.
|
23
|
+
|
24
|
+
* Improve implementation of spin-lock-esque code that waits for the connection to be
|
25
|
+
established before returning.
|
26
|
+
|
27
|
+
This cut the test runtime down from 1m 20s to 2s.
|
28
|
+
|
29
|
+
* Java client refactoring, similar correctness changes
|
30
|
+
|
31
|
+
* Change ZookeeperException base class to StandardError instead of Exception
|
32
|
+
|
33
|
+
|
1
34
|
v0.4.5 Upgrade to ZooKeeper 3.3.3
|
2
35
|
|
3
36
|
v0.4.4 Fix race condition on close, possible data corruption on async get.
|
@@ -24,3 +57,4 @@ v0.2. Bundle C dependencies, like memcached.gem.
|
|
24
57
|
|
25
58
|
v0.1. First release.
|
26
59
|
|
60
|
+
# vim:ft=text:ts=2:sw=2:et
|
data/ext/zookeeper_base.rb
CHANGED
@@ -56,7 +56,10 @@ class ZookeeperBase
|
|
56
56
|
@watcher_reqs.clear
|
57
57
|
set_default_global_watcher
|
58
58
|
|
59
|
-
@czk = CZookeeper.new(@host, @event_queue)
|
59
|
+
orig_czk, @czk = @czk, CZookeeper.new(@host, @event_queue)
|
60
|
+
|
61
|
+
orig_czk.close if orig_czk
|
62
|
+
|
60
63
|
@czk.wait_until_connected(timeout)
|
61
64
|
end
|
62
65
|
|
data/java/zookeeper_base.rb
CHANGED
@@ -176,7 +176,7 @@ class ZookeeperBase
|
|
176
176
|
|
177
177
|
@mutex.synchronize do
|
178
178
|
# flushes all outstanding watcher reqs.
|
179
|
-
@watcher_reqs
|
179
|
+
@watcher_reqs.clear
|
180
180
|
set_default_global_watcher
|
181
181
|
|
182
182
|
replace_jzk!
|
@@ -215,7 +215,7 @@ class ZookeeperBase
|
|
215
215
|
# allows connected-state handlers to be registered before
|
216
216
|
yield self if block_given?
|
217
217
|
|
218
|
-
reopen(timeout
|
218
|
+
reopen(timeout)
|
219
219
|
return nil unless connected?
|
220
220
|
@_running = true
|
221
221
|
setup_dispatch_thread!
|
data/lib/zookeeper.rb
CHANGED
@@ -183,6 +183,16 @@ class Zookeeper < ZookeeperBase
|
|
183
183
|
def associating?
|
184
184
|
super
|
185
185
|
end
|
186
|
+
|
187
|
+
# There are some operations that are dangerous in the context of the event
|
188
|
+
# dispatch thread (because they would block further event delivery). This
|
189
|
+
# method allows clients to know if they're currently executing in the context of an
|
190
|
+
# event.
|
191
|
+
#
|
192
|
+
# @returns [true,false] true if the current thread is the event dispatch thread
|
193
|
+
def event_dispatch_thread?
|
194
|
+
super
|
195
|
+
end
|
186
196
|
|
187
197
|
# for expert use only. set the underlying debug level for the C layer, has no
|
188
198
|
# effect in java
|
data/lib/zookeeper/common.rb
CHANGED
@@ -4,6 +4,10 @@ module ZookeeperCommon
|
|
4
4
|
# sigh, i guess define this here?
|
5
5
|
ZKRB_GLOBAL_CB_REQ = -1
|
6
6
|
|
7
|
+
def event_dispatch_thread?
|
8
|
+
@dispatcher && (@dispatcher == Thread.current)
|
9
|
+
end
|
10
|
+
|
7
11
|
protected
|
8
12
|
def get_next_event(blocking=true)
|
9
13
|
@event_queue.pop(!blocking).tap do |event|
|
data/lib/zookeeper/em_client.rb
CHANGED
@@ -31,16 +31,24 @@ module ZookeeperEM
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def dispatch_next_callback(hash)
|
34
|
-
EM.schedule
|
34
|
+
EM.schedule do
|
35
|
+
if running? and not closed?
|
36
|
+
logger.debug { "#{self.class}##{__method__} dispatch_next_callback: #{hash.inspect}: reactor_thread? #{EM.reactor_thread?}, running? #{running?}, closed? #{closed?}" }
|
37
|
+
super(hash)
|
38
|
+
end
|
39
|
+
end
|
35
40
|
end
|
36
41
|
|
37
|
-
# this is synchronous, but since the API still allows attaching to on_close,
|
38
|
-
# we just fake it here
|
39
42
|
def close(&block)
|
40
|
-
on_close(&block)
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
on_close(&block)
|
44
|
+
super()
|
45
|
+
on_close.succeed
|
46
|
+
end
|
47
|
+
|
48
|
+
# Because eventmachine is single-threaded, and events are dispatched on the
|
49
|
+
# reactor thread we just delegate this to EM.reactor_thread?
|
50
|
+
def event_dispatch_thread?
|
51
|
+
EM.reactor_thread?
|
44
52
|
end
|
45
53
|
end # Client
|
46
54
|
end # ZookeeperEM
|
data/slyphon-zookeeper.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "slyphon-zookeeper"
|
6
|
-
s.version = '0.8.
|
6
|
+
s.version = '0.8.1'
|
7
7
|
|
8
8
|
s.authors = ["Phillip Pearson", "Eric Maland", "Evan Weaver", "Brian Wickman", "Neil Conway", "Jonathan D. Simms"]
|
9
9
|
s.email = ["slyphon@gmail.com"]
|
@@ -985,6 +985,23 @@ shared_examples_for "connection" do
|
|
985
985
|
end
|
986
986
|
end
|
987
987
|
end
|
988
|
-
end
|
989
988
|
|
989
|
+
describe :event_dispatch_thread? do
|
990
|
+
it %[should return true when called on the event dispatching thread] do
|
991
|
+
@result = nil
|
992
|
+
|
993
|
+
cb = lambda do |hash|
|
994
|
+
@result = zk.event_dispatch_thread?
|
995
|
+
end
|
996
|
+
|
997
|
+
@rv = zk.sync(:path => path, :callback => cb)
|
998
|
+
|
999
|
+
wait_until(2) { @result == true }.should be_true
|
1000
|
+
end
|
1001
|
+
|
1002
|
+
it %[should return false when not on the event dispatching thread] do
|
1003
|
+
zk.event_dispatch_thread?.should_not be_true
|
1004
|
+
end
|
1005
|
+
end
|
1006
|
+
end
|
990
1007
|
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slyphon-zookeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 61
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
- 0
|
10
|
-
- rc
|
11
9
|
- 1
|
12
|
-
version: 0.8.
|
10
|
+
version: 0.8.1
|
13
11
|
platform: java
|
14
12
|
authors:
|
15
13
|
- Phillip Pearson
|
@@ -22,7 +20,7 @@ autorequire:
|
|
22
20
|
bindir: bin
|
23
21
|
cert_chain: []
|
24
22
|
|
25
|
-
date: 2012-04-
|
23
|
+
date: 2012-04-23 00:00:00 Z
|
26
24
|
dependencies:
|
27
25
|
- !ruby/object:Gem::Dependency
|
28
26
|
name: rspec
|
@@ -64,7 +62,7 @@ dependencies:
|
|
64
62
|
requirements:
|
65
63
|
- - "="
|
66
64
|
- !ruby/object:Gem::Version
|
67
|
-
hash:
|
65
|
+
hash: 3858962089
|
68
66
|
segments:
|
69
67
|
- 1
|
70
68
|
- 0
|
@@ -230,14 +228,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
229
|
none: false
|
232
230
|
requirements:
|
233
|
-
- - "
|
231
|
+
- - ">="
|
234
232
|
- !ruby/object:Gem::Version
|
235
|
-
hash:
|
233
|
+
hash: 3
|
236
234
|
segments:
|
237
|
-
-
|
238
|
-
|
239
|
-
- 1
|
240
|
-
version: 1.3.1
|
235
|
+
- 0
|
236
|
+
version: "0"
|
241
237
|
requirements: []
|
242
238
|
|
243
239
|
rubyforge_project:
|