zookeeper 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ v0.2.1. No more camelcase classname.
3
+
2
4
  v0.2. Bundle C dependencies, like memcached.gem.
3
5
 
4
6
  v0.1. First release.
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  zookeeper
2
2
 
3
- An interface to the ZooKeeper distributed configuration server.
3
+ An interface to the Zookeeper distributed configuration server.
4
4
 
5
5
  == License
6
6
 
@@ -12,47 +12,42 @@ sudo gem install zookeeper
12
12
 
13
13
  == Usage
14
14
 
15
- = Connect to a server
15
+ Connect to a server:
16
16
 
17
17
  require 'rubygems'
18
18
  require 'zookeeper'
19
- z = ZooKeeper.new("localhost:2181")
19
+ z = Zookeeper.new("localhost:2181")
20
20
 
21
- = Create, set and read nodes
21
+ Create, set and read nodes:
22
22
 
23
23
  z.create("/bacon", "text to be stored in the new node", 0)
24
- # => "/bacon"
25
-
26
24
  data, stat = z.get("/bacon")
27
- # => ["text to be stored in the new node", #<ZkStat:0xb771be54 @ephemeralOwner=0, @ctime=1216196667669, @aversion=0, @mzxid=1008, @cversion=0, @version=0, @czxid=1008, @mtime=1216196667669>]
28
-
25
+ # => ["text to be stored in the new node"...]
26
+
29
27
  z.set("/bacon", "an entirely different line of text", stat.version)
30
- # => nil
31
-
32
28
  z.set("/bacon", "this won't work", stat.version)
33
- # CZooKeeper::BadVersionError: expected version does not match actual version
29
+ # CZookeeper::BadVersionError: expected version does not match actual version
34
30
 
35
31
  data, stat = z.get("/bacon")
36
- # => ["an entirely different line of text", #<ZkStat:0xb77125d4 @ephemeralOwner=0, @ctime=1216196667669, @aversion=0, @mzxid=1009, @cversion=0, @version=1, @czxid=1008, @mtime=1216196704709>]
37
-
32
+ # => ["an entirely different line of text"...]
38
33
  z.delete("/bacon", stat.version)
39
- # => nil
40
34
 
41
- = Create ephemeral and sequence nodes
35
+ Create ephemeral and sequence nodes:
42
36
 
43
37
  z.create("/parent", "parent node", 0)
44
- # => "/parent"
45
38
 
46
- z.create("/parent/test-", "an ordered node that will disappear when the connection goes down", ZooKeeper::EPHEMERAL | ZooKeeper::SEQUENCE)
47
- # => "/parent/test-0"
39
+ z.create("/parent/test-",
40
+ "an ordered ephemeral node",
41
+ Zookeeper::EPHEMERAL | Zookeeper::SEQUENCE)
42
+ # => "/parent/test-0"
48
43
 
49
- z.create("/parent/test-", "an ordered node that will disappear when the connection goes down", ZooKeeper::EPHEMERAL | ZooKeeper::SEQUENCE)
50
- # => "/parent/test-1"
44
+ z.create("/parent/test-",
45
+ "an ordered ephemeral node",
46
+ Zookeeper::EPHEMERAL | Zookeeper::SEQUENCE)
47
+ # => "/parent/test-1"
51
48
 
52
- = Acquire locks
49
+ Acquire locks:
53
50
 
54
51
  z.try_acquire "/parent/lock-", "content for the lock file" do |have_lock|
55
52
  puts have_lock ? "we have the lock" : "we don't have the lock"
56
53
  end
57
- # we have the lock
58
- # => nil
data/Rakefile CHANGED
@@ -3,8 +3,9 @@ require 'echoe'
3
3
  Echoe.new("zookeeper") do |p|
4
4
  p.author = "Phillip Pearson, Eric Maland, Evan Weaver"
5
5
  p.project = "fauna"
6
- p.summary = "A Ruby wrapper for the ZooKeeper C client library."
6
+ p.summary = "An interface to the Zookeeper distributed configuration server."
7
7
  p.url = "http://blog.evanweaver.com/files/doc/fauna/zookeeper/"
8
8
  p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/"
9
9
  p.clean_pattern += ["ext/lib", "ext/include", "ext/c", "ext/bin", "ext/conftest.dSYM"]
10
+ p.rdoc_pattern = /README|TODO|LICENSE|CHANGELOG|BENCH|COMPAT|zookeeper_c.c|zookeeper.rb/
10
11
  end
data/ext/zookeeper_c.c CHANGED
@@ -1,4 +1,4 @@
1
- /* Ruby wrapper for the ZooKeeper C API
1
+ /* Ruby wrapper for the Zookeeper C API
2
2
  * Phillip Pearson <pp@myelin.co.nz>
3
3
  * Eric Maland <eric@twitter.com>
4
4
  */
@@ -11,7 +11,7 @@
11
11
  #include <errno.h>
12
12
  #include <stdio.h>
13
13
 
14
- static VALUE ZooKeeper = Qnil;
14
+ static VALUE Zookeeper = Qnil;
15
15
  static VALUE eNoNode = Qnil;
16
16
  static VALUE eBadVersion = Qnil;
17
17
 
@@ -71,7 +71,7 @@ static VALUE method_initialize(VALUE self, VALUE hostPort) {
71
71
 
72
72
  Check_Type(hostPort, T_STRING);
73
73
 
74
- data = Data_Make_Struct(ZooKeeper, struct zk_rb_data, 0, free_zk_rb_data, zk);
74
+ data = Data_Make_Struct(Zookeeper, struct zk_rb_data, 0, free_zk_rb_data, zk);
75
75
 
76
76
  zoo_set_debug_level(ZOO_LOG_LEVEL_INFO);
77
77
  zoo_deterministic_conn_order(0);
@@ -413,10 +413,10 @@ static VALUE method_set_watcher(VALUE self, VALUE new_watcher) {
413
413
  }
414
414
 
415
415
  void Init_zookeeper_c() {
416
- ZooKeeper = rb_define_class("CZooKeeper", rb_cObject);
416
+ Zookeeper = rb_define_class("CZookeeper", rb_cObject);
417
417
 
418
418
  #define DEFINE_METHOD(method, args) { \
419
- rb_define_method(ZooKeeper, #method, method_ ## method, args); }
419
+ rb_define_method(Zookeeper, #method, method_ ## method, args); }
420
420
 
421
421
  DEFINE_METHOD(initialize, 1);
422
422
  DEFINE_METHOD(get_children, 1);
@@ -443,10 +443,10 @@ void Init_zookeeper_c() {
443
443
  DEFINE_METHOD(state, 0);
444
444
  DEFINE_METHOD(zerror, 1);
445
445
 
446
- eNoNode = rb_define_class_under(ZooKeeper, "NoNodeError", rb_eRuntimeError);
447
- eBadVersion = rb_define_class_under(ZooKeeper, "BadVersionError", rb_eRuntimeError);
446
+ eNoNode = rb_define_class_under(Zookeeper, "NoNodeError", rb_eRuntimeError);
447
+ eBadVersion = rb_define_class_under(Zookeeper, "BadVersionError", rb_eRuntimeError);
448
448
 
449
- #define EXPORT_CONST(x) { rb_define_const(ZooKeeper, #x, INT2FIX(x)); }
449
+ #define EXPORT_CONST(x) { rb_define_const(Zookeeper, #x, INT2FIX(x)); }
450
450
 
451
451
  /* create flags */
452
452
  EXPORT_CONST(ZOO_EPHEMERAL);
data/lib/zookeeper.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Ruby wrapper for the ZooKeeper C API
1
+ # Ruby wrapper for the Zookeeper C API
2
2
  # Phillip Pearson <pp@myelin.co.nz>
3
3
 
4
4
  require 'zookeeper_c'
@@ -10,7 +10,7 @@ class ZkStat
10
10
  end
11
11
  end
12
12
 
13
- class ZooKeeper < CZooKeeper
13
+ class Zookeeper < CZookeeper
14
14
  def initialize(host)
15
15
  super(host)
16
16
  @watchers = {} # path => [ block, block, ... ]
@@ -23,7 +23,7 @@ class ZooKeeper < CZooKeeper
23
23
 
24
24
  def stat(path, &blk)
25
25
  exists(path, &blk)
26
- rescue ZooKeeper::NoNodeError
26
+ rescue Zookeeper::NoNodeError
27
27
  nil
28
28
  end
29
29
 
@@ -37,7 +37,7 @@ class ZooKeeper < CZooKeeper
37
37
  create(path, "lock node", 0) unless stat(path)
38
38
 
39
39
  # attempt to obtain the lock
40
- realpath = create("#{path}/lock-", value, ZooKeeper::ZOO_EPHEMERAL | ZooKeeper::ZOO_SEQUENCE)
40
+ realpath = create("#{path}/lock-", value, Zookeeper::ZOO_EPHEMERAL | Zookeeper::ZOO_SEQUENCE)
41
41
  #puts "created lock node #{realpath}"
42
42
 
43
43
  # see if we got it
data/test/test_basic.rb CHANGED
@@ -2,7 +2,7 @@ HERE = File.expand_path(File.dirname(__FILE__))
2
2
 
3
3
  require "#{HERE}/../lib/zookeeper"
4
4
 
5
- z = ZooKeeper.new("localhost:2181")
5
+ z = Zookeeper.new("localhost:2181")
6
6
 
7
7
  puts "root: #{z.get_children("/").inspect}"
8
8
 
@@ -35,7 +35,7 @@ puts "delete: #{z.delete(path, stat.version).inspect}"
35
35
  begin
36
36
  puts "exists? #{z.exists(path)}"
37
37
  raise Exception, "it shouldn't exist"
38
- rescue ZooKeeper::NoNodeError
38
+ rescue Zookeeper::NoNodeError
39
39
  puts "doesn't exist - good, because we just deleted it!"
40
40
  end
41
41
 
data/zookeeper.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{zookeeper}
5
- s.version = "0.2"
5
+ s.version = "0.2.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Phillip Pearson, Eric Maland, Evan Weaver"]
9
9
  s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
10
10
  s.date = %q{2010-03-02}
11
- s.description = %q{A Ruby wrapper for the ZooKeeper C client library.}
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
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "ext/extconf.rb", "ext/zkc-3.2.2.tar.gz", "ext/zookeeper_c.c", "lib/zookeeper.rb"]
14
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "ext/zookeeper_c.c", "lib/zookeeper.rb"]
15
15
  s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "ext/extconf.rb", "ext/zkc-3.2.2.tar.gz", "ext/zookeeper_c.c", "lib/zookeeper.rb", "test/test_basic.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"]
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.rubyforge_project = %q{fauna}
20
20
  s.rubygems_version = %q{1.3.5}
21
21
  s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem}
