slyphon-zookeeper 0.1.0-java → 0.1.4-java

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ platforms :mri_18 do
6
+ gem 'ruby-debug'
7
+ end
8
+
9
+
10
+ # vim:ft=ruby
@@ -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::ConnectionClosed unless connected?
60
+ raise ZookeeperException::NotConnected unless connected?
61
61
  end
62
62
 
63
63
  def connected?
@@ -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::ConnectionClosed unless connected?
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)
@@ -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
- # TODO: Eventually enforce derivation from Zookeeper::Callback
70
- if callback.respond_to?(:call)
71
- callback.call(hash)
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
- # puts "dispatch_next_callback found non-callback => #{callback.inspect}"
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
 
@@ -6,6 +6,7 @@ module ZookeeperConstants
6
6
  # session state
7
7
  ZOO_EXPIRED_SESSION_STATE = -112
8
8
  ZOO_AUTH_FAILED_STATE = -113
9
+ ZOO_CLOSED_STATE = 0
9
10
  ZOO_CONNECTING_STATE = 1
10
11
  ZOO_ASSOCIATING_STATE = 2
11
12
  ZOO_CONNECTED_STATE = 3
@@ -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
- class ConnectionClosed < ZookeeperException; end # this is a Ruby client exception
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
@@ -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.0'
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: 27
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: java
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-02-14 00:00:00 +00:00
22
+ date: 2011-03-08 00:00:00 +00:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -98,6 +98,7 @@ extra_rdoc_files: []
98
98
  files:
99
99
  - .gitignore
100
100
  - CHANGELOG
101
+ - Gemfile
101
102
  - LICENSE
102
103
  - Manifest
103
104
  - README