zookeeper 1.4.4-java → 1.4.6-java

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.
@@ -26,11 +26,11 @@ module ACLs
26
26
  end
27
27
 
28
28
  module Constants
29
- ZOO_PERM_READ = 0
30
- ZOO_PERM_WRITE = 1
31
- ZOO_PERM_CREATE = 2
32
- ZOO_PERM_DELETE = 4
33
- ZOO_PERM_ADMIN = 8
29
+ ZOO_PERM_READ = 1 << 0
30
+ ZOO_PERM_WRITE = 1 << 1
31
+ ZOO_PERM_CREATE = 1 << 2
32
+ ZOO_PERM_DELETE = 1 << 3
33
+ ZOO_PERM_ADMIN = 1 << 4
34
34
  ZOO_PERM_ALL = ZOO_PERM_READ | ZOO_PERM_WRITE | ZOO_PERM_CREATE | ZOO_PERM_DELETE | ZOO_PERM_ADMIN
35
35
 
36
36
  ZOO_ANYONE_ID_UNSAFE = Id.new(:scheme => "world", :id => "anyone")
@@ -9,12 +9,12 @@ module ClientMethods
9
9
  def_delegators :@req_registry, :setup_call
10
10
  private :setup_call
11
11
 
12
- def reopen(timeout=10, watcher=nil)
12
+ def reopen(timeout=10, watcher=nil, opts = {})
13
13
  warn "WARN: ZookeeperBase#reopen watcher argument is now ignored" if watcher
14
14
  super
15
15
  end
16
16
 
17
- def initialize(host, timeout=10, watcher=nil)
17
+ def initialize(host, timeout=10, watcher=nil, opts = {})
18
18
  super
19
19
  end
20
20
 
@@ -1,4 +1,4 @@
1
1
  module Zookeeper
2
- VERSION = '1.4.4'
3
- DRIVER_VERSION = '3.3.5'
2
+ VERSION = '1.4.6'
3
+ DRIVER_VERSION = '3.4.5'
4
4
  end
@@ -441,6 +441,35 @@ shared_examples_for "connection" do
441
441
  end
442
442
  end
443
443
 
444
+ describe :child_watcher_behavior do
445
+ describe :async_watch, :async => true do
446
+ it_should_behave_like "all success return values"
447
+
448
+ before do
449
+ @watcher = Zookeeper::Callbacks::WatcherCallback.new
450
+ @cb = Zookeeper::Callbacks::StringsCallback.new
451
+
452
+ @rv = zk.get_children(:path => path, :watcher => @watcher, :watcher_context => path, :callback => @cb, :callback_context => path)
453
+ wait_until { @cb.completed? }
454
+ @cb.should be_completed
455
+ end
456
+
457
+ it %[should fire the watcher when the node has been deleted] do
458
+ @watcher.should_not be_completed
459
+
460
+ zk.delete(:path => path)[:rc].should == Zookeeper::ZOK
461
+
462
+ wait_until { @watcher.completed? }
463
+ @watcher.should be_completed
464
+
465
+ @watcher.path.should == path
466
+ @watcher.context.should == path
467
+ @watcher.type.should == Zookeeper::ZOO_DELETED_EVENT
468
+ end
469
+ end
470
+ end
471
+
472
+
444
473
  # NOTE: the jruby version of stat on non-existent node will have a
445
474
  # return_code of 0, but the C version will have a return_code of -101
446
475
  describe :stat do
@@ -5,7 +5,7 @@ module RSpec
5
5
  module Formatters
6
6
  class ProgressFormatter
7
7
  def example_started(example)
8
- SpecGlobalLogger.logger << yellow("\n=====<([ #{example.full_description} ])>=====\n")
8
+ SpecGlobalLogger.logger << pending_color("\n=====<([ #{example.full_description} ])>=====\n")
9
9
  super(example)
10
10
  end
