Permalink
Browse files

java now uses RequestRegistry, tests pass

  • Loading branch information...
1 parent ec9ca3d commit e628a22bc9a56f62a9e81ac5768789921a585b1a @slyphon slyphon committed Aug 17, 2012
Showing with 6 additions and 40 deletions.
  1. +5 −20 java/java_base.rb
  2. +0 −19 lib/zookeeper/common.rb
  3. +1 −1 lib/zookeeper/request_registry.rb
View
@@ -186,9 +186,7 @@ def reopen(timeout=10, watcher=nil)
# watcher ||= @default_watcher
@mutex.synchronize do
- # flushes all outstanding watcher reqs.
- @watcher_reqs.clear
- set_default_global_watcher
+ @req_registry.clear_watchers!
replace_jzk!
wait_until_connected
@@ -205,19 +203,19 @@ def wait_until_connected(timeout=10)
def initialize(host, timeout=10, watcher=nil, options={})
@host = host
@event_queue = QueueWithPipe.new
- @current_req_id = 0
+
+ watcher ||= get_default_global_watcher()
+
+ @req_registry = RequestRegistry.new(watcher)
@mutex = Monitor.new
@dispatch_shutdown_cond = @mutex.new_cond
@connected_latch = Latch.new
- @watcher_reqs = {}
- @completion_reqs = {}
@_running = nil
@_closed = false
@options = {}
- @default_watcher = (watcher || get_default_global_watcher)
# allows connected-state handlers to be registered before
yield self if block_given?
@@ -415,19 +413,6 @@ def assert_open
raise NotConnected unless connected?
end
- # set the watcher object/proc that will receive all global events (such as session/state events)
- #---
- # XXX: this code needs to be duplicated from ext/zookeeper_base.rb because
- # it's called from the initializer, and because of the C impl. we can't have
- # the two decend from a common base, and a module wouldn't work
- #
- # XXX: this is probably a relic?
- def set_default_global_watcher
- @mutex.synchronize do
- @watcher_reqs[ZKRB_GLOBAL_CB_REQ] = { :watcher => @default_watcher, :watcher_context => nil }
- end
- end
-
def session_id
jzk.session_id
end
@@ -3,11 +3,6 @@
module Zookeeper
module Common
- extend Forwardable
-
- # XXX: this is assigned in the various base classes, should probably move this elsewhere
- def_delegators :@req_registry, :setup_call
-
def event_dispatch_thread?
@dispatcher && (@dispatcher == Thread.current)
end
@@ -93,20 +88,6 @@ def dispatch_next_callback(hash)
true
end
- def assert_supported_keys(args, supported)
- unless (args.keys - supported).empty?
- raise Zookeeper::Exceptions::BadArguments,
- "Supported arguments are: #{supported.inspect}, but arguments #{args.keys.inspect} were supplied instead"
- end
- end
-
- def assert_required_keys(args, required)
- unless (required - args.keys).empty?
- raise Zookeeper::Exceptions::BadArguments,
- "Required arguments are: #{required.inspect}, but only the arguments #{args.keys.inspect} were supplied."
- end
- end
-
def dispatch_thread_body
while true
begin
@@ -139,7 +139,7 @@ def maybe_wrap_callback(meth_name, cb)
end
def chrooted?
- !@chroot_path.empty?
+ @chroot_path && !@chroot_path.empty?
end
def default_watcher_proc

0 comments on commit e628a22

Please sign in to comment.