zookeeper 0.4.4 → 0.9.3

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.
Files changed (48) hide show
  1. data/.gitignore +10 -0
  2. data/CHANGELOG +95 -0
  3. data/Gemfile +17 -0
  4. data/Manifest +8 -2
  5. data/README.markdown +59 -0
  6. data/Rakefile +137 -7
  7. data/ext/.gitignore +6 -0
  8. data/ext/Rakefile +51 -0
  9. data/ext/c_zookeeper.rb +212 -0
  10. data/ext/dbg.h +53 -0
  11. data/ext/depend +5 -0
  12. data/ext/extconf.rb +44 -15
  13. data/ext/generate_gvl_code.rb +316 -0
  14. data/ext/zkc-3.3.5.tar.gz +0 -0
  15. data/ext/zkrb_wrapper.c +731 -0
  16. data/ext/zkrb_wrapper.h +330 -0
  17. data/ext/zkrb_wrapper_compat.c +15 -0
  18. data/ext/zkrb_wrapper_compat.h +11 -0
  19. data/ext/zookeeper_base.rb +211 -0
  20. data/ext/zookeeper_c.c +268 -97
  21. data/ext/zookeeper_lib.c +157 -92
  22. data/ext/zookeeper_lib.h +12 -6
  23. data/java/zookeeper_base.rb +477 -0
  24. data/lib/zookeeper/acls.rb +10 -1
  25. data/lib/zookeeper/callbacks.rb +5 -3
  26. data/lib/zookeeper/common/queue_with_pipe.rb +78 -0
  27. data/lib/zookeeper/common.rb +174 -0
  28. data/lib/zookeeper/constants.rb +31 -28
  29. data/lib/zookeeper/em_client.rb +55 -0
  30. data/lib/zookeeper/exceptions.rb +10 -2
  31. data/lib/zookeeper/stat.rb +11 -2
  32. data/lib/zookeeper/version.rb +6 -0
  33. data/lib/zookeeper.rb +155 -122
  34. data/notes.txt +14 -0
  35. data/spec/c_zookeeper_spec.rb +50 -0
  36. data/spec/chrooted_connection_spec.rb +81 -0
  37. data/spec/default_watcher_spec.rb +41 -0
  38. data/spec/em_spec.rb +51 -0
  39. data/spec/log4j.properties +17 -0
  40. data/spec/shared/all_success_return_values.rb +10 -0
  41. data/spec/shared/connection_examples.rb +1018 -0
  42. data/spec/spec_helper.rb +119 -0
  43. data/spec/support/progress_formatter.rb +15 -0
  44. data/spec/zookeeper_spec.rb +24 -0
  45. data/zookeeper.gemspec +37 -25
  46. metadata +78 -34
  47. data/README +0 -42
  48. data/ext/zkc-3.3.2.tar.gz +0 -0