11
11
  end
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ awk '{ if (prev == $0) count++; else { if (count > 0) { print " --- Line repeated " count " times --- " } print; prev = $0; count = 0 } }' $*
@@ -0,0 +1,194 @@
1
+ require 'zookeeper'
2
+ require 'zk-server'
3
+ require 'fileutils'
4
+ require 'tmpdir'
5
+
6
+ SLEEP_TIME = 30
7
+ STDOUT.sync = true
8
+
9
+ if ENV['DEBUG']
10
+ def zookeeper_logger(from)
11
+ l = Logger.new(STDOUT)
12
+ l.formatter = proc do |sev, time, c, msg|
13
+ "t=#{time.to_i} from=#{from} level=#{sev.downcase} message=#{msg.inspect}\n"
14
+ end
15
+ l
16
+ end
17
+
18
+ Zookeeper.logger = zookeeper_logger('zookeeper')
19
+ Zookeeper.set_debug_level(Zookeeper::ZOO_LOG_LEVEL_DEBUG)
20
+ end
21
+
22
+ class Worker
23
+ def initialize(body = nil, &block)
24
+ raise ArgumentError, "Cannot include both body and block" if body && block
25
+ @body = body || block
26
+ end
27
+
28
+ def body
29
+ @body || method(:call)
30
+ end
31
+
32
+ def start
33
+ @thread = Thread.new do
34
+ Thread.current.abort_on_exception = true
35
+ body.call
36
+ end
37
+ end
38
+
39
+ def stop
40
+ if @thread
41
+ @thread.kill
42
+ @thread = nil
43
+ end
44
+ end
45
+
46
+ def join
47
+ if @thread
48
+ @thread.join
49
+ end
50
+ end
51
+ end
52
+
53
+
54
+
55
+ base_dir = Dir.mktmpdir('zk-server-cluster')
56
+ num_cluster = 3
57
+ cluster = ZK::Server::Cluster.new(num_cluster, :base_dir => base_dir)
58
+
59
+ class Reader < Worker
60
+ attr_reader :client
61
+
62
+ def initialize(zookeeper_hosts)
63
+ @zookeeper_hosts = zookeeper_hosts
64
+ @log_from = :reader
65
+ end
66
+
67
+ def call
68
+ @client = Zookeeper.new(@zookeeper_hosts, 10, method(:watcher))
69
+ client.wait_until_connected
70
+
71
+ client.create(:path => "/test", :data => '') rescue client.set(:path => "/test", :data => '')
72
+
73
+ while true
74
+ error = nil
75
+ t = Benchmark.realtime do
76
+ begin
77
+ client.get(:path => "/test")
78
+ rescue => e
79
+ error = e
80
+ end
81
+ end
82
+
83
+ msg = "host=#{client.connected_host || 'nil'} session_id=#{client.session_id} state=#{client.state_by_value(client.state)} time=#{"%0.4f" % t}"
84
+ if error
85
+ msg << " error=#{error.class} error_message=#{error.to_s.inspect}"
86
+ msg << " closed=#{client.closed?} running=#{client.running?} shutting_down=#{client.shutting_down?}"
87
+ end
88
+
89
+ log msg
90
+
91
+ sleep 1
92
+ end
93
+ end
94
+
95
+ def log(message)
96
+ puts "t=#{Time.now.to_i} from=#{@log_from} #{message}\n"
97
+ end
98
+
99
+ def watcher(event)
100
+ if event[:state] == Zookeeper::ZOO_EXPIRED_SESSION_STATE
101
+ if client
102
+ log "action=reconnecting state=#{client.state_by_value(event[:state])} session_id=#{client.session_id}"
103
+ client.reopen
104
+ end
105
+ end
106
+
107
+ end
108
+ end
109
+
110
+ class Writer < Worker
111
+ def initialize(zookeeper_hosts)
112
+ @zookeeper_hosts = zookeeper_hosts
113
+ @log_from = :writer
114
+ end
115
+
116
+ def call
117
+ client = Zookeeper.new(@zookeeper_hosts)
118
+ client.wait_until_connected
119
+
120
+ while true
121
+ error = nil
122
+ t = Benchmark.realtime do
123
+ begin
124
+ client.create(:path => "/test", :data => '') rescue client.set(:path => "/test", :data => '')
125
+ rescue => e
126
+ error = e
127
+ end
128
+ end
129
+
130
+ msg = "host=#{client.connected_host || 'nil'} session_id=#{client.session_id} state=#{client.state_by_value(client.state)} time=#{"%0.4f" % t}"
131
+ msg << " error=#{error.class} error_message=#{error.to_s.inspect}" if error
132
+ log msg
133
+
134
+ sleep 1
135
+ end
136
+ end
137
+
138
+ def log(message)
139
+ puts "t=#{Time.now.to_i} from=#{@log_from} #{message}\n"
140
+ end
141
+ end
142
+
143
+ class ZooMonkey < Worker
144
+ attr_reader :cluster
145
+
146
+ def initialize(cluster)
147
+ @cluster = cluster
148
+ @log_from = :server
149
+ end
150
+
151
+ def call
152
+ while true
153
+ sleep SLEEP_TIME
154
+
155
+ cluster.processes.each do |server|
156
+ host = "127.0.0.1:#{server.client_port}"
157
+ log "host=#{host} pid=#{server.pid} action=pausing"
158
+ server.kill "STOP"
159
+ sleep SLEEP_TIME
160
+
161
+ log "host=#{host} pid=#{server.pid} action=resuming"
162
+ server.kill "CONT"
163
+ sleep SLEEP_TIME
164
+ end
165
+ end
166
+ end
167
+
168
+ def log(message)
169
+ puts "t=#{Time.now.to_i} from=#{@log_from} #{message}\n"
170
+ end
171
+ end
172
+
173
+ begin
174
+ cluster.run
175
+
176
+ zookeeper_hosts = cluster.processes.map { |p| "127.0.0.1:#{p.client_port}" }
177
+ zookeeper_spec = (zookeeper_hosts * 2).join(',')
178
+
179
+ reader = Reader.new(zookeeper_spec)
180
+ reader.start
181
+
182
+ # writer = Writer.new(zookeeper_spec)
183
+ # writer.start
184
+
185
+ monkey = ZooMonkey.new(cluster)
186
+ monkey.start
187
+
188
+ reader.join
189
+ writer.join
190
+ monkey.join
191
+ ensure
192
+ cluster.clobber!
193
+ FileUtils.remove_entry(base_dir)
194
+ end
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: zookeeper
3
- version: !ruby/object:Gem::Version
4
- hash: 15
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.6
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 4
9
- - 4
10
- version: 1.4.4
11
6
  platform: java
