slyphon-zookeeper 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -2
- data/Rakefile +1 -12
- data/ext/zkc-3.3.3.tar.gz +0 -0
- data/ext/zookeeper_base.rb +4 -1
- data/ext/zookeeper_c.c +37 -31
- data/ext/zookeeper_lib.c +32 -24
- data/ext/zookeeper_lib.h +1 -0
- data/java/zookeeper_base.rb +3 -0
- data/lib/zookeeper.rb +17 -17
- data/slyphon-zookeeper.gemspec +2 -2
- metadata +7 -6
- data/ext/zkc-3.3.2.tar.gz +0 -0
data/CHANGELOG
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
v0.4.
|
2
|
-
|
1
|
+
v0.4.5 Upgrade to ZooKeeper 3.3.3
|
2
|
+
|
3
|
+
v0.4.4 Fix race condition on close, possible data corruption on async get.
|
4
|
+
|
5
|
+
v0.4.3 Fix a handful of memory-related bugs, fix SIGSEGV on master change, reduce latency of event handling, fix compilation on OSX.
|
3
6
|
|
4
7
|
v0.4.2 Add options to Zookeeper#initialize, silence most Zookeeper logs.
|
5
8
|
|
data/Rakefile
CHANGED
@@ -1,15 +1,3 @@
|
|
1
|
-
require 'echoe'
|
2
|
-
|
3
|
-
Echoe.new("zookeeper") do |p|
|
4
|
-
p.author = "Phillip Pearson, Eric Maland, Evan Weaver, Brian Wickman"
|
5
|
-
p.project = "fauna"
|
6
|
-
p.summary = "An interface to the Zookeeper distributed configuration server."
|
7
|
-
p.url = "https://github.com/twitter/zookeeper"
|
8
|
-
p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/"
|
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/
|
11
|
-
end
|
12
|
-
|
13
1
|
namespace :mb do
|
14
2
|
task :build_gems do
|
15
3
|
sh "gem build slyphon-zookeeper.gemspec"
|
@@ -17,3 +5,4 @@ namespace :mb do
|
|
17
5
|
sh "gem build slyphon-zookeeper.gemspec"
|
18
6
|
end
|
19
7
|
end
|
8
|
+
|
Binary file
|
data/ext/zookeeper_base.rb
CHANGED
@@ -49,6 +49,9 @@ class ZookeeperBase < CZookeeper
|
|
49
49
|
watcher ||= get_default_global_watcher
|
50
50
|
|
51
51
|
@_running = nil # used by the C layer
|
52
|
+
|
53
|
+
yield self if block_given?
|
54
|
+
|
52
55
|
reopen(timeout, watcher)
|
53
56
|
return nil unless connected?
|
54
57
|
setup_dispatch_thread!
|
@@ -73,7 +76,7 @@ class ZookeeperBase < CZookeeper
|
|
73
76
|
end
|
74
77
|
|
75
78
|
def close
|
76
|
-
@_running = false
|
79
|
+
@_running = false
|
77
80
|
wake_event_loop!
|
78
81
|
|
79
82
|
@dispatcher.join
|
data/ext/zookeeper_c.c
CHANGED
@@ -106,7 +106,7 @@ static VALUE method_init(int argc, VALUE* argv, VALUE self) {
|
|
106
106
|
zkrb_calling_context *ctx =
|
107
107
|
zkrb_calling_context_alloc(ZKRB_GLOBAL_REQ, zk_local_ctx->queue);
|
108
108
|
|
109
|
-
zk_local_ctx->zh =
|
109
|
+
zk_local_ctx->zh =
|
110
110
|
zookeeper_init(
|
111
111
|
RSTRING_PTR(hostPort),
|
112
112
|
zkrb_state_callback,
|
@@ -114,7 +114,7 @@ static VALUE method_init(int argc, VALUE* argv, VALUE self) {
|
|
114
114
|
&zk_local_ctx->myid,
|
115
115
|
ctx,
|
116
116
|
0);
|
117
|
-
|
117
|
+
|
118
118
|
#warning [wickman] TODO handle this properly on the Ruby side rather than C side
|
119
119
|
if (!zk_local_ctx->zh) {
|
120
120
|
rb_raise(rb_eRuntimeError, "error connecting to zookeeper: %d", errno);
|
@@ -158,10 +158,10 @@ static VALUE method_init(int argc, VALUE* argv, VALUE self) {
|
|
158
158
|
|
159
159
|
static VALUE method_get_children(VALUE self, VALUE reqid, VALUE path, VALUE async, VALUE watch) {
|
160
160
|
STANDARD_PREAMBLE(self, zk, reqid, path, async, watch, data_ctx, watch_ctx, call_type);
|
161
|
-
|
161
|
+
|
162
162
|
struct String_vector strings;
|
163
163
|
struct Stat stat;
|
164
|
-
|
164
|
+
|
165
165
|
int rc;
|
166
166
|
switch (call_type) {
|
167
167
|
case SYNC:
|
@@ -171,11 +171,11 @@ static VALUE method_get_children(VALUE self, VALUE reqid, VALUE path, VALUE asyn
|
|
171
171
|
case SYNC_WATCH:
|
172
172
|
rc = zoo_wget_children2(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, &strings, &stat);
|
173
173
|
break;
|
174
|
-
|
174
|
+
|
175
175
|
case ASYNC:
|
176
176
|
rc = zoo_aget_children2(zk->zh, RSTRING_PTR(path), 0, zkrb_strings_stat_callback, data_ctx);
|
177
177
|
break;
|
178
|
-
|
178
|
+
|
179
179
|
case ASYNC_WATCH:
|
180
180
|
rc = zoo_awget_children2(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, zkrb_strings_stat_callback, data_ctx);
|
181
181
|
break;
|
@@ -192,7 +192,7 @@ static VALUE method_get_children(VALUE self, VALUE reqid, VALUE path, VALUE asyn
|
|
192
192
|
|
193
193
|
static VALUE method_exists(VALUE self, VALUE reqid, VALUE path, VALUE async, VALUE watch) {
|
194
194
|
STANDARD_PREAMBLE(self, zk, reqid, path, async, watch, data_ctx, watch_ctx, call_type);
|
195
|
-
|
195
|
+
|
196
196
|
struct Stat stat;
|
197
197
|
|
198
198
|
int rc;
|
@@ -204,11 +204,11 @@ static VALUE method_exists(VALUE self, VALUE reqid, VALUE path, VALUE async, VAL
|
|
204
204
|
case SYNC_WATCH:
|
205
205
|
rc = zoo_wexists(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, &stat);
|
206
206
|
break;
|
207
|
-
|
207
|
+
|
208
208
|
case ASYNC:
|
209
209
|
rc = zoo_aexists(zk->zh, RSTRING_PTR(path), 0, zkrb_stat_callback, data_ctx);
|
210
210
|
break;
|
211
|
-
|
211
|
+
|
212
212
|
case ASYNC_WATCH:
|
213
213
|
rc = zoo_awexists(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, zkrb_stat_callback, data_ctx);
|
214
214
|
break;
|
@@ -225,12 +225,12 @@ static VALUE method_exists(VALUE self, VALUE reqid, VALUE path, VALUE async, VAL
|
|
225
225
|
static VALUE method_create(VALUE self, VALUE reqid, VALUE path, VALUE data, VALUE async, VALUE acls, VALUE flags) {
|
226
226
|
VALUE watch = Qfalse;
|
227
227
|
STANDARD_PREAMBLE(self, zk, reqid, path, async, watch, data_ctx, watch_ctx, call_type);
|
228
|
-
|
228
|
+
|
229
229
|
if (data != Qnil) Check_Type(data, T_STRING);
|
230
230
|
Check_Type(flags, T_FIXNUM);
|
231
231
|
const char *data_ptr = (data == Qnil) ? NULL : RSTRING_PTR(data);
|
232
232
|
size_t data_len = (data == Qnil) ? -1 : RSTRING_LEN(data);
|
233
|
-
|
233
|
+
|
234
234
|
struct ACL_vector *aclptr = NULL;
|
235
235
|
if (acls != Qnil) { aclptr = zkrb_ruby_to_aclvector(acls); }
|
236
236
|
char realpath[16384];
|
@@ -263,10 +263,10 @@ static VALUE method_create(VALUE self, VALUE reqid, VALUE path, VALUE data, VALU
|
|
263
263
|
}
|
264
264
|
|
265
265
|
static VALUE method_delete(VALUE self, VALUE reqid, VALUE path, VALUE version, VALUE async) {
|
266
|
-
VALUE watch = Qfalse;
|
266
|
+
VALUE watch = Qfalse;
|
267
267
|
STANDARD_PREAMBLE(self, zk, reqid, path, async, watch, data_ctx, watch_ctx, call_type);
|
268
268
|
Check_Type(version, T_FIXNUM);
|
269
|
-
|
269
|
+
|
270
270
|
int rc = 0;
|
271
271
|
switch (call_type) {
|
272
272
|
case SYNC:
|
@@ -295,7 +295,7 @@ static VALUE method_get(VALUE self, VALUE reqid, VALUE path, VALUE async, VALUE
|
|
295
295
|
struct Stat stat;
|
296
296
|
|
297
297
|
int rc;
|
298
|
-
|
298
|
+
|
299
299
|
switch (call_type) {
|
300
300
|
case SYNC:
|
301
301
|
rc = zoo_get(zk->zh, RSTRING_PTR(path), 0, data, &data_len, &stat);
|
@@ -304,11 +304,11 @@ static VALUE method_get(VALUE self, VALUE reqid, VALUE path, VALUE async, VALUE
|
|
304
304
|
case SYNC_WATCH:
|
305
305
|
rc = zoo_wget(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, data, &data_len, &stat);
|
306
306
|
break;
|
307
|
-
|
307
|
+
|
308
308
|
case ASYNC:
|
309
309
|
rc = zoo_aget(zk->zh, RSTRING_PTR(path), 0, zkrb_data_callback, data_ctx);
|
310
310
|
break;
|
311
|
-
|
311
|
+
|
312
312
|
case ASYNC_WATCH:
|
313
313
|
rc = zoo_awget(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, zkrb_data_callback, data_ctx);
|
314
314
|
break;
|
@@ -331,7 +331,7 @@ static VALUE method_get(VALUE self, VALUE reqid, VALUE path, VALUE async, VALUE
|
|
331
331
|
static VALUE method_set(VALUE self, VALUE reqid, VALUE path, VALUE data, VALUE async, VALUE version) {
|
332
332
|
VALUE watch = Qfalse;
|
333
333
|
STANDARD_PREAMBLE(self, zk, reqid, path, async, watch, data_ctx, watch_ctx, call_type);
|
334
|
-
|
334
|
+
|
335
335
|
struct Stat stat;
|
336
336
|
if (data != Qnil) Check_Type(data, T_STRING);
|
337
337
|
const char *data_ptr = (data == Qnil) ? NULL : RSTRING_PTR(data);
|
@@ -391,7 +391,7 @@ static VALUE method_get_acl(VALUE self, VALUE reqid, VALUE path, VALUE async) {
|
|
391
391
|
|
392
392
|
struct ACL_vector acls;
|
393
393
|
struct Stat stat;
|
394
|
-
|
394
|
+
|
395
395
|
int rc;
|
396
396
|
switch (call_type) {
|
397
397
|
case SYNC:
|
@@ -426,6 +426,10 @@ static VALUE method_get_next_event(VALUE self) {
|
|
426
426
|
FETCH_DATA_PTR(self, zk);
|
427
427
|
|
428
428
|
for (;;) {
|
429
|
+
|
430
|
+
// we use the is_running(self) method here because it allows us to have a
|
431
|
+
// ruby-land semaphore that we can also use in the java extension
|
432
|
+
//
|
429
433
|
if (!is_running(self)) {
|
430
434
|
/* fprintf(stderr, "method_get_next_event: running is false, returning nil\n");*/
|
431
435
|
return Qnil; // this case for shutdown
|
@@ -433,12 +437,7 @@ static VALUE method_get_next_event(VALUE self) {
|
|
433
437
|
|
434
438
|
zkrb_event_t *event = zkrb_dequeue(zk->queue, 1);
|
435
439
|
|
436
|
-
/*
|
437
|
-
* If no events found, wait for an event by using rb_thread_select() on the
|
438
|
-
* queue's pipe. Note that the ZK handle might be closed while we're
|
439
|
-
* waiting; if this happens, the rb_thread_select() will fail, and we can't
|
440
|
-
* safely touch the "zk" instance handle.
|
441
|
-
*/
|
440
|
+
/* Wait for an event using rb_thread_select() on the queue's pipe */
|
442
441
|
if (event == NULL) {
|
443
442
|
int fd = zk->queue->pipe_read;
|
444
443
|
fd_set rset;
|
@@ -475,18 +474,25 @@ static VALUE method_client_id(VALUE self) {
|
|
475
474
|
return UINT2NUM(id->client_id);
|
476
475
|
}
|
477
476
|
|
477
|
+
|
478
478
|
// wake up the event loop, used when shutting down
|
479
479
|
static VALUE method_wake_event_loop_bang(VALUE self) {
|
480
480
|
FETCH_DATA_PTR(self, zk);
|
481
481
|
|
482
|
-
|
483
|
-
|
484
|
-
if (ret == -1)
|
485
|
-
rb_raise(rb_eRuntimeError, "write to pipe failed: %d", errno);
|
482
|
+
zkrb_signal(zk->queue);
|
486
483
|
|
487
484
|
return Qnil;
|
488
485
|
};
|
489
486
|
|
487
|
+
// static VALUE method_signal_pending_close(VALUE self) {
|
488
|
+
// FETCH_DATA_PTR(self, zk);
|
489
|
+
//
|
490
|
+
// zk->pending_close = 1;
|
491
|
+
// zkrb_signal(zk->queue);
|
492
|
+
//
|
493
|
+
// return Qnil;
|
494
|
+
// }
|
495
|
+
|
490
496
|
static VALUE method_close(VALUE self) {
|
491
497
|
FETCH_DATA_PTR(self, zk);
|
492
498
|
|
@@ -541,7 +547,7 @@ static void zkrb_define_methods(void) {
|
|
541
547
|
DEFINE_METHOD(get, 4);
|
542
548
|
DEFINE_METHOD(set, 5);
|
543
549
|
DEFINE_METHOD(set_acl, 5);
|
544
|
-
DEFINE_METHOD(get_acl, 3);
|
550
|
+
DEFINE_METHOD(get_acl, 3);
|
545
551
|
DEFINE_METHOD(client_id, 0);
|
546
552
|
DEFINE_METHOD(close, 0);
|
547
553
|
DEFINE_METHOD(deterministic_conn_order, 1);
|
@@ -552,11 +558,11 @@ static void zkrb_define_methods(void) {
|
|
552
558
|
// DEFINE_METHOD(add_auth, 3);
|
553
559
|
// DEFINE_METHOD(async, 1);
|
554
560
|
|
555
|
-
// methods for the ruby-side event manager
|
561
|
+
// methods for the ruby-side event manager
|
556
562
|
DEFINE_METHOD(get_next_event, 0);
|
557
563
|
DEFINE_METHOD(has_events, 0);
|
558
564
|
|
559
|
-
// Make these class methods?
|
565
|
+
// Make these class methods?
|
560
566
|
DEFINE_METHOD(set_debug_level, 1);
|
561
567
|
DEFINE_METHOD(zerror, 1);
|
562
568
|
|
data/ext/zookeeper_lib.c
CHANGED
@@ -69,6 +69,14 @@ zkrb_event_t* zkrb_dequeue(zkrb_queue_t *q, int need_lock) {
|
|
69
69
|
}
|
70
70
|
}
|
71
71
|
|
72
|
+
void zkrb_signal(zkrb_queue_t *q) {
|
73
|
+
pthread_mutex_lock(&zkrb_q_mutex);
|
74
|
+
ssize_t ret = write(q->pipe_write, "0", 1); /* Wake up Ruby listener */
|
75
|
+
pthread_mutex_unlock(&zkrb_q_mutex);
|
76
|
+
if (ret == -1)
|
77
|
+
rb_raise(rb_eRuntimeError, "write to pipe failed: %d", errno);
|
78
|
+
}
|
79
|
+
|
72
80
|
zkrb_queue_t *zkrb_queue_alloc(void) {
|
73
81
|
int pfd[2];
|
74
82
|
if (pipe(pfd) == -1)
|
@@ -194,7 +202,7 @@ VALUE zkrb_event_to_ruby(zkrb_event_t *event) {
|
|
194
202
|
case ZKRB_STAT: {
|
195
203
|
struct zkrb_stat_completion *stat_ctx = event->completion.stat_completion;
|
196
204
|
rb_hash_aset(hash, GET_SYM("stat"), stat_ctx->stat ? zkrb_stat_to_rarray(stat_ctx->stat) : Qnil);
|
197
|
-
break;
|
205
|
+
break;
|
198
206
|
}
|
199
207
|
case ZKRB_STRING: {
|
200
208
|
struct zkrb_string_completion *string_ctx = event->completion.string_completion;
|
@@ -342,7 +350,7 @@ void zkrb_data_callback(
|
|
342
350
|
event->rc = rc;
|
343
351
|
event->type = ZKRB_DATA;
|
344
352
|
event->completion.data_completion = dc;
|
345
|
-
|
353
|
+
|
346
354
|
zkrb_enqueue(queue, event);
|
347
355
|
}
|
348
356
|
|
@@ -361,7 +369,7 @@ void zkrb_stat_callback(
|
|
361
369
|
event->rc = rc;
|
362
370
|
event->type = ZKRB_STAT;
|
363
371
|
event->completion.stat_completion = sc;
|
364
|
-
|
372
|
+
|
365
373
|
zkrb_enqueue(queue, event);
|
366
374
|
}
|
367
375
|
|
@@ -381,7 +389,7 @@ void zkrb_string_callback(
|
|
381
389
|
event->rc = rc;
|
382
390
|
event->type = ZKRB_STRING;
|
383
391
|
event->completion.string_completion = sc;
|
384
|
-
|
392
|
+
|
385
393
|
zkrb_enqueue(queue, event);
|
386
394
|
}
|
387
395
|
|
@@ -400,7 +408,7 @@ void zkrb_strings_callback(
|
|
400
408
|
event->rc = rc;
|
401
409
|
event->type = ZKRB_STRINGS;
|
402
410
|
event->completion.strings_completion = sc;
|
403
|
-
|
411
|
+
|
404
412
|
zkrb_enqueue(queue, event);
|
405
413
|
}
|
406
414
|
|
@@ -420,7 +428,7 @@ void zkrb_strings_stat_callback(
|
|
420
428
|
event->rc = rc;
|
421
429
|
event->type = ZKRB_STRINGS_STAT;
|
422
430
|
event->completion.strings_stat_completion = sc;
|
423
|
-
|
431
|
+
|
424
432
|
zkrb_enqueue(queue, event);
|
425
433
|
}
|
426
434
|
|
@@ -435,7 +443,7 @@ void zkrb_void_callback(
|
|
435
443
|
event->rc = rc;
|
436
444
|
event->type = ZKRB_VOID;
|
437
445
|
event->completion.void_completion = NULL;
|
438
|
-
|
446
|
+
|
439
447
|
zkrb_enqueue(queue, event);
|
440
448
|
}
|
441
449
|
|
@@ -456,7 +464,7 @@ void zkrb_acl_callback(
|
|
456
464
|
event->rc = rc;
|
457
465
|
event->type = ZKRB_ACL;
|
458
466
|
event->completion.acl_completion = ac;
|
459
|
-
|
467
|
+
|
460
468
|
/* should be synchronized */
|
461
469
|
zkrb_enqueue(queue, event);
|
462
470
|
}
|
@@ -494,22 +502,22 @@ struct ACL_vector * zkrb_ruby_to_aclvector(VALUE acl_ary) {
|
|
494
502
|
#warning [wickman] TODO test zkrb_ruby_to_aclvector
|
495
503
|
struct ACL zkrb_ruby_to_acl(VALUE rubyacl) {
|
496
504
|
struct ACL acl;
|
497
|
-
|
505
|
+
|
498
506
|
VALUE perms = rb_iv_get(rubyacl, "@perms");
|
499
507
|
VALUE rubyid = rb_iv_get(rubyacl, "@id");
|
500
508
|
acl.perms = NUM2INT(perms);
|
501
509
|
acl.id = zkrb_ruby_to_id(rubyid);
|
502
|
-
|
510
|
+
|
503
511
|
return acl;
|
504
512
|
}
|
505
513
|
|
506
514
|
#warning [wickman] TODO zkrb_ruby_to_id error checking? test
|
507
515
|
struct Id zkrb_ruby_to_id(VALUE rubyid) {
|
508
516
|
struct Id id;
|
509
|
-
|
517
|
+
|
510
518
|
VALUE scheme = rb_iv_get(rubyid, "@scheme");
|
511
519
|
VALUE ident = rb_iv_get(rubyid, "@id");
|
512
|
-
|
520
|
+
|
513
521
|
if (scheme != Qnil) {
|
514
522
|
id.scheme = malloc(RSTRING_LEN(scheme) + 1);
|
515
523
|
strncpy(id.scheme, RSTRING_PTR(scheme), RSTRING_LEN(scheme));
|
@@ -525,7 +533,7 @@ struct Id zkrb_ruby_to_id(VALUE rubyid) {
|
|
525
533
|
} else {
|
526
534
|
id.id = NULL;
|
527
535
|
}
|
528
|
-
|
536
|
+
|
529
537
|
return id;
|
530
538
|
}
|
531
539
|
|
@@ -549,17 +557,17 @@ VALUE zkrb_string_vector_to_ruby(struct String_vector *string_vector) {
|
|
549
557
|
|
550
558
|
VALUE zkrb_stat_to_rarray(const struct Stat* stat) {
|
551
559
|
return rb_ary_new3(11,
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
560
|
+
LL2NUM(stat->czxid),
|
561
|
+
LL2NUM(stat->mzxid),
|
562
|
+
LL2NUM(stat->ctime),
|
563
|
+
LL2NUM(stat->mtime),
|
564
|
+
INT2NUM(stat->version),
|
565
|
+
INT2NUM(stat->cversion),
|
566
|
+
INT2NUM(stat->aversion),
|
567
|
+
LL2NUM(stat->ephemeralOwner),
|
568
|
+
INT2NUM(stat->dataLength),
|
569
|
+
INT2NUM(stat->numChildren),
|
570
|
+
LL2NUM(stat->pzxid));
|
563
571
|
}
|
564
572
|
|
565
573
|
VALUE zkrb_stat_to_rhash(const struct Stat *stat) {
|
data/ext/zookeeper_lib.h
CHANGED
@@ -109,6 +109,7 @@ void zkrb_event_free(zkrb_event_t *ptr);
|
|
109
109
|
void zkrb_enqueue(zkrb_queue_t *queue, zkrb_event_t *elt);
|
110
110
|
zkrb_event_t * zkrb_peek(zkrb_queue_t *queue);
|
111
111
|
zkrb_event_t * zkrb_dequeue(zkrb_queue_t *queue, int need_lock);
|
112
|
+
void zkrb_signal(zkrb_queue_t *queue);
|
112
113
|
|
113
114
|
void zkrb_print_stat(const struct Stat *s);
|
114
115
|
|
data/java/zookeeper_base.rb
CHANGED
@@ -179,6 +179,9 @@ class ZookeeperBase
|
|
179
179
|
|
180
180
|
watcher ||= get_default_global_watcher
|
181
181
|
|
182
|
+
# allows connected-state handlers to be registered before
|
183
|
+
yield self if block_given?
|
184
|
+
|
182
185
|
reopen(timeout, watcher)
|
183
186
|
return nil unless connected?
|
184
187
|
setup_dispatch_thread!
|
data/lib/zookeeper.rb
CHANGED
@@ -31,14 +31,14 @@ class Zookeeper < ZookeeperBase
|
|
31
31
|
assert_open
|
32
32
|
assert_supported_keys(options, [:path, :watcher, :watcher_context, :callback, :callback_context])
|
33
33
|
assert_required_keys(options, [:path])
|
34
|
-
|
34
|
+
|
35
35
|
req_id = setup_call(options)
|
36
36
|
rc, value, stat = super(req_id, options[:path], options[:callback], options[:watcher])
|
37
37
|
|
38
38
|
rv = { :req_id => req_id, :rc => rc }
|
39
39
|
options[:callback] ? rv : rv.merge(:data => value, :stat => Stat.new(stat))
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def set(options = {})
|
43
43
|
assert_open
|
44
44
|
assert_supported_keys(options, [:path, :data, :version, :callback, :callback_context])
|
@@ -51,7 +51,7 @@ class Zookeeper < ZookeeperBase
|
|
51
51
|
rv = { :req_id => req_id, :rc => rc }
|
52
52
|
options[:callback] ? rv : rv.merge(:stat => Stat.new(stat))
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def get_children(options = {})
|
56
56
|
assert_open
|
57
57
|
assert_supported_keys(options, [:path, :callback, :callback_context, :watcher, :watcher_context])
|
@@ -75,34 +75,34 @@ class Zookeeper < ZookeeperBase
|
|
75
75
|
rv = { :req_id => req_id, :rc => rc }
|
76
76
|
options[:callback] ? rv : rv.merge(:stat => Stat.new(stat))
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
def create(options = {})
|
80
80
|
assert_open
|
81
81
|
assert_supported_keys(options, [:path, :data, :acl, :ephemeral, :sequence, :callback, :callback_context])
|
82
82
|
assert_required_keys(options, [:path])
|
83
|
-
|
83
|
+
|
84
84
|
flags = 0
|
85
85
|
flags |= ZOO_EPHEMERAL if options[:ephemeral]
|
86
86
|
flags |= ZOO_SEQUENCE if options[:sequence]
|
87
87
|
|
88
88
|
options[:acl] ||= ZOO_OPEN_ACL_UNSAFE
|
89
|
-
|
89
|
+
|
90
90
|
req_id = setup_call(options)
|
91
91
|
rc, newpath = super(req_id, options[:path], options[:data], options[:callback], options[:acl], flags)
|
92
|
-
|
92
|
+
|
93
93
|
rv = { :req_id => req_id, :rc => rc }
|
94
|
-
options[:callback] ? rv : rv.merge(:path => newpath)
|
94
|
+
options[:callback] ? rv : rv.merge(:path => newpath)
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
def delete(options = {})
|
98
98
|
assert_open
|
99
99
|
assert_supported_keys(options, [:path, :version, :callback, :callback_context])
|
100
100
|
assert_required_keys(options, [:path])
|
101
101
|
options[:version] ||= -1
|
102
|
-
|
102
|
+
|
103
103
|
req_id = setup_call(options)
|
104
104
|
rc = super(req_id, options[:path], options[:version], options[:callback])
|
105
|
-
|
105
|
+
|
106
106
|
{ :req_id => req_id, :rc => rc }
|
107
107
|
end
|
108
108
|
|
@@ -111,21 +111,21 @@ class Zookeeper < ZookeeperBase
|
|
111
111
|
assert_supported_keys(options, [:path, :acl, :version, :callback, :callback_context])
|
112
112
|
assert_required_keys(options, [:path, :acl])
|
113
113
|
options[:version] ||= -1
|
114
|
-
|
114
|
+
|
115
115
|
req_id = setup_call(options)
|
116
116
|
rc = super(req_id, options[:path], options[:acl], options[:callback], options[:version])
|
117
|
-
|
117
|
+
|
118
118
|
{ :req_id => req_id, :rc => rc }
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
def get_acl(options = {})
|
122
122
|
assert_open
|
123
123
|
assert_supported_keys(options, [:path, :callback, :callback_context])
|
124
124
|
assert_required_keys(options, [:path])
|
125
|
-
|
125
|
+
|
126
126
|
req_id = setup_call(options)
|
127
127
|
rc, acls, stat = super(req_id, options[:path], options[:callback])
|
128
|
-
|
128
|
+
|
129
129
|
rv = { :req_id => req_id, :rc => rc }
|
130
130
|
options[:callback] ? rv : rv.merge(:acl => acls, :stat => Stat.new(stat))
|
131
131
|
end
|
@@ -157,7 +157,7 @@ private
|
|
157
157
|
}
|
158
158
|
req_id
|
159
159
|
end
|
160
|
-
|
160
|
+
|
161
161
|
def setup_watcher(req_id, call_opts)
|
162
162
|
@watcher_reqs[req_id] = { :watcher => call_opts[:watcher],
|
163
163
|
:context => call_opts[:watcher_context] }
|
data/slyphon-zookeeper.gemspec
CHANGED
@@ -3,9 +3,9 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "slyphon-zookeeper"
|
6
|
-
s.version = '0.1.
|
6
|
+
s.version = '0.1.6'
|
7
7
|
|
8
|
-
s.authors = ["Phillip Pearson", "Eric Maland", "Evan Weaver", "Brian Wickman", "Jonathan D. Simms"]
|
8
|
+
s.authors = ["Phillip Pearson", "Eric Maland", "Evan Weaver", "Brian Wickman", "Neil Conway", "Jonathan D. Simms"]
|
9
9
|
s.email = ["slyphon@gmail.com"]
|
10
10
|
s.summary = %q{twitter's zookeeper client}
|
11
11
|
s.description = s.summary
|
metadata
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slyphon-zookeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phillip Pearson
|
14
14
|
- Eric Maland
|
15
15
|
- Evan Weaver
|
16
16
|
- Brian Wickman
|
17
|
+
- Neil Conway
|
17
18
|
- Jonathan D. Simms
|
18
19
|
autorequire:
|
19
20
|
bindir: bin
|
20
21
|
cert_chain: []
|
21
22
|
|
22
|
-
date: 2011-
|
23
|
+
date: 2011-05-18 00:00:00 +00:00
|
23
24
|
default_executable:
|
24
25
|
dependencies:
|
25
26
|
- !ruby/object:Gem::Dependency
|
@@ -74,7 +75,7 @@ files:
|
|
74
75
|
- examples/cloud_config.rb
|
75
76
|
- ext/.gitignore
|
76
77
|
- ext/extconf.rb
|
77
|
-
- ext/zkc-3.3.
|
78
|
+
- ext/zkc-3.3.3.tar.gz
|
78
79
|
- ext/zookeeper_base.rb
|
79
80
|
- ext/zookeeper_c.c
|
80
81
|
- ext/zookeeper_lib.c
|
@@ -130,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
131
|
requirements: []
|
131
132
|
|
132
133
|
rubyforge_project:
|
133
|
-
rubygems_version: 1.
|
134
|
+
rubygems_version: 1.6.2
|
134
135
|
signing_key:
|
135
136
|
specification_version: 3
|
136
137
|
summary: twitter's zookeeper client
|
data/ext/zkc-3.3.2.tar.gz
DELETED
Binary file
|