zookeeper 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/ext/zookeeper_base.rb +1 -2
- data/lib/zookeeper/continuation.rb +30 -16
- data/lib/zookeeper/version.rb +1 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
data/ext/zookeeper_base.rb
CHANGED
@@ -117,8 +117,7 @@ class ZookeeperBase
|
|
117
117
|
# if either of these happen, the user will need to renegotiate a connection via reopen
|
118
118
|
def assert_open
|
119
119
|
@mutex.synchronize do
|
120
|
-
raise Exceptions::
|
121
|
-
raise Exceptions::NotConnected unless connected?
|
120
|
+
raise Exceptions::NotConnected if closed?
|
122
121
|
if forked?
|
123
122
|
raise InheritedConnectionError, <<-EOS.gsub(/(?:^|\n)\s*/, ' ').strip
|
124
123
|
You tried to use a connection inherited from another process
|
@@ -82,6 +82,9 @@ module Zookeeper
|
|
82
82
|
@mutex = Mutex.new
|
83
83
|
@cond = ConditionVariable.new
|
84
84
|
@rval = nil
|
85
|
+
|
86
|
+
# make this error reporting more robust if necessary, right now, just set to state
|
87
|
+
@error = nil
|
85
88
|
|
86
89
|
# set to true when an event occurs that would cause the caller to
|
87
90
|
# otherwise block forever
|
@@ -90,9 +93,17 @@ module Zookeeper
|
|
90
93
|
|
91
94
|
# the caller calls this method and receives the response from the async loop
|
92
95
|
def value
|
93
|
-
@mutex.
|
94
|
-
|
95
|
-
|
96
|
+
@mutex.synchronize do
|
97
|
+
@cond.wait(@mutex) until @rval or @error
|
98
|
+
|
99
|
+
case @error
|
100
|
+
when nil
|
101
|
+
# ok, nothing to see here, carry on
|
102
|
+
when ZOO_EXPIRED_SESSION_STATE
|
103
|
+
raise Exceptions::SessionExpired, "connection has expired"
|
104
|
+
else
|
105
|
+
raise Exceptions::NotConnected, "connection state is #{STATE_NAMES[@error]}"
|
106
|
+
end
|
96
107
|
|
97
108
|
case @rval.length
|
98
109
|
when 1
|
@@ -100,8 +111,6 @@ module Zookeeper
|
|
100
111
|
else
|
101
112
|
return @rval
|
102
113
|
end
|
103
|
-
ensure
|
104
|
-
@mutex.unlock
|
105
114
|
end
|
106
115
|
end
|
107
116
|
|
@@ -124,13 +133,24 @@ module Zookeeper
|
|
124
133
|
# implementation, but it's more important to get *something* working and
|
125
134
|
# passing specs, then refactor to make everything sane
|
126
135
|
#
|
136
|
+
#
|
127
137
|
def submit(czk)
|
138
|
+
state = czk.zkrb_state # check the state of the connection
|
139
|
+
|
140
|
+
if @meth == :state # if the method is a state call
|
141
|
+
@rval = [state] # we're done, no error
|
142
|
+
return deliver!
|
143
|
+
|
144
|
+
elsif state != ZOO_CONNECTED_STATE # otherwise, we must be connected
|
145
|
+
@error = state # so set the error
|
146
|
+
return deliver! # and we're out
|
147
|
+
end
|
148
|
+
|
128
149
|
rc, *_ = czk.__send__(:"zkrb_#{@meth}", *async_args)
|
129
150
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
deliver! # wake the caller and we're out
|
151
|
+
if user_callback? or (rc != ZOK) # async call, or we failed to submit it
|
152
|
+
@rval = [rc] # create the repsonse
|
153
|
+
deliver! # wake the caller and we're out
|
134
154
|
end
|
135
155
|
end
|
136
156
|
|
@@ -152,9 +172,6 @@ module Zookeeper
|
|
152
172
|
|
153
173
|
logger.debug { "async_args, meth: #{meth} ary: #{ary.inspect}, #{callback_arg_idx}" }
|
154
174
|
|
155
|
-
# this is not already an async call
|
156
|
-
# so we replace the req_id with the ZKRB_ASYNC_CONTN_ID so the
|
157
|
-
# event thread knows to dispatch it itself
|
158
175
|
ary[callback_arg_idx] ||= self
|
159
176
|
|
160
177
|
ary
|
@@ -165,11 +182,8 @@ module Zookeeper
|
|
165
182
|
end
|
166
183
|
|
167
184
|
def deliver!
|
168
|
-
@mutex.
|
169
|
-
begin
|
185
|
+
@mutex.synchronize do
|
170
186
|
@cond.signal
|
171
|
-
ensure
|
172
|
-
@mutex.unlock rescue nil
|
173
187
|
end
|
174
188
|
end
|
175
189
|
end # Base
|
data/lib/zookeeper/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zookeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 3
|
10
|
+
version: 1.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phillip Pearson
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date: 2012-05-
|
23
|
+
date: 2012-05-21 00:00:00 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: backports
|