12
- authors:
7
+ authors:
13
8
  - Phillip Pearson
14
9
  - Eric Maland
15
10
  - Evan Weaver
@@ -19,58 +14,61 @@ authors:
19
14
  autorequire:
20
15
  bindir: bin
21
16
  cert_chain: []
22
-
23
- date: 2013-04-27 00:00:00 Z
24
- dependencies:
25
- - !ruby/object:Gem::Dependency
17
+ date: 2013-09-09 00:00:00.000000000 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
26
20
  name: slyphon-log4j
27
- prerelease: false
28
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ requirement: !ruby/object:Gem::Requirement
29
22
  none: false
30
- requirements:
31
- - - "="
32
- - !ruby/object:Gem::Version
33
- hash: 1
34
- segments:
35
- - 1
36
- - 2
37
- - 15
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
38
26
  version: 1.2.15
39
27
  type: :runtime
40
- version_requirements: *id001
41
- - !ruby/object:Gem::Dependency
42
- name: slyphon-zookeeper_jar
43
28
  prerelease: false
44
- requirement: &id002 !ruby/object:Gem::Requirement
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - '='
33
+ - !ruby/object:Gem::Version
34
+ version: 1.2.15
35
+ - !ruby/object:Gem::Dependency
36
+ name: slyphon-zookeeper_jar
37
+ requirement: !ruby/object:Gem::Requirement
45
38
  none: false