22
- s.summary = %q{A Ruby wrapper for the ZooKeeper C client library.}
22
+ s.summary = %q{An interface to the Zookeeper distributed configuration server.}
23
23
  s.test_files = ["test/test_basic.rb"]
24
24
 
25
25
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zookeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.2"
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phillip Pearson, Eric Maland, Evan Weaver
@@ -34,7 +34,7 @@ date: 2010-03-02 00:00:00 -08:00
34
34
  default_executable:
35
35
  dependencies: []
36
36
 
37
- description: A Ruby wrapper for the ZooKeeper C client library.
37
+ description: An interface to the Zookeeper distributed configuration server.
38
38
  email: ""
39
39
  executables: []
40
40
 
@@ -44,8 +44,6 @@ extra_rdoc_files:
44
44
  - CHANGELOG
45
45
  - LICENSE
46
46
  - README
47
- - ext/extconf.rb
48
- - ext/zkc-3.2.2.tar.gz
49
47
  - ext/zookeeper_c.c
50
48
  - lib/zookeeper.rb
51
49
  files:
@@ -93,6 +91,6 @@ rubyforge_project: fauna
93
91
  rubygems_version: 1.3.5
94
92
  signing_key:
95
93
  specification_version: 3
96
- summary: A Ruby wrapper for the ZooKeeper C client library.
94
+ summary: An interface to the Zookeeper distributed configuration server.
97
95
  test_files:
98
96
  - test/test_basic.rb
metadata.gz.sig CHANGED
Binary file