slyphon-zookeeper 0.1.0 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -0
- data/ext/zookeeper_base.rb +1 -1
- data/java/zookeeper_base.rb +1 -1
- data/lib/zookeeper.rb +8 -8
- data/lib/zookeeper/common.rb +15 -6
- data/lib/zookeeper/constants.rb +1 -0
- data/lib/zookeeper/exceptions.rb +4 -1
- data/slyphon-zookeeper.gemspec +1 -1
- metadata +5 -4
data/Gemfile
ADDED
data/ext/zookeeper_base.rb
CHANGED
@@ -57,7 +57,7 @@ class ZookeeperBase < CZookeeper
|
|
57
57
|
# if either of these happen, the user will need to renegotiate a connection via reopen
|
58
58
|
def assert_open
|
59
59
|
raise ZookeeperException::SessionExpired if state == ZOO_EXPIRED_SESSION_STATE
|
60
|
-
raise ZookeeperException::
|
60
|
+
raise ZookeeperException::NotConnected unless connected?
|
61
61
|
end
|
62
62
|
|
63
63
|
def connected?
|
data/java/zookeeper_base.rb
CHANGED
@@ -322,7 +322,7 @@ class ZookeeperBase
|
|
322
322
|
|
323
323
|
def assert_open
|
324
324
|
# XXX don't know how to check for valid session state!
|
325
|
-
raise ZookeeperException::
|
325
|
+
raise ZookeeperException::NotConnected unless connected?
|
326
326
|
end
|
327
327
|
|
328
328
|
KILL_TOKEN = :__kill_token__
|
data/lib/zookeeper.rb
CHANGED
@@ -138,6 +138,14 @@ class Zookeeper < ZookeeperBase
|
|
138
138
|
super
|
139
139
|
end
|
140
140
|
|
141
|
+
def connecting?
|
142
|
+
super
|
143
|
+
end
|
144
|
+
|
145
|
+
def associating?
|
146
|
+
super
|
147
|
+
end
|
148
|
+
|
141
149
|
private
|
142
150
|
def setup_call(opts)
|
143
151
|
req_id = nil
|
@@ -155,14 +163,6 @@ private
|
|
155
163
|
:context => call_opts[:watcher_context] }
|
156
164
|
end
|
157
165
|
|
158
|
-
def connecting?
|
159
|
-
super
|
160
|
-
end
|
161
|
-
|
162
|
-
def associating?
|
163
|
-
super
|
164
|
-
end
|
165
|
-
|
166
166
|
# TODO: Sanitize user mistakes by unregistering watchers from ops that
|
167
167
|
# don't return ZOK (except wexists)? Make users clean up after themselves for now.
|
168
168
|
def unregister_watcher(req_id)
|
data/lib/zookeeper/common.rb
CHANGED
@@ -63,14 +63,23 @@ protected
|
|
63
63
|
hash[:acl] = hash[:acl].map { |acl| ZookeeperACLs::ACL.new(acl) } if hash[:acl]
|
64
64
|
|
65
65
|
callback_context = is_completion ? get_completion(hash[:req_id]) : get_watcher(hash[:req_id])
|
66
|
-
callback = is_completion ? callback_context[:callback] : callback_context[:watcher]
|
67
|
-
hash[:context] = callback_context[:context]
|
68
66
|
|
69
|
-
#
|
70
|
-
|
71
|
-
|
67
|
+
# when connectivity with the server is lost, on reconnection it's possible
|
68
|
+
# to receive duplicate responses. If we've already handled a response for a
|
69
|
+
# given req_id, this value will be nil, and we just ignore it.
|
70
|
+
if callback_context
|
71
|
+
callback = is_completion ? callback_context[:callback] : callback_context[:watcher]
|
72
|
+
|
73
|
+
hash[:context] = callback_context[:context]
|
74
|
+
|
75
|
+
# TODO: Eventually enforce derivation from Zookeeper::Callback
|
76
|
+
if callback.respond_to?(:call)
|
77
|
+
callback.call(hash)
|
78
|
+
else
|
79
|
+
# puts "dispatch_next_callback found non-callback => #{callback.inspect}"
|
80
|
+
end
|
72
81
|
else
|
73
|
-
|
82
|
+
logger.warn { "Duplicate event received (no handler for req_id #{hash[:req_id]}, event: #{hash.inspect}" }
|
74
83
|
end
|
75
84
|
end
|
76
85
|
|
data/lib/zookeeper/constants.rb
CHANGED
data/lib/zookeeper/exceptions.rb
CHANGED
@@ -52,7 +52,10 @@ module ZookeeperExceptions
|
|
52
52
|
class Closing < ZookeeperException; end
|
53
53
|
class Nothing < ZookeeperException; end
|
54
54
|
class SessionMoved < ZookeeperException; end
|
55
|
-
|
55
|
+
|
56
|
+
# these are Ruby client exceptions
|
57
|
+
class ConnectionClosed < ZookeeperException; end
|
58
|
+
class NotConnected < ZookeeperException; end
|
56
59
|
|
57
60
|
def self.by_code(code)
|
58
61
|
case code
|
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.1.
|
6
|
+
s.version = '0.1.4'
|
7
7
|
|
8
8
|
s.authors = ["Phillip Pearson", "Eric Maland", "Evan Weaver", "Brian Wickman", "Jonathan D. Simms"]
|
9
9
|
s.email = ["slyphon@gmail.com"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slyphon-zookeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phillip Pearson
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2011-
|
22
|
+
date: 2011-03-08 00:00:00 +00:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
@@ -66,6 +66,7 @@ extra_rdoc_files: []
|
|
66
66
|
files:
|
67
67
|
- .gitignore
|
68
68
|
- CHANGELOG
|
69
|
+
- Gemfile
|
69
70
|
- LICENSE
|
70
71
|
- Manifest
|
71
72
|
- README
|