46
- requirements:
47
- - - "="
48
- - !ruby/object:Gem::Version
49
- hash: 1
50
- segments:
51
- - 3
52
- - 3
53
- - 5
39
+ requirements:
40
+ - - '='
41
+ - !ruby/object:Gem::Version
54
42
  version: 3.3.5
55
43
  type: :runtime
56
- version_requirements: *id002
57
- description: |+
58
- A low-level multi-Ruby wrapper around the ZooKeeper API bindings. For a
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - '='
49
+ - !ruby/object:Gem::Version
50
+ version: 3.3.5
51
+ description: ! 'A low-level multi-Ruby wrapper around the ZooKeeper API bindings.
52
+ For a
53
+
59
54
  friendlier interface, see http://github.com/slyphon/zk. Currently supported:
55
+
60
56
  MRI: {1.8.7, 1.9.2, 1.9.3}, JRuby: ~> 1.6.7, Rubinius: 2.0.testing, REE 1.8.7.
61
-
62
- This library uses version 3.3.5 of zookeeper bindings.
63
-
64
- email:
57
+
58
+
59
+ This library uses version 3.4.5 of zookeeper bindings.
60
+
61
+
62
+ '
63
+ email:
65
64
  - slyphon@gmail.com
66
65
  executables: []
67
-
68
66
  extensions: []
69
-
70
67
  extra_rdoc_files: []
71
-
72
- files:
68
+ files:
73
69
  - .ctags_paths
70
+ - .dotfiles/ruby-gemset
71
+ - .dotfiles/ruby-version
74
72
  - .dotfiles/rvmrc
75
73
  - .gitignore
76
74
  - .gitmodules
@@ -93,8 +91,9 @@ files:
93
91
  - ext/event_lib.h
94
92
  - ext/extconf.rb
95
93
  - ext/generate_gvl_code.rb
96
- - ext/patch-zookeeper
97
- - ext/zkc-3.3.5.tar.gz
94
+ - ext/patches/zkc-3.3.5-network.patch
95
+ - ext/patches/zkc-3.4.5-logging.patch
96
+ - ext/zkc-3.4.5.tar.gz
98
97
  - ext/zkrb.c
99
98
  - ext/zkrb_wrapper.c
100
99
  - ext/zkrb_wrapper.h
@@ -144,41 +143,34 @@ files:
144
143
  - spec/support/zookeeper_spec_helpers.rb
145
144
  - spec/zookeeper_spec.rb
146
145
  - zookeeper.gemspec
146
+ - zoomonkey/duplicates
147
+ - zoomonkey/zoomonkey.rb
147
148
  homepage: https://github.com/slyphon/zookeeper
148
149
  licenses: []
149
-
150
150
  post_install_message:
151
151
  rdoc_options: []
152
-
153
- require_paths:
152
+ require_paths:
154
153
  - lib
155
154
  - java
156
- required_ruby_version: !ruby/object:Gem::Requirement
155
+ required_ruby_version: !ruby/object:Gem::Requirement
157
156
  none: false
158
- requirements:
159
- - - ">="
160
- - !ruby/object:Gem::Version
161
- hash: 3
162
- segments:
163
- - 0
164
- version: "0"
165
- required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
162
  none: false
167
- requirements:
168
- - - ">="
169
- - !ruby/object:Gem::Version
170
- hash: 3
171
- segments:
172
- - 0
173
- version: "0"
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
174
167
  requirements: []
175
-
176
168
  rubyforge_project:
177
169
  rubygems_version: 1.8.25
178
170
  signing_key:
179
171
  specification_version: 3
180
172
  summary: Apache ZooKeeper driver for Rubies
181
- test_files:
173
+ test_files:
182
174
  - spec/c_zookeeper_spec.rb
183
175
  - spec/chrooted_connection_spec.rb
184
176
  - spec/compatibilty_spec.rb
@@ -196,3 +188,4 @@ test_files:
196
188
  - spec/support/progress_formatter.rb
197
189
  - spec/support/zookeeper_spec_helpers.rb
198
190
  - spec/zookeeper_spec.rb
191
+ has_rdoc: