slyphon-zookeeper 0.8.4-java → 0.9.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -4
- data/Rakefile +1 -1
- data/ext/Rakefile +23 -1
- data/ext/depend +3 -1
- data/ext/extconf.rb +4 -0
- data/ext/generate_gvl_code.rb +332 -0
- data/ext/zkrb_wrapper.c +917 -0
- data/ext/zkrb_wrapper.h +330 -0
- data/ext/zkrb_wrapper_compat.c +15 -0
- data/ext/zkrb_wrapper_compat.h +11 -0
- data/ext/zookeeper_c.c +53 -49
- data/lib/zookeeper.rb +1 -4
- data/slyphon-zookeeper.gemspec +1 -1
- metadata +11 -6
data/ext/zkrb_wrapper.h
ADDED
@@ -0,0 +1,330 @@
|
|
1
|
+
#ifndef ZKRB_WRAPPER_H
|
2
|
+
#define ZKRB_WRAPPER_H
|
3
|
+
#if 0
|
4
|
+
|
5
|
+
AUTOGENERATED BY generate_gvl_code.rb
|
6
|
+
|
7
|
+
#endif
|
8
|
+
|
9
|
+
#include "ruby.h"
|
10
|
+
#include "c-client-src/zookeeper.h"
|
11
|
+
#include "zkrb_wrapper_compat.h"
|
12
|
+
#include "dbg.h"
|
13
|
+
|
14
|
+
#define ZKRB_FAIL -1
|
15
|
+
|
16
|
+
typedef struct {
|
17
|
+
zhandle_t *zh;
|
18
|
+
int rc;
|
19
|
+
} zkrb_zoo_recv_timeout_args_t;
|
20
|
+
|
21
|
+
typedef struct {
|
22
|
+
zhandle_t *zh;
|
23
|
+
int rc;
|
24
|
+
} zkrb_zoo_state_args_t;
|
25
|
+
|
26
|
+
typedef struct {
|
27
|
+
zhandle_t *zh;
|
28
|
+
const char *path;
|
29
|
+
const char *value;
|
30
|
+
int valuelen;
|
31
|
+
const struct ACL_vector *acl;
|
32
|
+
int flags;
|
33
|
+
string_completion_t completion;
|
34
|
+
const void *data;
|
35
|
+
int rc;
|
36
|
+
} zkrb_zoo_acreate_args_t;
|
37
|
+
|
38
|
+
typedef struct {
|
39
|
+
zhandle_t *zh;
|
40
|
+
const char *path;
|
41
|
+
int version;
|
42
|
+
void_completion_t completion;
|
43
|
+
const void *data;
|
44
|
+
int rc;
|
45
|
+
} zkrb_zoo_adelete_args_t;
|
46
|
+
|
47
|
+
typedef struct {
|
48
|
+
zhandle_t *zh;
|
49
|
+
const char *path;
|
50
|
+
int watch;
|
51
|
+
stat_completion_t completion;
|
52
|
+
const void *data;
|
53
|
+
int rc;
|
54
|
+
} zkrb_zoo_aexists_args_t;
|
55
|
+
|
56
|
+
typedef struct {
|
57
|
+
zhandle_t *zh;
|
58
|
+
const char *path;
|
59
|
+
watcher_fn watcher;
|
60
|
+
void* watcherCtx;
|
61
|
+
stat_completion_t completion;
|
62
|
+
const void *data;
|
63
|
+
int rc;
|
64
|
+
} zkrb_zoo_awexists_args_t;
|
65
|
+
|
66
|
+
typedef struct {
|
67
|
+
zhandle_t *zh;
|
68
|
+
const char *path;
|
69
|
+
int watch;
|
70
|
+
data_completion_t completion;
|
71
|
+
const void *data;
|
72
|
+
int rc;
|
73
|
+
} zkrb_zoo_aget_args_t;
|
74
|
+
|
75
|
+
typedef struct {
|
76
|
+
zhandle_t *zh;
|
77
|
+
const char *path;
|
78
|
+
watcher_fn watcher;
|
79
|
+
void* watcherCtx;
|
80
|
+
data_completion_t completion;
|
81
|
+
const void *data;
|
82
|
+
int rc;
|
83
|
+
} zkrb_zoo_awget_args_t;
|
84
|
+
|
85
|
+
typedef struct {
|
86
|
+
zhandle_t *zh;
|
87
|
+
const char *path;
|
88
|
+
const char *buffer;
|
89
|
+
int buflen;
|
90
|
+
int version;
|
91
|
+
stat_completion_t completion;
|
92
|
+
const void *data;
|
93
|
+
int rc;
|
94
|
+
} zkrb_zoo_aset_args_t;
|
95
|
+
|
96
|
+
typedef struct {
|
97
|
+
zhandle_t *zh;
|
98
|
+
const char *path;
|
99
|
+
int watch;
|
100
|
+
strings_completion_t completion;
|
101
|
+
const void *data;
|
102
|
+
int rc;
|
103
|
+
} zkrb_zoo_aget_children_args_t;
|
104
|
+
|
105
|
+
typedef struct {
|
106
|
+
zhandle_t *zh;
|
107
|
+
const char *path;
|
108
|
+
watcher_fn watcher;
|
109
|
+
void* watcherCtx;
|
110
|
+
strings_completion_t completion;
|
111
|
+
const void *data;
|
112
|
+
int rc;
|
113
|
+
} zkrb_zoo_awget_children_args_t;
|
114
|
+
|
115
|
+
typedef struct {
|
116
|
+
zhandle_t *zh;
|
117
|
+
const char *path;
|
118
|
+
int watch;
|
119
|
+
strings_stat_completion_t completion;
|
120
|
+
const void *data;
|
121
|
+
int rc;
|
122
|
+
} zkrb_zoo_aget_children2_args_t;
|
123
|
+
|
124
|
+
typedef struct {
|
125
|
+
zhandle_t *zh;
|
126
|
+
const char *path;
|
127
|
+
watcher_fn watcher;
|
128
|
+
void* watcherCtx;
|
129
|
+
strings_stat_completion_t completion;
|
130
|
+
const void *data;
|
131
|
+
int rc;
|
132
|
+
} zkrb_zoo_awget_children2_args_t;
|
133
|
+
|
134
|
+
typedef struct {
|
135
|
+
zhandle_t *zh;
|
136
|
+
const char *path;
|
137
|
+
string_completion_t completion;
|
138
|
+
const void *data;
|
139
|
+
int rc;
|
140
|
+
} zkrb_zoo_async_args_t;
|
141
|
+
|
142
|
+
typedef struct {
|
143
|
+
zhandle_t *zh;
|
144
|
+
const char *path;
|
145
|
+
acl_completion_t completion;
|
146
|
+
const void *data;
|
147
|
+
int rc;
|
148
|
+
} zkrb_zoo_aget_acl_args_t;
|
149
|
+
|
150
|
+
typedef struct {
|
151
|
+
zhandle_t *zh;
|
152
|
+
const char *path;
|
153
|
+
int version;
|
154
|
+
struct ACL_vector *acl;
|
155
|
+
void_completion_t completion;
|
156
|
+
const void *data;
|
157
|
+
int rc;
|
158
|
+
} zkrb_zoo_aset_acl_args_t;
|
159
|
+
|
160
|
+
typedef struct {
|
161
|
+
zhandle_t *zh;
|
162
|
+
const char* scheme;
|
163
|
+
const char* cert;
|
164
|
+
int certLen;
|
165
|
+
void_completion_t completion;
|
166
|
+
const void *data;
|
167
|
+
int rc;
|
168
|
+
} zkrb_zoo_add_auth_args_t;
|
169
|
+
|
170
|
+
typedef struct {
|
171
|
+
zhandle_t *zh;
|
172
|
+
const char *path;
|
173
|
+
const char *value;
|
174
|
+
int valuelen;
|
175
|
+
const struct ACL_vector *acl;
|
176
|
+
int flags;
|
177
|
+
char *path_buffer;
|
178
|
+
int path_buffer_len;
|
179
|
+
int rc;
|
180
|
+
} zkrb_zoo_create_args_t;
|
181
|
+
|
182
|
+
typedef struct {
|
183
|
+
zhandle_t *zh;
|
184
|
+
const char *path;
|
185
|
+
int version;
|
186
|
+
int rc;
|
187
|
+
} zkrb_zoo_delete_args_t;
|
188
|
+
|
189
|
+
typedef struct {
|
190
|
+
zhandle_t *zh;
|
191
|
+
const char *path;
|
192
|
+
int watch;
|
193
|
+
struct Stat *stat;
|
194
|
+
int rc;
|
195
|
+
} zkrb_zoo_exists_args_t;
|
196
|
+
|
197
|
+
typedef struct {
|
198
|
+
zhandle_t *zh;
|
199
|
+
const char *path;
|
200
|
+
watcher_fn watcher;
|
201
|
+
void* watcherCtx;
|
202
|
+
struct Stat *stat;
|
203
|
+
int rc;
|
204
|
+
} zkrb_zoo_wexists_args_t;
|
205
|
+
|
206
|
+
typedef struct {
|
207
|
+
zhandle_t *zh;
|
208
|
+
const char *path;
|
209
|
+
int watch;
|
210
|
+
char *buffer;
|
211
|
+
int* buffer_len;
|
212
|
+
struct Stat *stat;
|
213
|
+
int rc;
|
214
|
+
} zkrb_zoo_get_args_t;
|
215
|
+
|
216
|
+
typedef struct {
|
217
|
+
zhandle_t *zh;
|
218
|
+
const char *path;
|
219
|
+
watcher_fn watcher;
|
220
|
+
void* watcherCtx;
|
221
|
+
char *buffer;
|
222
|
+
int* buffer_len;
|
223
|
+
struct Stat *stat;
|
224
|
+
int rc;
|
225
|
+
} zkrb_zoo_wget_args_t;
|
226
|
+
|
227
|
+
typedef struct {
|
228
|
+
zhandle_t *zh;
|
229
|
+
const char *path;
|
230
|
+
const char *buffer;
|
231
|
+
int buflen;
|
232
|
+
int version;
|
233
|
+
int rc;
|
234
|
+
} zkrb_zoo_set_args_t;
|
235
|
+
|
236
|
+
typedef struct {
|
237
|
+
zhandle_t *zh;
|
238
|
+
const char *path;
|
239
|
+
const char *buffer;
|
240
|
+
int buflen;
|
241
|
+
int version;
|
242
|
+
struct Stat *stat;
|
243
|
+
int rc;
|
244
|
+
} zkrb_zoo_set2_args_t;
|
245
|
+
|
246
|
+
typedef struct {
|
247
|
+
zhandle_t *zh;
|
248
|
+
const char *path;
|
249
|
+
int watch;
|
250
|
+
struct String_vector *strings;
|
251
|
+
int rc;
|
252
|
+
} zkrb_zoo_get_children_args_t;
|
253
|
+
|
254
|
+
typedef struct {
|
255
|
+
zhandle_t *zh;
|
256
|
+
const char *path;
|
257
|
+
watcher_fn watcher;
|
258
|
+
void* watcherCtx;
|
259
|
+
struct String_vector *strings;
|
260
|
+
int rc;
|
261
|
+
} zkrb_zoo_wget_children_args_t;
|
262
|
+
|
263
|
+
typedef struct {
|
264
|
+
zhandle_t *zh;
|
265
|
+
const char *path;
|
266
|
+
int watch;
|
267
|
+
struct String_vector *strings;
|
268
|
+
struct Stat *stat;
|
269
|
+
int rc;
|
270
|
+
} zkrb_zoo_get_children2_args_t;
|
271
|
+
|
272
|
+
typedef struct {
|
273
|
+
zhandle_t *zh;
|
274
|
+
const char *path;
|
275
|
+
watcher_fn watcher;
|
276
|
+
void* watcherCtx;
|
277
|
+
struct String_vector *strings;
|
278
|
+
struct Stat *stat;
|
279
|
+
int rc;
|
280
|
+
} zkrb_zoo_wget_children2_args_t;
|
281
|
+
|
282
|
+
typedef struct {
|
283
|
+
zhandle_t *zh;
|
284
|
+
const char *path;
|
285
|
+
struct ACL_vector *acl;
|
286
|
+
struct Stat *stat;
|
287
|
+
int rc;
|
288
|
+
} zkrb_zoo_get_acl_args_t;
|
289
|
+
|
290
|
+
typedef struct {
|
291
|
+
zhandle_t *zh;
|
292
|
+
const char *path;
|
293
|
+
int version;
|
294
|
+
const struct ACL_vector *acl;
|
295
|
+
int rc;
|
296
|
+
} zkrb_zoo_set_acl_args_t;
|
297
|
+
|
298
|
+
int zkrb_call_zoo_recv_timeout(zhandle_t *zh);
|
299
|
+
int zkrb_call_zoo_state(zhandle_t *zh);
|
300
|
+
int zkrb_call_zoo_acreate(zhandle_t *zh, const char *path, const char *value, int valuelen, const struct ACL_vector *acl, int flags, string_completion_t completion, const void *data);
|
301
|
+
int zkrb_call_zoo_adelete(zhandle_t *zh, const char *path, int version, void_completion_t completion, const void *data);
|
302
|
+
int zkrb_call_zoo_aexists(zhandle_t *zh, const char *path, int watch, stat_completion_t completion, const void *data);
|
303
|
+
int zkrb_call_zoo_awexists(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, stat_completion_t completion, const void *data);
|
304
|
+
int zkrb_call_zoo_aget(zhandle_t *zh, const char *path, int watch, data_completion_t completion, const void *data);
|
305
|
+
int zkrb_call_zoo_awget(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, data_completion_t completion, const void *data);
|
306
|
+
int zkrb_call_zoo_aset(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, stat_completion_t completion, const void *data);
|
307
|
+
int zkrb_call_zoo_aget_children(zhandle_t *zh, const char *path, int watch, strings_completion_t completion, const void *data);
|
308
|
+
int zkrb_call_zoo_awget_children(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, strings_completion_t completion, const void *data);
|
309
|
+
int zkrb_call_zoo_aget_children2(zhandle_t *zh, const char *path, int watch, strings_stat_completion_t completion, const void *data);
|
310
|
+
int zkrb_call_zoo_awget_children2(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, strings_stat_completion_t completion, const void *data);
|
311
|
+
int zkrb_call_zoo_async(zhandle_t *zh, const char *path, string_completion_t completion, const void *data);
|
312
|
+
int zkrb_call_zoo_aget_acl(zhandle_t *zh, const char *path, acl_completion_t completion, const void *data);
|
313
|
+
int zkrb_call_zoo_aset_acl(zhandle_t *zh, const char *path, int version, struct ACL_vector *acl, void_completion_t completion, const void *data);
|
314
|
+
int zkrb_call_zoo_add_auth(zhandle_t *zh, const char* scheme, const char* cert, int certLen, void_completion_t completion, const void *data);
|
315
|
+
int zkrb_call_zoo_create(zhandle_t *zh, const char *path, const char *value, int valuelen, const struct ACL_vector *acl, int flags, char *path_buffer, int path_buffer_len);
|
316
|
+
int zkrb_call_zoo_delete(zhandle_t *zh, const char *path, int version);
|
317
|
+
int zkrb_call_zoo_exists(zhandle_t *zh, const char *path, int watch, struct Stat *stat);
|
318
|
+
int zkrb_call_zoo_wexists(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, struct Stat *stat);
|
319
|
+
int zkrb_call_zoo_get(zhandle_t *zh, const char *path, int watch, char *buffer, int* buffer_len, struct Stat *stat);
|
320
|
+
int zkrb_call_zoo_wget(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, char *buffer, int* buffer_len, struct Stat *stat);
|
321
|
+
int zkrb_call_zoo_set(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version);
|
322
|
+
int zkrb_call_zoo_set2(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, struct Stat *stat);
|
323
|
+
int zkrb_call_zoo_get_children(zhandle_t *zh, const char *path, int watch, struct String_vector *strings);
|
324
|
+
int zkrb_call_zoo_wget_children(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, struct String_vector *strings);
|
325
|
+
int zkrb_call_zoo_get_children2(zhandle_t *zh, const char *path, int watch, struct String_vector *strings, struct Stat *stat);
|
326
|
+
int zkrb_call_zoo_wget_children2(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, struct String_vector *strings, struct Stat *stat);
|
327
|
+
int zkrb_call_zoo_get_acl(zhandle_t *zh, const char *path, struct ACL_vector *acl, struct Stat *stat);
|
328
|
+
int zkrb_call_zoo_set_acl(zhandle_t *zh, const char *path, int version, const struct ACL_vector *acl);
|
329
|
+
|
330
|
+
#endif /* ZKRB_WRAPPER_H */
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#include "ruby.h"
|
2
|
+
#include "zkrb_wrapper_compat.h"
|
3
|
+
|
4
|
+
|
5
|
+
VALUE zkrb_thread_blocking_region(zkrb_blocking_function_t *func, void *data1) {
|
6
|
+
|
7
|
+
#ifdef ZKRB_RUBY_187
|
8
|
+
return func(data1);
|
9
|
+
#else
|
10
|
+
return rb_thread_blocking_region((rb_blocking_function_t *)func, data1, RUBY_UBF_IO, 0);
|
11
|
+
#endif
|
12
|
+
|
13
|
+
}
|
14
|
+
|
15
|
+
// vim:sts=2:sw=2:et
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#ifndef ZKRB_WRAPPER_COMPAT_H
|
2
|
+
#define ZKRB_WRAPPER_COMPAT_H
|
3
|
+
|
4
|
+
typedef VALUE zkrb_blocking_function_t(void *);
|
5
|
+
typedef void zkrb_unblock_function_t(void *);
|
6
|
+
|
7
|
+
// delegates to rb_thread_blocking_region on 1.9.x, always uses UBF_IO
|
8
|
+
VALUE zkrb_thread_blocking_region(zkrb_blocking_function_t *func, void *data1);
|
9
|
+
|
10
|
+
|
11
|
+
#endif /* ZKRB_WRAPPER_COMPAT_H */
|
data/ext/zookeeper_c.c
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
#include <inttypes.h>
|
24
24
|
|
25
25
|
#include "zookeeper_lib.h"
|
26
|
+
#include "zkrb_wrapper.h"
|
26
27
|
#include "dbg.h"
|
27
28
|
|
28
29
|
static VALUE Zookeeper = Qnil;
|
@@ -193,35 +194,35 @@ error:
|
|
193
194
|
return Qnil;
|
194
195
|
}
|
195
196
|
|
196
|
-
#define FETCH_DATA_PTR(
|
197
|
-
struct zkrb_instance_data *
|
198
|
-
Data_Get_Struct(rb_iv_get(
|
199
|
-
if ((
|
197
|
+
#define FETCH_DATA_PTR(X, Y) \
|
198
|
+
struct zkrb_instance_data * Y; \
|
199
|
+
Data_Get_Struct(rb_iv_get(X, "@_data"), struct zkrb_instance_data, Y); \
|
200
|
+
if ((Y)->zh == NULL) \
|
200
201
|
rb_raise(rb_eRuntimeError, "zookeeper handle is closed")
|
201
202
|
|
202
203
|
#define STANDARD_PREAMBLE(self, zk, reqid, path, async, watch, cb_ctx, w_ctx, call_type) \
|
203
|
-
if (TYPE(reqid) != T_FIXNUM && TYPE(reqid) != T_BIGNUM) {
|
204
|
-
rb_raise(rb_eTypeError, "reqid must be Fixnum/Bignum");
|
205
|
-
return Qnil;
|
206
|
-
}
|
207
|
-
Check_Type(path, T_STRING);
|
208
|
-
struct zkrb_instance_data * zk;
|
209
|
-
Data_Get_Struct(rb_iv_get(self, "@_data"), struct zkrb_instance_data, zk);
|
210
|
-
if (!zk->zh)
|
211
|
-
rb_raise(rb_eRuntimeError, "zookeeper handle is closed");
|
212
|
-
zkrb_calling_context* cb_ctx =
|
213
|
-
(async != Qfalse && async != Qnil) ?
|
214
|
-
zkrb_calling_context_alloc(NUM2LL(reqid), zk->queue) :
|
215
|
-
NULL;
|
216
|
-
zkrb_calling_context* w_ctx =
|
217
|
-
(watch != Qfalse && watch != Qnil) ?
|
218
|
-
zkrb_calling_context_alloc(NUM2LL(reqid), zk->queue) :
|
219
|
-
NULL;
|
220
|
-
int
|
221
|
-
int
|
222
|
-
zkrb_call_type call_type;
|
223
|
-
if (
|
224
|
-
|
204
|
+
if (TYPE(reqid) != T_FIXNUM && TYPE(reqid) != T_BIGNUM) { \
|
205
|
+
rb_raise(rb_eTypeError, "reqid must be Fixnum/Bignum"); \
|
206
|
+
return Qnil; \
|
207
|
+
} \
|
208
|
+
Check_Type(path, T_STRING); \
|
209
|
+
struct zkrb_instance_data * zk; \
|
210
|
+
Data_Get_Struct(rb_iv_get(self, "@_data"), struct zkrb_instance_data, zk); \
|
211
|
+
if (!zk->zh) \
|
212
|
+
rb_raise(rb_eRuntimeError, "zookeeper handle is closed"); \
|
213
|
+
zkrb_calling_context* cb_ctx = \
|
214
|
+
(async != Qfalse && async != Qnil) ? \
|
215
|
+
zkrb_calling_context_alloc(NUM2LL(reqid), zk->queue) : \
|
216
|
+
NULL; \
|
217
|
+
zkrb_calling_context* w_ctx = \
|
218
|
+
(watch != Qfalse && watch != Qnil) ? \
|
219
|
+
zkrb_calling_context_alloc(NUM2LL(reqid), zk->queue) : \
|
220
|
+
NULL; \
|
221
|
+
int a_ = (async != Qfalse && async != Qnil); \
|
222
|
+
int w_ = (watch != Qfalse && watch != Qnil); \
|
223
|
+
zkrb_call_type call_type; \
|
224
|
+
if (a_) { if (w_) { call_type = ASYNC_WATCH; } else { call_type = ASYNC; } } \
|
225
|
+
else { if (w_) { call_type = SYNC_WATCH; } else { call_type = SYNC; } }
|
225
226
|
|
226
227
|
static VALUE method_get_children(VALUE self, VALUE reqid, VALUE path, VALUE async, VALUE watch) {
|
227
228
|
STANDARD_PREAMBLE(self, zk, reqid, path, async, watch, data_ctx, watch_ctx, call_type);
|
@@ -232,19 +233,19 @@ static VALUE method_get_children(VALUE self, VALUE reqid, VALUE path, VALUE asyn
|
|
232
233
|
int rc;
|
233
234
|
switch (call_type) {
|
234
235
|
case SYNC:
|
235
|
-
rc =
|
236
|
+
rc = zkrb_call_zoo_get_children2(zk->zh, RSTRING_PTR(path), 0, &strings, &stat);
|
236
237
|
break;
|
237
238
|
|
238
239
|
case SYNC_WATCH:
|
239
|
-
rc =
|
240
|
+
rc = zkrb_call_zoo_wget_children2(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, &strings, &stat);
|
240
241
|
break;
|
241
242
|
|
242
243
|
case ASYNC:
|
243
|
-
rc =
|
244
|
+
rc = zkrb_call_zoo_aget_children2(zk->zh, RSTRING_PTR(path), 0, zkrb_strings_stat_callback, data_ctx);
|
244
245
|
break;
|
245
246
|
|
246
247
|
case ASYNC_WATCH:
|
247
|
-
rc =
|
248
|
+
rc = zkrb_call_zoo_awget_children2(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, zkrb_strings_stat_callback, data_ctx);
|
248
249
|
break;
|
249
250
|
}
|
250
251
|
|
@@ -265,19 +266,19 @@ static VALUE method_exists(VALUE self, VALUE reqid, VALUE path, VALUE async, VAL
|
|
265
266
|
int rc;
|
266
267
|
switch (call_type) {
|
267
268
|
case SYNC:
|
268
|
-
rc =
|
269
|
+
rc = zkrb_call_zoo_exists(zk->zh, RSTRING_PTR(path), 0, &stat);
|
269
270
|
break;
|
270
271
|
|
271
272
|
case SYNC_WATCH:
|
272
|
-
rc =
|
273
|
+
rc = zkrb_call_zoo_wexists(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, &stat);
|
273
274
|
break;
|
274
275
|
|
275
276
|
case ASYNC:
|
276
|
-
rc =
|
277
|
+
rc = zkrb_call_zoo_aexists(zk->zh, RSTRING_PTR(path), 0, zkrb_stat_callback, data_ctx);
|
277
278
|
break;
|
278
279
|
|
279
280
|
case ASYNC_WATCH:
|
280
|
-
rc =
|
281
|
+
rc = zkrb_call_zoo_awexists(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, zkrb_stat_callback, data_ctx);
|
281
282
|
break;
|
282
283
|
}
|
283
284
|
|
@@ -297,7 +298,7 @@ static VALUE method_sync(VALUE self, VALUE reqid, VALUE path) {
|
|
297
298
|
|
298
299
|
STANDARD_PREAMBLE(self, zk, reqid, path, async, watch, data_ctx, watch_ctx, call_type);
|
299
300
|
|
300
|
-
rc =
|
301
|
+
rc = zkrb_call_zoo_async(zk->zh, RSTRING_PTR(path), zkrb_string_callback, data_ctx);
|
301
302
|
|
302
303
|
return INT2FIX(rc);
|
303
304
|
}
|
@@ -319,10 +320,12 @@ static VALUE method_create(VALUE self, VALUE reqid, VALUE path, VALUE data, VALU
|
|
319
320
|
switch (call_type) {
|
320
321
|
case SYNC:
|
321
322
|
// casting data_len to int is OK as you can only store 1MB in zookeeper
|
322
|
-
rc =
|
323
|
+
rc = zkrb_call_zoo_create(zk->zh, RSTRING_PTR(path), data_ptr, (int)data_len, aclptr, FIX2INT(flags), realpath, sizeof(realpath));
|
324
|
+
|
323
325
|
break;
|
324
326
|
case ASYNC:
|
325
|
-
rc =
|
327
|
+
rc = zkrb_call_zoo_acreate(zk->zh, RSTRING_PTR(path), data_ptr, (int)data_len, aclptr, FIX2INT(flags), zkrb_string_callback, data_ctx);
|
328
|
+
|
326
329
|
break;
|
327
330
|
default:
|
328
331
|
/* TODO(wickman) raise proper argument error */
|
@@ -330,6 +333,7 @@ static VALUE method_create(VALUE self, VALUE reqid, VALUE path, VALUE data, VALU
|
|
330
333
|
break;
|
331
334
|
}
|
332
335
|
|
336
|
+
|
333
337
|
if (aclptr) {
|
334
338
|
deallocate_ACL_vector(aclptr);
|
335
339
|
free(aclptr);
|
@@ -351,10 +355,10 @@ static VALUE method_delete(VALUE self, VALUE reqid, VALUE path, VALUE version, V
|
|
351
355
|
int rc = 0;
|
352
356
|
switch (call_type) {
|
353
357
|
case SYNC:
|
354
|
-
rc =
|
358
|
+
rc = zkrb_call_zoo_delete(zk->zh, RSTRING_PTR(path), FIX2INT(version));
|
355
359
|
break;
|
356
360
|
case ASYNC:
|
357
|
-
rc =
|
361
|
+
rc = zkrb_call_zoo_adelete(zk->zh, RSTRING_PTR(path), FIX2INT(version), zkrb_void_callback, data_ctx);
|
358
362
|
break;
|
359
363
|
default:
|
360
364
|
/* TODO(wickman) raise proper argument error */
|
@@ -379,19 +383,19 @@ static VALUE method_get(VALUE self, VALUE reqid, VALUE path, VALUE async, VALUE
|
|
379
383
|
|
380
384
|
switch (call_type) {
|
381
385
|
case SYNC:
|
382
|
-
rc =
|
386
|
+
rc = zkrb_call_zoo_get(zk->zh, RSTRING_PTR(path), 0, data, &data_len, &stat);
|
383
387
|
break;
|
384
388
|
|
385
389
|
case SYNC_WATCH:
|
386
|
-
rc =
|
390
|
+
rc = zkrb_call_zoo_wget(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, data, &data_len, &stat);
|
387
391
|
break;
|
388
392
|
|
389
393
|
case ASYNC:
|
390
|
-
rc =
|
394
|
+
rc = zkrb_call_zoo_aget(zk->zh, RSTRING_PTR(path), 0, zkrb_data_callback, data_ctx);
|
391
395
|
break;
|
392
396
|
|
393
397
|
case ASYNC_WATCH:
|
394
|
-
rc =
|
398
|
+
rc = zkrb_call_zoo_awget(zk->zh, RSTRING_PTR(path), zkrb_state_callback, watch_ctx, zkrb_data_callback, data_ctx);
|
395
399
|
break;
|
396
400
|
}
|
397
401
|
|
@@ -421,10 +425,10 @@ static VALUE method_set(VALUE self, VALUE reqid, VALUE path, VALUE data, VALUE a
|
|
421
425
|
int rc;
|
422
426
|
switch (call_type) {
|
423
427
|
case SYNC:
|
424
|
-
rc =
|
428
|
+
rc = zkrb_call_zoo_set2(zk->zh, RSTRING_PTR(path), data_ptr, (int)data_len, FIX2INT(version), &stat);
|
425
429
|
break;
|
426
430
|
case ASYNC:
|
427
|
-
rc =
|
431
|
+
rc = zkrb_call_zoo_aset(zk->zh, RSTRING_PTR(path), data_ptr, (int)data_len, FIX2INT(version),
|
428
432
|
zkrb_stat_callback, data_ctx);
|
429
433
|
break;
|
430
434
|
default:
|
@@ -449,10 +453,10 @@ static VALUE method_set_acl(VALUE self, VALUE reqid, VALUE path, VALUE acls, VAL
|
|
449
453
|
int rc;
|
450
454
|
switch (call_type) {
|
451
455
|
case SYNC:
|
452
|
-
rc =
|
456
|
+
rc = zkrb_call_zoo_set_acl(zk->zh, RSTRING_PTR(path), FIX2INT(version), aclptr);
|
453
457
|
break;
|
454
458
|
case ASYNC:
|
455
|
-
rc =
|
459
|
+
rc = zkrb_call_zoo_aset_acl(zk->zh, RSTRING_PTR(path), FIX2INT(version), aclptr, zkrb_void_callback, data_ctx);
|
456
460
|
break;
|
457
461
|
default:
|
458
462
|
/* TODO(wickman) raise proper argument error */
|
@@ -476,10 +480,10 @@ static VALUE method_get_acl(VALUE self, VALUE reqid, VALUE path, VALUE async) {
|
|
476
480
|
int rc;
|
477
481
|
switch (call_type) {
|
478
482
|
case SYNC:
|
479
|
-
rc =
|
483
|
+
rc = zkrb_call_zoo_get_acl(zk->zh, RSTRING_PTR(path), &acls, &stat);
|
480
484
|
break;
|
481
485
|
case ASYNC:
|
482
|
-
rc =
|
486
|
+
rc = zkrb_call_zoo_aget_acl(zk->zh, RSTRING_PTR(path), zkrb_acl_callback, data_ctx);
|
483
487
|
break;
|
484
488
|
default:
|
485
489
|
/* TODO(wickman) raise proper argument error */
|