zookeeper 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.ctags_paths ADDED
@@ -0,0 +1 @@
1
+ ~/vendor/ruby/*.{c,h}
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ v1.0.5 Minor cleanup
2
+
3
+ * Fix the InheritedConnectionError message
4
+
5
+ * Clean up the module includes
6
+
1
7
  v1.0.3 Linux: Fix hang on reopen after fork
2
8
 
3
9
  * Linux users relying on fork() should upgrade to 1.0.3, as it
data/Rakefile CHANGED
@@ -100,3 +100,6 @@ end
100
100
 
101
101
  task 'spec:run' => 'build:clean' unless defined?(::JRUBY_VERSION)
102
102
 
103
+ # because i'm a creature of habit
104
+ task 'mb:test_all' => 'zk:test_all'
105
+
data/ext/c_zookeeper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require_relative '../lib/zookeeper/logger'
1
2
  require_relative '../lib/zookeeper/common'
2
3
  require_relative '../lib/zookeeper/constants'
3
4
  require_relative 'zookeeper_c'
@@ -8,9 +9,10 @@ require_relative 'zookeeper_c'
8
9
  # when we're garbage collected
9
10
  module Zookeeper
10
11
  class CZookeeper
11
- include Zookeeper::Forked
12
- include Zookeeper::Constants
13
- include Zookeeper::Exceptions
12
+ include Forked
13
+ include Constants
14
+ include Exceptions
15
+ include Logger
14
16
 
15
17
  DEFAULT_SESSION_TIMEOUT_MSEC = 10000
16
18
 
@@ -223,10 +225,6 @@ class CZookeeper
223
225
  end
224
226
  end
225
227
 
226
- def logger
227
- Zookeeper.logger
228
- end
229
-
230
228
  # called by underlying C code to signal we're running
231
229
  def zkc_set_running_and_notify!
232
230
  logger.debug { "#{self.class}##{__method__}" }
@@ -8,12 +8,13 @@ require 'forwardable'
8
8
  module Zookeeper
9
9
  class ZookeeperBase
10
10
  extend Forwardable
11
- include Zookeeper::Forked
12
- include Zookeeper::Common # XXX: clean this up, no need to include *everything*
13
- include Zookeeper::Callbacks
14
- include Zookeeper::Constants
15
- include Zookeeper::Exceptions
16
- include Zookeeper::ACLs
11
+ include Forked
12
+ include Common # XXX: clean this up, no need to include *everything*
13
+ include Callbacks
14
+ include Constants
15
+ include Exceptions
16
+ include ACLs
17
+ include Logger
17
18
 
18
19
  attr_accessor :original_pid
19
20
 
@@ -143,7 +144,8 @@ class ZookeeperBase
143
144
  raise Exceptions::NotConnected unless connected?
144
145
  if forked?
145
146
  raise InheritedConnectionError, <<-EOS.gsub(/(?:^|\n)\s*/, ' ').strip
146
- You tried to use a connection inherited from another process [#{@pid}]
147
+ You tried to use a connection inherited from another process
148
+ (original pid: #{original_pid}, your pid: #{Process.pid})
147
149
  You need to call reopen() after forking
148
150
  EOS
149
151
  end
data/ext/zookeeper_lib.c CHANGED
@@ -64,7 +64,7 @@ void atfork_child() {
64
64
  // set up handlers to make sure the thread being forked holds the lock at the
65
65
  // time the process is copied, then immediately unlock the mutex in both parent
66
66
  // and children
67
- pthread_atfork(atfork_prepare, atfork_parent, atfork_child);
67
+ /*pthread_atfork(atfork_prepare, atfork_parent, atfork_child);*/
68
68
 
69
69
 
70
70
  void zkrb_enqueue(zkrb_queue_t *q, zkrb_event_t *elt) {
data/java/java_base.rb CHANGED
@@ -16,11 +16,12 @@ module Zookeeper
16
16
  # subclassed by the top-level Zookeeper class
17
17
  class JavaBase
18
18
  include Java
19
- include Zookeeper::Common
20
- include Zookeeper::Constants
21
- include Zookeeper::Callbacks
22
- include Zookeeper::Exceptions
23
- include Zookeeper::ACLs
19
+ include Common
20
+ include Constants
21
+ include Callbacks
22
+ include Exceptions
23
+ include ACLs
24
+ include Logger
24
25
 
25
26
  JZK = org.apache.zookeeper
26
27
  JZKD = org.apache.zookeeper.data
@@ -64,16 +65,13 @@ class JavaBase
64
65
  # @private
65
66
  module JavaCB
66
67
  class Callback
68
+ include Logger
69
+
67
70
  attr_reader :req_id
68
71
 
69
72
  def initialize(req_id)
70
73
  @req_id = req_id
71
74
  end
72
-
73
- protected
74
- def logger
75
- Zookeeper.logger
76
- end
77
75
  end
78
76
 
79
77
  class DataCallback < Callback
data/lib/zookeeper.rb CHANGED
@@ -15,6 +15,7 @@ silence_warnings do
15
15
  require 'backports'
16
16
  end
17
17
 
18
+ require_relative 'zookeeper/logger'
18
19
  require_relative 'zookeeper/forked'
19
20
  require_relative 'zookeeper/latch'
20
21
  require_relative 'zookeeper/acls'
@@ -33,7 +34,7 @@ module Zookeeper
33
34
  include Constants
34
35
 
35
36
  unless defined?(@@logger)
36
- @@logger = Logger.new($stderr).tap { |l| l.level = ENV['ZOOKEEPER_DEBUG'] ? Logger::DEBUG : Logger::ERROR }
37
+ @@logger = ::Logger.new($stderr).tap { |l| l.level = ENV['ZOOKEEPER_DEBUG'] ? ::Logger::DEBUG : ::Logger::ERROR }
37
38
  end
38
39
 
39
40
  def self.logger
@@ -2,6 +2,7 @@ module Zookeeper
2
2
  module ClientMethods
3
3
  include Constants
4
4
  include ACLs
5
+ include Logger
5
6
 
6
7
  def reopen(timeout=10, watcher=nil)
7
8
  warn "WARN: ZookeeperBase#reopen watcher argument is now ignored" if watcher
@@ -208,10 +209,6 @@ protected
208
209
  super
209
210
  end
210
211
 
211
- def logger
212
- Zookeeper.logger
213
- end
214
-
215
212
  def assert_valid_data_size!(data)
216
213
  return if data.nil?
217
214
 
@@ -3,6 +3,7 @@ module Common
3
3
  # Ceci n'est pas une pipe
4
4
  class QueueWithPipe
5
5
  extend Forwardable
6
+ include Logger
6
7
 
7
8
  def_delegators :@queue, :clear
8
9
 
@@ -65,10 +66,6 @@ module Common
65
66
  def clear_reads_on_pop?
66
67
  @clear_reads_on_pop
67
68
  end
68
-
69
- def logger
70
- Zookeeper.logger
71
- end
72
69
  end
73
70
  end
74
71
  end
@@ -0,0 +1,22 @@
1
+ module Zookeeper
2
+ module Logger
3
+ def self.included(mod)
4
+ mod.extend(self)
5
+ end
6
+
7
+ def self.const_missing(sym)
8
+ return ::Logger.const_get(sym) if ::Logger.const_defined?(sym)
9
+ super
10
+ end
11
+
12
+ def self.new(*a, &b)
13
+ ::Logger.new(*a, &b)
14
+ end
15
+
16
+ private
17
+ def logger
18
+ ::Zookeeper.logger
19
+ end
20
+ end
21
+ end
22
+
@@ -1,4 +1,4 @@
1
1
  module Zookeeper
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  DRIVER_VERSION = '3.3.5'
4
4
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ unless defined?(::JRUBY_VERSION)
4
+ describe Zookeeper::ZookeeperBase do
5
+ before do
6
+ @zk = described_class.new(Zookeeper.default_cnx_str)
7
+ end
8
+
9
+ after do
10
+ @zk.close unless @zk.closed?
11
+ end
12
+
13
+ it %[should have an original_pid assigned] do
14
+ @zk.original_pid.should == Process.pid
15
+ end
16
+ end
17
+ end
18
+
19
+
@@ -2,10 +2,7 @@ module Zookeeper
2
2
  module SpecHeleprs
3
3
  class TimeoutError < StandardError; end
4
4
  include Zookeeper::Constants
5
-
6
- def logger
7
- Zookeeper.logger
8
- end
5
+ include Zookeeper::Logger
9
6
 
10
7
  def ensure_node(zk, path, data)
11
8
  return if zk.closed?
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: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 4
10
- version: 1.0.4
9
+ - 5
10
+ version: 1.0.5
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-10 00:00:00 Z
23
+ date: 2012-05-11 00:00:00 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: backports
@@ -54,6 +54,7 @@ extensions:
54
54
  extra_rdoc_files: []
55
55
 
56
56
  files:
57
+ - .ctags_paths
57
58
  - .dotfiles/rvmrc
58
59
  - .gitignore
59
60
  - .gitmodules
@@ -95,6 +96,7 @@ files:
95
96
  - lib/zookeeper/exceptions.rb
96
97
  - lib/zookeeper/forked.rb
97
98
  - lib/zookeeper/latch.rb
99
+ - lib/zookeeper/logger.rb
98
100
  - lib/zookeeper/rake_tasks.rb
99
101
  - lib/zookeeper/stat.rb
100
102
  - lib/zookeeper/version.rb
@@ -105,6 +107,7 @@ files:
105
107
  - spec/compatibilty_spec.rb
106
108
  - spec/default_watcher_spec.rb
107
109
  - spec/em_spec.rb
110
+ - spec/ext/zookeeper_base_spec.rb
108
111
  - spec/fork_hook_specs.rb
109
112
  - spec/forked_connection_spec.rb
110
113
  - spec/latch_spec.rb
@@ -157,6 +160,7 @@ test_files:
157
160
  - spec/compatibilty_spec.rb
158
161
  - spec/default_watcher_spec.rb
159
162
  - spec/em_spec.rb
163
+ - spec/ext/zookeeper_base_spec.rb
160
164
  - spec/fork_hook_specs.rb
161
165
  - spec/forked_connection_spec.rb
162
166
  - spec/latch_spec.rb