@@ -0,0 +1,119 @@
1
+ $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
2
+ $LOAD_PATH.unshift(File.expand_path('../../ext', __FILE__))
3
+ $LOAD_PATH.uniq!
4
+
5
+ require 'rubygems'
6
+
7
+ gem 'flexmock', '~> 0.8.11'
8
+
9
+ require 'flexmock'
10
+ require 'zookeeper'
11
+
12
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].sort.each { |f| require(f) }
13
+
14
+ if ENV['ZKRB_DEBUG']
15
+ Zookeeper.logger = Logger.new($stderr).tap { |l| l.level = Logger::DEBUG }
16
+ Zookeeper.set_debug_level(4)
17
+ else
18
+ Zookeeper.logger = Logger.new(File.expand_path('../../test.log', __FILE__)).tap do |log|
19
+ log.level = Logger::DEBUG
20
+ end
21
+ end
22
+
23
+ if ENV['ZKRB_NOLOG']
24
+ Zookeeper.logger.level = Logger::FATAL
25
+ Zookeeper.set_debug_level(0)
26
+ end
27
+
28
+
29
+ module ZookeeperSpecHeleprs
30
+ class TimeoutError < StandardError; end
31
+
32
+ def logger
33
+ Zookeeper.logger
34
+ end
35
+
36
+ def ensure_node(zk, path, data)
37
+ return if zk.closed?
38
+ if zk.stat(:path => path)[:stat].exists?
39
+ zk.set(:path => path, :data => data)
40
+ else
41
+ zk.create(:path => path, :data => data)
42
+ end
43
+ end
44
+
45
+ def with_open_zk(host='localhost:2181')
46
+ z = Zookeeper.new(host)
47
+ yield z
48
+ ensure
49
+ if z
50
+ unless z.closed?
51
+ z.close
52
+
53
+ wait_until do
54
+ begin
55
+ !z.connected?
56
+ rescue RuntimeError
57
+ true
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ # this is not as safe as the one in ZK, just to be used to clean up
65
+ # when we're the only one adjusting a particular path
66
+ def rm_rf(z, path)
67
+ z.get_children(:path => path).tap do |h|
68
+ if h[:rc].zero?
69
+ h[:children].each do |child|
70
+ rm_rf(z, File.join(path, child))
71
+ end
72
+ elsif h[:rc] == ZookeeperExceptions::ZNONODE
73
+ # no-op
74
+ else
75
+ raise "Oh noes! unexpected return value! #{h.inspect}"
76
+ end
77
+ end
78
+
79
+ rv = z.delete(:path => path)
80
+
81
+ unless (rv[:rc].zero? or rv[:rc] == ZookeeperExceptions::ZNONODE)
82
+ raise "oh noes! failed to delete #{path}"
83
+ end
84
+
85
+ path
86
+ end
87
+
88
+
89
+ # method to wait until block passed returns true or timeout (default is 10 seconds) is reached
90
+ # raises TiemoutError on timeout
91
+ def wait_until(timeout=10)
92
+ time_to_stop = Time.now + timeout
93
+ while true
94
+ rval = yield
95
+ return rval if rval
96
+ raise TimeoutError, "timeout of #{timeout}s exceeded" if Time.now > time_to_stop
97
+ Thread.pass
98
+ end
99
+ end
100
+
101
+ # inverse of wait_until
102
+ def wait_while(timeout=10)
103
+ time_to_stop = Time.now + timeout
104
+ while true
105
+ rval = yield
106
+ return rval unless rval
107
+ raise TimeoutError, "timeout of #{timeout}s exceeded" if Time.now > time_to_stop
108
+ Thread.pass
109
+ end
110
+ end
111
+ end
112
+
113
+ RSpec.configure do |config|
114
+ config.mock_with :flexmock
115
+ config.include ZookeeperSpecHeleprs
116
+ config.extend ZookeeperSpecHeleprs
117
+ end
118
+
119
+
@@ -0,0 +1,15 @@
1
+ require 'rspec/core/formatters/progress_formatter'
2
+
3
+ module RSpec
4
+ module Core
5
+ module Formatters
6
+ class ProgressFormatter
7
+ def example_started(example)
8
+ Zookeeper.logger.info(yellow("=====<([ #{example.full_description} ])>====="))
9
+ super(example)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'shared/connection_examples'
3
+
4
+
5
+ describe 'Zookeeper' do
6
+ let(:path) { "/_zktest_" }
7
+ let(:data) { "underpants" }
8
+ let(:connection_string) { 'localhost:2181' }
9
+
10
+ before do
11
+ @zk = Zookeeper.new(connection_string)
12
+ end
13
+
14
+ after do
15
+ @zk and @zk.close
16
+ end
17
+
18
+ def zk
19
+ @zk
20
+ end
21
+
22
+ it_should_behave_like "connection"
23
+ end
24
+
data/zookeeper.gemspec CHANGED
@@ -1,31 +1,43 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'zookeeper/version'
2
4
 
3
5
  Gem::Specification.new do |s|
4
- s.name = %q{zookeeper}
5
- s.version = "0.4.4"
6
-
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, Brian Wickman"]
9
- s.date = %q{2011-03-30}
10
- s.description = %q{An interface to the Zookeeper distributed configuration server.}
11
- s.email = %q{}
12
- s.extensions = ["ext/extconf.rb"]
13
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "ext/zookeeper_c.c", "lib/zookeeper.rb"]
14
- s.files = ["CHANGELOG", "LICENSE", "README", "Rakefile", "examples/cloud_config.rb", "ext/extconf.rb", "ext/zkc-3.3.2.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_close.rb", "test/test_esoteric.rb", "test/test_watcher1.rb", "test/test_watcher2.rb", "Manifest", "zookeeper.gemspec"]
15
- s.homepage = %q{http://twitter.github.com/twitter/zookeeper/}
16
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Zookeeper", "--main", "README"]
17
- s.require_paths = ["lib", "ext"]
18
- s.rubyforge_project = %q{twitter}
19
- s.rubygems_version = %q{1.6.1}
20
- s.summary = %q{An interface to the Zookeeper distributed configuration server.}
21
- s.test_files = ["test/test_basic.rb", "test/test_callback1.rb", "test/test_close.rb", "test/test_esoteric.rb", "test/test_watcher1.rb", "test/test_watcher2.rb"]
22
-
23
- if s.respond_to? :specification_version then
24
- s.specification_version = 3
25
-
26
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- else
28
- end
6
+ s.name = "zookeeper"
7
+ s.version = ZookeeperVersion::VERSION
8
+
9
+ s.authors = ["Phillip Pearson", "Eric Maland", "Evan Weaver", "Brian Wickman", "Neil Conway", "Jonathan D. Simms"]
10
+ s.email = ["slyphon@gmail.com"]
11
+ s.summary = %q{Low level zookeeper client}
12
+ s.description = <<-EOS
13
+ A low-level multi-Ruby wrapper around the ZooKeeper API bindings.
14
+ For a friendlier interface, see http://github.com/slyphon/zk
15
+
16
+ Currently supported:
17
+
18
+ MRI: 1.8.7, 1.9.2, 1.9.3
19
+ JRuby: ~> 1.6.7
20
+ Rubinius: 2.0.testing
21
+
22
+ This library uses version #{ZookeeperVersion::DRIVER_VERSION} of zookeeper bindings.
23
+
24
+ EOS
25
+
26
+ s.homepage = 'https://github.com/slyphon/zookeeper'
27
+
28
+ s.files = `git ls-files`.split("\n")
29
+ s.require_paths = ["lib"]
30
+
31
+ if ENV['JAVA_GEM'] or defined?(::JRUBY_VERSION)
32
+ s.platform = 'java'
33
+ s.add_runtime_dependency('slyphon-log4j', '= 1.2.15')
34
+ s.add_runtime_dependency('slyphon-zookeeper_jar', '= 3.3.5')
35
+ s.require_paths += %w[java]
29
36
  else
37
+ s.require_paths += %w[ext]
38
+ s.extensions = 'ext/extconf.rb'
30
39
  end
40
+
41
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
42
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
31
43
  end
metadata CHANGED
@@ -1,73 +1,108 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zookeeper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 4
10
- version: 0.4.4
8
+ - 9
9
+ - 3
10
+ version: 0.9.3
11
11
  platform: ruby
12
12
  authors:
13
- - Phillip Pearson, Eric Maland, Evan Weaver, Brian Wickman
13
+ - Phillip Pearson
14
+ - Eric Maland
15
+ - Evan Weaver
16
+ - Brian Wickman
17
+ - Neil Conway
18
+ - Jonathan D. Simms
14
19
  autorequire:
15
20
  bindir: bin
16
21
  cert_chain: []
17
22
 
18
- date: 2011-03-30 00:00:00 -07:00
19
- default_executable:
23
+ date: 2012-05-03 00:00:00 Z
20
24
  dependencies: []
21
25
 
22
- description: An interface to the Zookeeper distributed configuration server.
23
- email: ""
26
+ description: |+
27
+ A low-level multi-Ruby wrapper around the ZooKeeper API bindings.
28
+ For a friendlier interface, see http://github.com/slyphon/zk
29
+
30
+ Currently supported:
31
+
32
+ MRI: 1.8.7, 1.9.2, 1.9.3
33
+ JRuby: ~> 1.6.7
34
+ Rubinius: 2.0.testing
35
+
36
+ This library uses version 3.3.5 of zookeeper bindings.
37
+
38
+ email:
39
+ - slyphon@gmail.com
24
40
  executables: []
25
41
 
26
42
  extensions:
27
43
  - ext/extconf.rb
28
- extra_rdoc_files:
29
- - CHANGELOG
30
- - LICENSE
31
- - README
32
- - ext/zookeeper_c.c
33
- - lib/zookeeper.rb
44
+ extra_rdoc_files: []
45
+
34
46
  files:
47
+ - .gitignore
35
48
  - CHANGELOG
49
+ - Gemfile
36
50
  - LICENSE
37
- - README
51
+ - Manifest
52
+ - README.markdown
38
53
  - Rakefile
39
54
  - examples/cloud_config.rb
55
+ - ext/.gitignore
56
+ - ext/Rakefile
57
+ - ext/c_zookeeper.rb
58
+ - ext/dbg.h
59
+ - ext/depend
40
60
  - ext/extconf.rb
41
- - ext/zkc-3.3.2.tar.gz
61
+ - ext/generate_gvl_code.rb
62
+ - ext/zkc-3.3.5.tar.gz
63
+ - ext/zkrb_wrapper.c
64
+ - ext/zkrb_wrapper.h
65
+ - ext/zkrb_wrapper_compat.c
66
+ - ext/zkrb_wrapper_compat.h
67
+ - ext/zookeeper_base.rb
42
68
  - ext/zookeeper_c.c
43
69
  - ext/zookeeper_lib.c
44
70
  - ext/zookeeper_lib.h
71
+ - java/zookeeper_base.rb
45
72
  - lib/zookeeper.rb
46
73
  - lib/zookeeper/acls.rb
47
74
  - lib/zookeeper/callbacks.rb
75
+ - lib/zookeeper/common.rb
76
+ - lib/zookeeper/common/queue_with_pipe.rb
48
77
  - lib/zookeeper/constants.rb
78
+ - lib/zookeeper/em_client.rb
49
79
  - lib/zookeeper/exceptions.rb
50
80
  - lib/zookeeper/stat.rb
81
+ - lib/zookeeper/version.rb
82
+ - notes.txt
83
+ - spec/c_zookeeper_spec.rb
84
+ - spec/chrooted_connection_spec.rb
85
+ - spec/default_watcher_spec.rb
86
+ - spec/em_spec.rb
87
+ - spec/log4j.properties
88
+ - spec/shared/all_success_return_values.rb
89
+ - spec/shared/connection_examples.rb
90
+ - spec/spec_helper.rb
91
+ - spec/support/progress_formatter.rb
92
+ - spec/zookeeper_spec.rb
51
93
  - test/test_basic.rb
52
94
  - test/test_callback1.rb
53
95
  - test/test_close.rb
54
96
  - test/test_esoteric.rb
55
97
  - test/test_watcher1.rb
56
98
  - test/test_watcher2.rb
57
- - Manifest
58
99
  - zookeeper.gemspec
59
- has_rdoc: true
60
- homepage: http://twitter.github.com/twitter/zookeeper/
100
+ homepage: https://github.com/slyphon/zookeeper
61
101
  licenses: []
62
102
 
63
103
  post_install_message:
64
- rdoc_options:
65
- - --line-numbers
66
- - --inline-source
67
- - --title
68
- - Zookeeper
69
- - --main
70
- - README
104
+ rdoc_options: []
105
+
71
106
  require_paths:
72
107
  - lib
73
108
  - ext
@@ -85,19 +120,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
120
  requirements:
86
121
  - - ">="
87
122
  - !ruby/object:Gem::Version
88
- hash: 11
123
+ hash: 3
89
124
  segments:
90
- - 1
91
- - 2
92
- version: "1.2"
125
+ - 0
126
+ version: "0"
93
127
  requirements: []
94
128
 
95
- rubyforge_project: twitter
96
- rubygems_version: 1.6.1
129
+ rubyforge_project:
130
+ rubygems_version: 1.8.15
97
131
  signing_key:
98
132
  specification_version: 3
99
- summary: An interface to the Zookeeper distributed configuration server.
133
+ summary: Low level zookeeper client
100
134
  test_files:
135
+ - spec/c_zookeeper_spec.rb
136
+ - spec/chrooted_connection_spec.rb
137
+ - spec/default_watcher_spec.rb
138
+ - spec/em_spec.rb
139
+ - spec/log4j.properties
140
+ - spec/shared/all_success_return_values.rb
141
+ - spec/shared/connection_examples.rb
142
+ - spec/spec_helper.rb
143
+ - spec/support/progress_formatter.rb
144
+ - spec/zookeeper_spec.rb
101
145
  - test/test_basic.rb
102
146
  - test/test_callback1.rb
103
147
  - test/test_close.rb
data/README DELETED
@@ -1,42 +0,0 @@
1
- zookeeper
2
-
3
- An interface to the Zookeeper distributed configuration server.
4
-
5
- == License
6
-
7
- Copyright 2008 Phillip Pearson, and 2010 Twitter, Inc. Licensed under the
8
- MIT License. See the included LICENSE file. Portions copyright 2008-2010
9
- the Apache Software Foundation, licensed under the Apache 2 license, and
10
- used with permission.
11
-
12
- == Install
13
-
14
- sudo gem install zookeeper
15
-
16
- == Usage
17
-
18
- Connect to a server:
19
-
20
- require 'rubygems'
21
- require 'zookeeper'
22
- z = Zookeeper.new("localhost:2181")
23
- z.get_children(:path => "/")
24
-
25
- == Idioms
26
-
27
- The following methods are initially supported:
28
- get
29
- set
30
- get_children
31
- stat
32
- create
33
- delete
34
- get_acl
35
- set_acl
36
-
37
- All support async callbacks. get, get_children and stat support both
38
- watchers and callbacks.
39
-
40
- Calls take a dictionary of parameters. With the exception of set_acl, the
41
- only required parameter is :path. Each call returns a dictionary with at
42
- minimum two keys :req_id and :rc.
data/ext/zkc-3.3.2.tar.gz DELETED
Binary file