Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into dev/zookeeper-st

Conflicts:
	Rakefile
	lib/zookeeper.rb
  • Loading branch information...
commit 524fc12dc6fea95016b7c3b863dd204ef0e95e04 2 parents 732ebda + 5e66076
@slyphon slyphon authored
View
1  .ctags_paths
@@ -0,0 +1 @@
+~/vendor/ruby/*.{c,h}
View
10 CHANGELOG
@@ -1,3 +1,13 @@
+v1.0.6 Only include backports if RUBY_VERSION is 1.8.x
+
+ * 'backports' pollutes too much, use sparingly
+
+v1.0.5 Minor cleanup
+
+ * Fix the InheritedConnectionError message
+
+ * Clean up the module includes
+
v1.0.3 Linux: Fix hang on reopen after fork
* Linux users relying on fork() should upgrade to 1.0.3, as it
View
4 Rakefile
@@ -104,3 +104,7 @@ task 'ctags' do
sh 'bundle-ctags'
end
+# because i'm a creature of habit
+task 'mb:test_all' => 'zk:test_all'
+
+
View
12 ext/c_zookeeper.rb
@@ -1,3 +1,4 @@
+require_relative '../lib/zookeeper/logger'
require_relative '../lib/zookeeper/common'
require_relative '../lib/zookeeper/constants'
require_relative 'zookeeper_c'
@@ -7,9 +8,10 @@
module Zookeeper
# NOTE: this class extending (opening) the class defined in zkrb.c
class CZookeeper
- include Zookeeper::Forked
- include Zookeeper::Constants
- include Zookeeper::Exceptions
+ include Forked
+ include Constants
+ include Exceptions
+ include Logger
DEFAULT_SESSION_TIMEOUT_MSEC = 10000
@@ -265,10 +267,6 @@ def stop_event_thread!
end
end
- def logger
- Zookeeper.logger
- end
-
# called by underlying C code to signal we're running
def zkc_set_running_and_notify!
logger.debug { "#{self.class}##{__method__}" }
View
16 ext/zookeeper_base.rb
@@ -8,12 +8,13 @@
module Zookeeper
class ZookeeperBase
extend Forwardable
- include Zookeeper::Forked
- include Zookeeper::Common # XXX: clean this up, no need to include *everything*
- include Zookeeper::Callbacks
- include Zookeeper::Constants
- include Zookeeper::Exceptions
- include Zookeeper::ACLs
+ include Forked
+ include Common # XXX: clean this up, no need to include *everything*
+ include Callbacks
+ include Constants
+ include Exceptions
+ include ACLs
+ include Logger
attr_accessor :original_pid
@@ -143,7 +144,8 @@ def assert_open
raise Exceptions::NotConnected unless connected?
if forked?
raise InheritedConnectionError, <<-EOS.gsub(/(?:^|\n)\s*/, ' ').strip
- You tried to use a connection inherited from another process [#{@pid}]
+ You tried to use a connection inherited from another process
+ (original pid: #{original_pid}, your pid: #{Process.pid})
You need to call reopen() after forking
EOS
end
View
18 java/java_base.rb
@@ -16,11 +16,12 @@ module Zookeeper
# subclassed by the top-level Zookeeper class
class JavaBase
include Java
- include Zookeeper::Common
- include Zookeeper::Constants
- include Zookeeper::Callbacks
- include Zookeeper::Exceptions
- include Zookeeper::ACLs
+ include Common
+ include Constants
+ include Callbacks
+ include Exceptions
+ include ACLs
+ include Logger
JZK = org.apache.zookeeper
JZKD = org.apache.zookeeper.data
@@ -64,16 +65,13 @@ def to_hash
# @private
module JavaCB
class Callback
+ include Logger
+
attr_reader :req_id
def initialize(req_id)
@req_id = req_id
end
-
- protected
- def logger
- Zookeeper.logger
- end
end
class DataCallback < Callback
View
7 lib/zookeeper.rb
@@ -11,11 +11,10 @@ module Zookeeper
require File.expand_path('../zookeeper/core_ext', __FILE__)
-silence_warnings do
- require 'backports'
-end
+require 'backports' if RUBY_VERSION =~ /\A1\.8\./
require_relative 'zookeeper/monitor'
+require_relative 'zookeeper/logger'
require_relative 'zookeeper/forked'
require_relative 'zookeeper/latch'
require_relative 'zookeeper/acls'
@@ -35,7 +34,7 @@ module Zookeeper
include Constants
unless defined?(@@logger)
- @@logger = Logger.new($stderr).tap { |l| l.level = ENV['ZOOKEEPER_DEBUG'] ? Logger::DEBUG : Logger::ERROR }
+ @@logger = ::Logger.new($stderr).tap { |l| l.level = ENV['ZOOKEEPER_DEBUG'] ? ::Logger::DEBUG : ::Logger::ERROR }
end
def self.logger
View
5 lib/zookeeper/client_methods.rb
@@ -2,6 +2,7 @@ module Zookeeper
module ClientMethods
include Constants
include ACLs
+ include Logger
def reopen(timeout=10, watcher=nil)
warn "WARN: ZookeeperBase#reopen watcher argument is now ignored" if watcher
@@ -208,10 +209,6 @@ def get_default_global_watcher
super
end
- def logger
- Zookeeper.logger
- end
-
def assert_valid_data_size!(data)
return if data.nil?
View
5 lib/zookeeper/common/queue_with_pipe.rb
@@ -3,6 +3,7 @@ module Common
# Ceci n'est pas une pipe
class QueueWithPipe
extend Forwardable
+ include Logger
def_delegators :@queue, :clear
@@ -65,10 +66,6 @@ def closed?
def clear_reads_on_pop?
@clear_reads_on_pop
end
-
- def logger
- Zookeeper.logger
- end
end
end
end
View
22 lib/zookeeper/logger.rb
@@ -0,0 +1,22 @@
+module Zookeeper
+ module Logger
+ def self.included(mod)
+ mod.extend(self)
+ end
+
+ def self.const_missing(sym)
+ return ::Logger.const_get(sym) if ::Logger.const_defined?(sym)
+ super
+ end
+
+ def self.new(*a, &b)
+ ::Logger.new(*a, &b)
+ end
+
+ private
+ def logger
+ ::Zookeeper.logger
+ end
+ end
+end
+
View
2  lib/zookeeper/version.rb
@@ -1,4 +1,4 @@
module Zookeeper
- VERSION = '1.0.4'
+ VERSION = '1.0.6'
DRIVER_VERSION = '3.3.5'
end
View
19 spec/ext/zookeeper_base_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+unless defined?(::JRUBY_VERSION)
+ describe Zookeeper::ZookeeperBase do
+ before do
+ @zk = described_class.new(Zookeeper.default_cnx_str)
+ end
+
+ after do
+ @zk.close unless @zk.closed?
+ end
+
+ it %[should have an original_pid assigned] do
+ @zk.original_pid.should == Process.pid
+ end
+ end
+end
+
+
View
5 spec/support/zookeeper_spec_helpers.rb
@@ -2,10 +2,7 @@ module Zookeeper
module SpecHeleprs
class TimeoutError < StandardError; end
include Zookeeper::Constants
-
- def logger
- Zookeeper.logger
- end
+ include Zookeeper::Logger
def ensure_node(zk, path, data)
return if zk.closed?

0 comments on commit 524fc12

Please sign in to comment.
Something went wrong with that request. Please try again.