zookeeper 0.2.2 → 0.3.0
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/CHANGELOG +3 -0
- data/Manifest +13 -1
- data/README +30 -0
- data/Rakefile +1 -1
- data/examples/cloud_config.rb +125 -0
- data/ext/zkc-3.3.1.tar.gz +0 -0
- data/ext/zookeeper_c.c +338 -393
- data/ext/zookeeper_lib.c +527 -0
- data/ext/zookeeper_lib.h +151 -0
- data/lib/zookeeper/acls.rb +31 -0
- data/lib/zookeeper/callbacks.rb +89 -0
- data/lib/zookeeper/constants.rb +54 -0
- data/lib/zookeeper/exceptions.rb +91 -0
- data/lib/zookeeper/stat.rb +12 -0
- data/lib/zookeeper.rb +207 -51
- data/test/test_basic.rb +16 -39
- data/test/test_callback1.rb +36 -0
- data/test/test_esoteric.rb +7 -0
- data/test/test_watcher1.rb +56 -0
- data/test/test_watcher2.rb +52 -0
- data/zookeeper.gemspec +6 -6
- data.tar.gz.sig +0 -0
- metadata +31 -7
- metadata.gz.sig +0 -0
- data/ext/zkc-3.2.2.tar.gz +0 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'zookeeper'
|
3
|
+
|
4
|
+
def wait_until(timeout=10, &block)
|
5
|
+
time_to_stop = Time.now + timeout
|
6
|
+
until yield do
|
7
|
+
break if Time.now > time_to_stop
|
8
|
+
sleep 0.1
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
puts 'Initializing Zookeeper'
|
13
|
+
|
14
|
+
zk = Zookeeper.new('localhost:2181')
|
15
|
+
|
16
|
+
if zk.state != Zookeeper::ZOO_CONNECTED_STATE
|
17
|
+
puts 'Unable to connect to Zookeeper!'
|
18
|
+
Kernel.exit
|
19
|
+
end
|
20
|
+
|
21
|
+
def watcher(args)
|
22
|
+
puts "#{args.inspect}"
|
23
|
+
puts "In watcher: path=#{args.path}, context=#{args.context}"
|
24
|
+
if args.path == args.context
|
25
|
+
puts "TEST PASSED IN WATCHER"
|
26
|
+
else
|
27
|
+
puts "TEST FAILED IN WATCHER"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
wcb = Zookeeper::WatcherCallback.new do
|
32
|
+
watcher(wcb)
|
33
|
+
end
|
34
|
+
|
35
|
+
resp = zk.create(:path => '/test', :sequence => true)
|
36
|
+
puts "#{resp.inspect}"
|
37
|
+
puts "TEST FAILED [create]" unless resp[:rc] == Zookeeper::ZOK
|
38
|
+
|
39
|
+
base_path = resp[:path]
|
40
|
+
watched_file = "#{base_path}/file.does.not.exist"
|
41
|
+
|
42
|
+
resp = zk.stat(:path => watched_file, :watcher => wcb, :watcher_context => watched_file)
|
43
|
+
puts "#{resp.inspect}"
|
44
|
+
puts "TEST FAILED [stat]" unless resp[:rc] == Zookeeper::ZNONODE
|
45
|
+
|
46
|
+
resp = zk.create(:path => watched_file, :data => 'test data', :ephemeral => true)
|
47
|
+
puts "#{resp.inspect}"
|
48
|
+
puts "TEST FAILED [create]" unless resp[:rc] == Zookeeper::ZOK
|
49
|
+
|
50
|
+
wait_until { wcb.completed? }
|
51
|
+
|
52
|
+
puts "TEST FAILED" unless wcb.completed?
|
53
|
+
puts "TEST PASSED"
|
54
|
+
|
55
|
+
zk.delete(:path => watched_file)
|
56
|
+
zk.delete(:path => base_path)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'zookeeper'
|
3
|
+
|
4
|
+
def wait_until(timeout=10, &block)
|
5
|
+
time_to_stop = Time.now + timeout
|
6
|
+
until yield do
|
7
|
+
break if Time.now > time_to_stop
|
8
|
+
sleep 0.1
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
puts 'Initializing Zookeeper'
|
13
|
+
|
14
|
+
zk = Zookeeper.new('localhost:2181')
|
15
|
+
|
16
|
+
if zk.state != Zookeeper::ZOO_CONNECTED_STATE
|
17
|
+
puts 'Unable to connect to Zookeeper!'
|
18
|
+
Kernel.exit
|
19
|
+
end
|
20
|
+
|
21
|
+
def watcher(args)
|
22
|
+
if args.path == args.context
|
23
|
+
puts "TEST PASSED IN WATCHER"
|
24
|
+
else
|
25
|
+
puts "TEST FAILED IN WATCHER"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
wcb = Zookeeper::WatcherCallback.new do
|
30
|
+
watcher(wcb)
|
31
|
+
end
|
32
|
+
|
33
|
+
resp = zk.create(:path => '/test', :sequence => true)
|
34
|
+
puts "#{resp.inspect}"
|
35
|
+
puts "TEST FAILED [create]" unless resp[:rc] == Zookeeper::ZOK
|
36
|
+
|
37
|
+
base_path = resp[:path]
|
38
|
+
triggering_file = "#{base_path}/file.does.not.exist"
|
39
|
+
|
40
|
+
resp = zk.get_children(:path => base_path, :watcher => wcb, :watcher_context => base_path)
|
41
|
+
puts "TEST FAILED [get_children]" unless resp[:rc] == Zookeeper::ZOK
|
42
|
+
|
43
|
+
resp = zk.create(:path => triggering_file, :data => 'test data', :ephemeral => true)
|
44
|
+
puts "TEST FAILED [create]" unless resp[:rc] == Zookeeper::ZOK
|
45
|
+
|
46
|
+
wait_until { wcb.completed? }
|
47
|
+
|
48
|
+
puts "TEST FAILED" unless wcb.completed?
|
49
|
+
puts "TEST PASSED"
|
50
|
+
|
51
|
+
zk.delete(:path => triggering_file)
|
52
|
+
zk.delete(:path => base_path)
|
data/zookeeper.gemspec
CHANGED
@@ -2,25 +2,25 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{zookeeper}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.3.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Phillip Pearson, Eric Maland, Evan Weaver"]
|
8
|
+
s.authors = ["Phillip Pearson, Eric Maland, Evan Weaver, Brian Wickman"]
|
9
9
|
s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
|
10
|
-
s.date = %q{2010-03
|
10
|
+
s.date = %q{2010-07-03}
|
11
11
|
s.description = %q{An interface to the Zookeeper distributed configuration server.}
|
12
12
|
s.email = %q{}
|
13
13
|
s.extensions = ["ext/extconf.rb"]
|
14
14
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "ext/zookeeper_c.c", "lib/zookeeper.rb"]
|
15
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "ext/extconf.rb", "ext/zkc-3.
|
15
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "examples/cloud_config.rb", "ext/extconf.rb", "ext/zkc-3.3.1.tar.gz", "ext/zookeeper_c.c", "ext/zookeeper_lib.c", "ext/zookeeper_lib.h", "lib/zookeeper.rb", "lib/zookeeper/acls.rb", "lib/zookeeper/callbacks.rb", "lib/zookeeper/constants.rb", "lib/zookeeper/exceptions.rb", "lib/zookeeper/stat.rb", "test/test_basic.rb", "test/test_callback1.rb", "test/test_esoteric.rb", "test/test_watcher1.rb", "test/test_watcher2.rb", "zookeeper.gemspec"]
|
16
16
|
s.homepage = %q{http://blog.evanweaver.com/files/doc/fauna/zookeeper/}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Zookeeper", "--main", "README"]
|
18
18
|
s.require_paths = ["lib", "ext"]
|
19
19
|
s.rubyforge_project = %q{fauna}
|
20
|
-
s.rubygems_version = %q{1.3.
|
20
|
+
s.rubygems_version = %q{1.3.6}
|
21
21
|
s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem}
|
22
22
|
s.summary = %q{An interface to the Zookeeper distributed configuration server.}
|
23
|
-
s.test_files = ["test/test_basic.rb"]
|
23
|
+
s.test_files = ["test/test_basic.rb", "test/test_callback1.rb", "test/test_esoteric.rb", "test/test_watcher1.rb", "test/test_watcher2.rb"]
|
24
24
|
|
25
25
|
if s.respond_to? :specification_version then
|
26
26
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zookeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
|
-
- Phillip Pearson, Eric Maland, Evan Weaver
|
12
|
+
- Phillip Pearson, Eric Maland, Evan Weaver, Brian Wickman
|
8
13
|
autorequire:
|
9
14
|
bindir: bin
|
10
15
|
cert_chain:
|
@@ -30,7 +35,7 @@ cert_chain:
|
|
30
35
|
yZ0=
|
31
36
|
-----END CERTIFICATE-----
|
32
37
|
|
33
|
-
date: 2010-03
|
38
|
+
date: 2010-07-03 00:00:00 -07:00
|
34
39
|
default_executable:
|
35
40
|
dependencies: []
|
36
41
|
|
@@ -52,11 +57,23 @@ files:
|
|
52
57
|
- Manifest
|
53
58
|
- README
|
54
59
|
- Rakefile
|
60
|
+
- examples/cloud_config.rb
|
55
61
|
- ext/extconf.rb
|
56
|
-
- ext/zkc-3.
|
62
|
+
- ext/zkc-3.3.1.tar.gz
|
57
63
|
- ext/zookeeper_c.c
|
64
|
+
- ext/zookeeper_lib.c
|
65
|
+
- ext/zookeeper_lib.h
|
58
66
|
- lib/zookeeper.rb
|
67
|
+
- lib/zookeeper/acls.rb
|
68
|
+
- lib/zookeeper/callbacks.rb
|
69
|
+
- lib/zookeeper/constants.rb
|
70
|
+
- lib/zookeeper/exceptions.rb
|
71
|
+
- lib/zookeeper/stat.rb
|
59
72
|
- test/test_basic.rb
|
73
|
+
- test/test_callback1.rb
|
74
|
+
- test/test_esoteric.rb
|
75
|
+
- test/test_watcher1.rb
|
76
|
+
- test/test_watcher2.rb
|
60
77
|
- zookeeper.gemspec
|
61
78
|
has_rdoc: true
|
62
79
|
homepage: http://blog.evanweaver.com/files/doc/fauna/zookeeper/
|
@@ -77,20 +94,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
94
|
requirements:
|
78
95
|
- - ">="
|
79
96
|
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
80
99
|
version: "0"
|
81
|
-
version:
|
82
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
101
|
requirements:
|
84
102
|
- - ">="
|
85
103
|
- !ruby/object:Gem::Version
|
104
|
+
segments:
|
105
|
+
- 1
|
106
|
+
- 2
|
86
107
|
version: "1.2"
|
87
|
-
version:
|
88
108
|
requirements: []
|
89
109
|
|
90
110
|
rubyforge_project: fauna
|
91
|
-
rubygems_version: 1.3.
|
111
|
+
rubygems_version: 1.3.6
|
92
112
|
signing_key:
|
93
113
|
specification_version: 3
|
94
114
|
summary: An interface to the Zookeeper distributed configuration server.
|
95
115
|
test_files:
|
96
116
|
- test/test_basic.rb
|
117
|
+
- test/test_callback1.rb
|
118
|
+
- test/test_esoteric.rb
|
119
|
+
- test/test_watcher1.rb
|
120
|
+
- test/test_watcher2.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/ext/zkc-3.2.2.tar.gz
DELETED
Binary file
|