zk 1.4.0 → 1.4.1

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/Gemfile CHANGED
@@ -8,7 +8,7 @@ source :rubygems
8
8
  # keep closer track of this stuff to make bisecting easier and travis more
9
9
  # accurate
10
10
 
11
- # git 'git://github.com/slyphon/zookeeper.git', :tag => 'dev/zk/00000' do
11
+ # git 'git://github.com/slyphon/zookeeper.git', :tag => 'dev/zk/00001' do
12
12
  # gem 'zookeeper', '~> 1.0.0'
13
13
  # end
14
14
 
data/README.markdown CHANGED
@@ -66,6 +66,10 @@ In addition to all of that, I would like to think that the public API the ZK::Cl
66
66
 
67
67
  ## NEWS ##
68
68
 
69
+ ### v1.4.1 ###
70
+
71
+ * All users of resque or other libraries that depend on `fork()` are encouraged to upgrade immediately. This version of ZK features the `zookeeper-1.1.0` gem with a completely rewritten backend that provides true fork safety. The rules still apply (you must call `#reopen` on your client as soon as possible in the child process) but you can be assured a much more stable experience.
72
+
69
73
  ### v1.4.0 ###
70
74
 
71
75
  * Added a new `:ignore` option for convenience when you don't care if an operation fails. In the case of a failure, the method will return nil instead of raising an exception. This option works for `children`, `create`, `delete`, `get`, `get_acl`, `set`, and `set_acl`. `stat` will ignore the option (because it doesn't care about the state of a node).
data/RELEASES.markdown CHANGED
@@ -1,5 +1,10 @@
1
1
  This file notes feature differences and bugfixes contained between releases.
2
2
 
3
+ ### v1.4.1 ###
4
+
5
+ * True fork safety! The `zookeeper` at 1.1.0 is finally fork-safe. You can now use ZK in whatever forking library you want. Just remember to call `#reopen` on your client instance in the child process before attempting any opersations.
6
+
7
+
3
8
  ### v1.4.0 ###
4
9
 
5
10
  * Added a new `:ignore` option for convenience when you don't care if an operation fails. In the case of a failure, the method will return nil instead of raising an exception. This option works for `children`, `create`, `delete`, `get`, `get_acl`, `set`, and `set_acl`. `stat` will ignore the option (because it doesn't care about the state of a node).
data/lib/zk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ZK
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -32,6 +32,14 @@ RSpec.configure do |config|
32
32
  config.extend(mod)
33
33
  end
34
34
 
35
+ if ZK.rubinius?
36
+ config.filter_run_excluding :rbx => :broken
37
+ end
38
+
39
+ if ZK.jruby?
40
+ config.filter_run_excluding :fork_required => true
41
+ end
42
+
35
43
  if ZK.spawn_zookeeper?
36
44
  require 'zk-server'
37
45
 
@@ -32,158 +32,153 @@ describe ZK::Client::Threaded do
32
32
  end
33
33
  end
34
34
 
35
- unless defined?(::JRUBY_VERSION)
36
- describe :forked do
37
- include_context 'connection opts'
35
+ describe :forked, :fork_required => true, :rbx => :broken do
36
+ include_context 'connection opts'
38
37
 
39
- before do
40
- @base_path = '/zktests'
41
- @pids_root = "#{@base_path}/pid"
38
+ before do
39
+ @base_path = '/zktests'
40
+ @pids_root = "#{@base_path}/pid"
42
41
 
43
- ZK.open(*connection_args) do |z|
44
- z.rm_rf(@base_path)
45
- z.mkdir_p(@pids_root)
46
- end
42
+ ZK.open(*connection_args) do |z|
43
+ z.rm_rf(@base_path)
44
+ z.mkdir_p(@pids_root)
47
45
  end
46
+ end
48
47
 
49
- after do
50
- if @pid
51
- begin
52
- Process.kill('TERM', @pid)
53
- pid, st = Process.wait2(@pid)
54
- logger.debug { "child #{@pid} exited with status: #{st.inspect}" }
55
- rescue Errno::ESRCH
56
- end
48
+ after do
49
+ if @pid
50
+ begin
51
+ Process.kill('TERM', @pid)
52
+ pid, st = Process.wait2(@pid)
53
+ logger.debug { "child #{@pid} exited with status: #{st.inspect}" }
54
+ rescue Errno::ESRCH
57
55
  end
58
-
59
- @zk.close! if @zk
60
- ZK.open(*connection_args) { |z| z.rm_rf(@base_path) }
61
56
  end
62
57
 
63
- it %[should deliver callbacks in the child], :fork => true do
64
- # pending_in_travis "skip this test, flaky in travis"
65
- pending_rbx('fails in rubinius')
66
-
67
- logger.debug { "Process.pid of parent: #{Process.pid}" }
68
-
69
- @zk = ZK.new do |z|
70
- z.on_connected do
71
- logger.debug { "on_connected fired, writing pid to path #{@pids_root}/#{$$}" }
72
- begin
73
- z.create("#{@pids_root}/#{Process.pid}", Process.pid.to_s)
74
- rescue ZK::Exceptions::NodeExists
75
- end
58
+ @zk.close! if @zk
59
+ ZK.open(*connection_args) { |z| z.rm_rf(@base_path) }
60
+ end
61
+
62
+ it %[should deliver callbacks in the child], :fork => true do
63
+ logger.debug { "Process.pid of parent: #{Process.pid}" }
64
+
65
+ @zk = ZK.new do |z|
66
+ z.on_connected do
67
+ logger.debug { "on_connected fired, writing pid to path #{@pids_root}/#{$$}" }
68
+ begin
69
+ z.create("#{@pids_root}/#{Process.pid}", Process.pid.to_s)
70
+ rescue ZK::Exceptions::NodeExists
76
71
  end
77
72
  end
73
+ end
78
74
 
79
- @parent_pid = $$
80
-
81
- @zk.create("#{@pids_root}/#{$$}", $$.to_s)
75
+ @parent_pid = $$
76
+
77
+ @zk.create("#{@pids_root}/#{$$}", $$.to_s)
82
78
 
83
- event_catcher = EventCatcher.new
79
+ event_catcher = EventCatcher.new
84
80
 
85
- @zk.register(@pids_root) do |event|
86
- if event.node_child?
87
- event_catcher << event
88
- else
89
- @zk.children(@pids_root, :watch => true)
90
- end
81
+ @zk.register(@pids_root) do |event|
82
+ if event.node_child?
83
+ event_catcher << event
84
+ else
85
+ @zk.children(@pids_root, :watch => true)
91
86
  end
87
+ end
92
88
 
93
- logger.debug { "parent watching for children on #{@pids_root}" }
94
- @zk.children(@pids_root, :watch => true) # side-effect, register watch
89
+ logger.debug { "parent watching for children on #{@pids_root}" }
90
+ @zk.children(@pids_root, :watch => true) # side-effect, register watch
95
91
 
96
- @pid = fork do
97
- @zk.reopen
98
- @zk.wait_until_connected
92
+ @pid = fork do
93
+ @zk.reopen
94
+ @zk.wait_until_connected
99
95
 
100
- child_pid_path = "#{@pids_root}/#{$$}"
96
+ child_pid_path = "#{@pids_root}/#{$$}"
101
97
 
102
- create_latch = Zookeeper::Latch.new
98
+ create_latch = Zookeeper::Latch.new
103
99
 
104
- create_sub = @zk.register(child_pid_path) do |event|
105
- if event.node_created?
106
- logger.debug { "got created event, releasing create_latch" }
107
- create_latch.release
108
- else
109
- if @zk.exists?(child_pid_path, :watch => true)
110
- logger.debug { "created behind our backs, releasing create_latch" }
111
- create_latch.release
112
- end
100
+ create_sub = @zk.register(child_pid_path) do |event|
101
+ if event.node_created?
102
+ logger.debug { "got created event, releasing create_latch" }
103
+ create_latch.release
104
+ else
105
+ if @zk.exists?(child_pid_path, :watch => true)
106
+ logger.debug { "created behind our backs, releasing create_latch" }
107
+ create_latch.release
113
108
  end
114
109
  end
110
+ end
115
111
 
116
- if @zk.exists?(child_pid_path, :watch => true)
117
- logger.debug { "woot! #{child_pid_path} exists!" }
118
- create_sub.unregister
119
- else
120
- logger.debug { "awaiting the create_latch to release" }
121
- create_latch.await
122
- end
112
+ if @zk.exists?(child_pid_path, :watch => true)
113
+ logger.debug { "woot! #{child_pid_path} exists!" }
114
+ create_sub.unregister
115
+ else
116
+ logger.debug { "awaiting the create_latch to release" }
117
+ create_latch.await
118
+ end
123
119
 
124
- logger.debug { "now testing for delete event totally created in child" }
120
+ logger.debug { "now testing for delete event totally created in child" }
125
121
 
126
- delete_latch = Zookeeper::Latch.new
122
+ delete_latch = Zookeeper::Latch.new
127
123
 
128
- delete_event = nil
124
+ delete_event = nil
129
125
 
130
- delete_sub = @zk.register(child_pid_path) do |event|
131
- if event.node_deleted?
132
- delete_event = event
133
- logger.debug { "child got delete event on #{child_pid_path}" }
134
- delete_latch.release
135
- else
136
- unless @zk.exists?(child_pid_path, :watch => true)
137
- logger.debug { "child: someone deleted #{child_pid_path} behind our back" }
138
- delete_latch.release
139
- end
126
+ delete_sub = @zk.register(child_pid_path) do |event|
127
+ if event.node_deleted?
128
+ delete_event = event
129
+ logger.debug { "child got delete event on #{child_pid_path}" }
130
+ delete_latch.release
131
+ else
132
+ unless @zk.exists?(child_pid_path, :watch => true)
133
+ logger.debug { "child: someone deleted #{child_pid_path} behind our back" }
134
+ delete_latch.release
140
135
  end
141
136
  end
137
+ end
142
138
 
143
- @zk.exists?(child_pid_path, :watch => true)
139
+ @zk.exists?(child_pid_path, :watch => true)
144
140
 
145
- @zk.delete(child_pid_path)
141
+ @zk.delete(child_pid_path)
146
142
 
147
- logger.debug { "awaiting deletion event notification" }
148
- delete_latch.await unless delete_event
143
+ logger.debug { "awaiting deletion event notification" }
144
+ delete_latch.await unless delete_event
149
145
 
150
- logger.debug { "deletion event: #{delete_event}" }
146
+ logger.debug { "deletion event: #{delete_event}" }
151
147
 
152
- if delete_event
153
- exit! 0
154
- else
155
- exit! 1
156
- end
148
+ if delete_event
149
+ exit! 0
150
+ else
151
+ exit! 1
157
152
  end
153
+ end
158
154
 
159
- # replicates deletion watcher inside child
160
- child_pid_path = "#{@pids_root}/#{@pid}"
155
+ # replicates deletion watcher inside child
156
+ child_pid_path = "#{@pids_root}/#{@pid}"
161
157
 
162
- delete_latch = Latch.new
158
+ delete_latch = Latch.new
163
159
 
164
- delete_sub = @zk.register(child_pid_path) do |event|
165
- if event.node_deleted?
166
- logger.debug { "parent got delete event on #{child_pid_path}" }
160
+ delete_sub = @zk.register(child_pid_path) do |event|
161
+ if event.node_deleted?
162
+ logger.debug { "parent got delete event on #{child_pid_path}" }
163
+ delete_latch.release
164
+ else
165
+ unless @zk.exists?(child_pid_path, :watch => true)
166
+ logger.debug { "child: someone deleted #{child_pid_path} behind our back" }
167
167
  delete_latch.release
168
- else
169
- unless @zk.exists?(child_pid_path, :watch => true)
170
- logger.debug { "child: someone deleted #{child_pid_path} behind our back" }
171
- delete_latch.release
172
- end
173
168
  end
174
169
  end
170
+ end
175
171
 
176
- delete_latch.await if @zk.exists?(child_pid_path, :watch => true)
172
+ delete_latch.await if @zk.exists?(child_pid_path, :watch => true)
177
173
 
178
- _, stat = Process.wait2(@pid)
174
+ _, stat = Process.wait2(@pid)
179
175
 
180
- stat.should_not be_signaled
181
- stat.should be_exited
182
- stat.should be_success
176
+ stat.should_not be_signaled
177
+ stat.should be_exited
178
+ stat.should be_success
183
179
 
184
180
 
185
- end # should deliver callbacks in the child
186
- end # forked
187
- end # # jruby guard
181
+ end # should deliver callbacks in the child
182
+ end # forked
188
183
  end # ZK::Client::Threaded
189
184
 
data/spec/zk/pool_spec.rb CHANGED
@@ -155,7 +155,7 @@ describe ZK::Pool do
155
155
  # These tests are seriously yucky, but they show that when a client is !connected?
156
156
  # the pool behaves properly and will not return that client to the caller.
157
157
 
158
- describe 'health checking with disconnected client' do
158
+ describe 'health checking with disconnected client', :rbx => :broken do
159
159
  before do
160
160
  wait_until(2) { @connection_pool.available_size == 2 }
161
161
  @connection_pool.available_size.should == 2
@@ -196,7 +196,6 @@ describe ZK::Pool do
196
196
  @connections.should include(@mcnx1)
197
197
  end
198
198
  end
199
-
200
199
  end # Simple
201
200
 
202
201
  describe :Bounded do
data/zk.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{A high-level wrapper around the zookeeper driver}
13
13
  s.description = s.summary + "\n"
14
14
 
15
- s.add_runtime_dependency 'zookeeper', '~> 1.0.3'
15
+ s.add_runtime_dependency 'zookeeper', '~> 1.1.0'
16
16
  s.add_runtime_dependency 'backports', '~> 2.5.1'
17
17
 
18
18
  s.files = `git ls-files`.split("\n")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 0
10
- version: 1.4.0
9
+ - 1
10
+ version: 1.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonathan D. Simms
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-05-10 00:00:00 Z
19
+ date: 2012-05-14 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: zookeeper
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 17
29
+ hash: 19
30
30
  segments:
31
31
  - 1
32
+ - 1
32
33
  - 0
33
- - 3
34
- version: 1.0.3
34
+ version: 1.1.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency