zookeeper-3.4.3
Main Page
Data Structures
Files
File List
Globals
include
zookeeper.h
Go to the documentation of this file.
1
19
#ifndef ZOOKEEPER_H_
20
#define ZOOKEEPER_H_
21
22
#include <stdlib.h>
23
#ifndef WIN32
24
#include <sys/socket.h>
25
#include <sys/time.h>
26
#else
27
#include "winconfig.h"
28
#endif
29
#include <stdio.h>
30
#include <ctype.h>
31
32
#include "proto.h"
33
#include "zookeeper_version.h"
34
#include "recordio.h"
35
#include "zookeeper.jute.h"
36
65
/* Support for building on various platforms */
66
67
// on cygwin we should take care of exporting/importing symbols properly
68
#ifdef DLL_EXPORT
69
# define ZOOAPI __declspec(dllexport)
70
#else
71
# if (defined(__CYGWIN__) || defined(WIN32)) && !defined(USE_STATIC_LIB)
72
# define ZOOAPI __declspec(dllimport)
73
# else
74
# define ZOOAPI
75
# endif
76
#endif
77
80
enum
ZOO_ERRORS
{
81
ZOK
= 0,
87
ZSYSTEMERROR
= -1,
88
ZRUNTIMEINCONSISTENCY
= -2,
89
ZDATAINCONSISTENCY
= -3,
90
ZCONNECTIONLOSS
= -4,
91
ZMARSHALLINGERROR
= -5,
92
ZUNIMPLEMENTED
= -6,
93
ZOPERATIONTIMEOUT
= -7,
94
ZBADARGUMENTS
= -8,
95
ZINVALIDSTATE
= -9,
103
ZAPIERROR
= -100,
104
ZNONODE
= -101,
105
ZNOAUTH
= -102,
106
ZBADVERSION
= -103,
107
ZNOCHILDRENFOREPHEMERALS
= -108,
108
ZNODEEXISTS
= -110,
109
ZNOTEMPTY
= -111,
110
ZSESSIONEXPIRED
= -112,
111
ZINVALIDCALLBACK
= -113,
112
ZINVALIDACL
= -114,
113
ZAUTHFAILED
= -115,
114
ZCLOSING
= -116,
115
ZNOTHING
= -117,
116
ZSESSIONMOVED
= -118
117
};
118
119
#ifdef __cplusplus
120
extern
"C"
{
121
#endif
122
126
typedef
enum
{ZOO_LOG_LEVEL_ERROR=1,ZOO_LOG_LEVEL_WARN=2,ZOO_LOG_LEVEL_INFO=3,ZOO_LOG_LEVEL_DEBUG=4} ZooLogLevel;
127
131
extern
ZOOAPI
const
int
ZOO_PERM_READ;
132
extern
ZOOAPI
const
int
ZOO_PERM_WRITE;
133
extern
ZOOAPI
const
int
ZOO_PERM_CREATE;
134
extern
ZOOAPI
const
int
ZOO_PERM_DELETE;
135
extern
ZOOAPI
const
int
ZOO_PERM_ADMIN;
136
extern
ZOOAPI
const
int
ZOO_PERM_ALL;
137
139
extern
ZOOAPI
struct
Id
ZOO_ANYONE_ID_UNSAFE
;
143
extern
ZOOAPI
struct
Id
ZOO_AUTH_IDS
;
144
146
extern
ZOOAPI
struct
ACL_vector
ZOO_OPEN_ACL_UNSAFE
;
148
extern
ZOOAPI
struct
ACL_vector
ZOO_READ_ACL_UNSAFE
;
150
extern
ZOOAPI
struct
ACL_vector
ZOO_CREATOR_ALL_ACL
;
151
160
// @{
161
extern
ZOOAPI
const
int
ZOOKEEPER_WRITE;
162
extern
ZOOAPI
const
int
ZOOKEEPER_READ;
163
// @}
164
171
// @{
172
extern
ZOOAPI
const
int
ZOO_EPHEMERAL;
173
extern
ZOOAPI
const
int
ZOO_SEQUENCE;
174
// @}
175
181
// @{
182
extern
ZOOAPI
const
int
ZOO_EXPIRED_SESSION_STATE;
183
extern
ZOOAPI
const
int
ZOO_AUTH_FAILED_STATE;
184
extern
ZOOAPI
const
int
ZOO_CONNECTING_STATE;
185
extern
ZOOAPI
const
int
ZOO_ASSOCIATING_STATE;
186
extern
ZOOAPI
const
int
ZOO_CONNECTED_STATE;
187
// @}
188
194
// @{
201
extern
ZOOAPI
const
int
ZOO_CREATED_EVENT
;
208
extern
ZOOAPI
const
int
ZOO_DELETED_EVENT
;
215
extern
ZOOAPI
const
int
ZOO_CHANGED_EVENT
;
222
extern
ZOOAPI
const
int
ZOO_CHILD_EVENT
;
228
extern
ZOOAPI
const
int
ZOO_SESSION_EVENT
;
229
236
extern
ZOOAPI
const
int
ZOO_NOTWATCHING_EVENT
;
237
// @}
238
246
typedef
struct
_zhandle
zhandle_t
;
247
255
typedef
struct
{
256
int64_t client_id;
257
char
passwd[16];
258
}
clientid_t
;
259
269
typedef
struct
zoo_op
{
270
int
type;
271
union
{
272
// CREATE
273
struct
{
274
const
char
*path;
275
const
char
*data;
276
int
datalen;
277
char
*buf;
278
int
buflen;
279
const
struct
ACL_vector *acl;
280
int
flags;
281
} create_op;
282
283
// DELETE
284
struct
{
285
const
char
*path;
286
int
version;
287
} delete_op;
288
289
// SET
290
struct
{
291
const
char
*path;
292
const
char
*data;
293
int
datalen;
294
int
version;
295
struct
Stat *stat;
296
} set_op;
297
298
// CHECK
299
struct
{
300
const
char
*path;
301
int
version;
302
} check_op;
303
};
304
}
zoo_op_t
;
305
330
void
zoo_create_op_init
(
zoo_op_t
*op,
const
char
*path,
const
char
*value,
331
int
valuelen,
const
struct
ACL_vector *acl,
int
flags,
332
char
*path_buffer,
int
path_buffer_len);
333
346
void
zoo_delete_op_init
(
zoo_op_t
*op,
const
char
*path,
int
version);
347
363
void
zoo_set_op_init
(
zoo_op_t
*op,
const
char
*path,
const
char
*buffer,
364
int
buflen,
int
version,
struct
Stat *stat);
365
377
void
zoo_check_op_init
(
zoo_op_t
*op,
const
char
*path,
int
version);
378
385
typedef
struct
zoo_op_result
{
386
int
err;
387
char
*value;
388
int
valuelen;
389
struct
Stat *stat;
390
}
zoo_op_result_t
;
391
418
typedef
void (*
watcher_fn
)(
zhandle_t
*zh,
int
type,
419
int
state,
const
char
*path,
void
*watcherCtx);
420
449
ZOOAPI
zhandle_t
*
zookeeper_init
(
const
char
*host,
watcher_fn
fn,
450
int
recv_timeout,
const
clientid_t
*clientid,
void
*context,
int
flags);
451
474
ZOOAPI
int
zookeeper_close
(
zhandle_t
*zh);
475
480
ZOOAPI
const
clientid_t
*
zoo_client_id
(
zhandle_t
*zh);
481
487
ZOOAPI
int
zoo_recv_timeout
(
zhandle_t
*zh);
488
492
ZOOAPI
const
void
*
zoo_get_context
(
zhandle_t
*zh);
493
497
ZOOAPI
void
zoo_set_context
(
zhandle_t
*zh,
void
*context);
498
503
ZOOAPI
watcher_fn
zoo_set_watcher
(
zhandle_t
*zh,
watcher_fn
newFn);
504
510
ZOOAPI
struct
sockaddr*
zookeeper_get_connected_host
(
zhandle_t
*zh,
511
struct
sockaddr *addr, socklen_t *addr_len);
512
513
#ifndef THREADED
514
533
#ifdef WIN32
534
ZOOAPI
int
zookeeper_interest
(
zhandle_t
*zh, SOCKET *fd,
int
*interest,
535
struct
timeval *tv);
536
#else
537
ZOOAPI
int
zookeeper_interest
(
zhandle_t
*zh,
int
*fd,
int
*interest,
538
struct
timeval *tv);
539
#endif
540
558
ZOOAPI
int
zookeeper_process
(
zhandle_t
*zh,
int
events);
559
#endif
560
578
typedef
void (*
void_completion_t
)(
int
rc,
const
void
*data);
579
600
typedef
void (*
stat_completion_t
)(
int
rc,
const
struct
Stat *stat,
601
const
void
*data);
602
627
typedef
void (*
data_completion_t
)(
int
rc,
const
char
*value,
int
value_len,
628
const
struct
Stat *stat,
const
void
*data);
629
651
typedef
void (*
strings_completion_t
)(
int
rc,
652
const
struct
String_vector *strings,
const
void
*data);
653
679
typedef
void (*
strings_stat_completion_t
)(
int
rc,
680
const
struct
String_vector *strings,
const
struct
Stat *stat,
681
const
void
*data);
682
701
typedef
void
702
(*
string_completion_t
)(
int
rc,
const
char
*value,
const
void
*data);
703
727
typedef
void (*
acl_completion_t
)(
int
rc,
struct
ACL_vector *acl,
728
struct
Stat *stat,
const
void
*data);
729
735
ZOOAPI
int
zoo_state
(
zhandle_t
*zh);
736
769
ZOOAPI
int
zoo_acreate
(
zhandle_t
*zh,
const
char
*path,
const
char
*value,
770
int
valuelen,
const
struct
ACL_vector *acl,
int
flags,
771
string_completion_t
completion,
const
void
*data);
772
796
ZOOAPI
int
zoo_adelete
(
zhandle_t
*zh,
const
char
*path,
int
version,
797
void_completion_t
completion,
const
void
*data);
798
820
ZOOAPI
int
zoo_aexists
(
zhandle_t
*zh,
const
char
*path,
int
watch,
821
stat_completion_t
completion,
const
void
*data);
822
852
ZOOAPI
int
zoo_awexists
(
zhandle_t
*zh,
const
char
*path,
853
watcher_fn
watcher,
void
* watcherCtx,
854
stat_completion_t
completion,
const
void
*data);
855
876
ZOOAPI
int
zoo_aget
(
zhandle_t
*zh,
const
char
*path,
int
watch,
877
data_completion_t
completion,
const
void
*data);
878
905
ZOOAPI
int
zoo_awget
(
zhandle_t
*zh,
const
char
*path,
906
watcher_fn
watcher,
void
* watcherCtx,
907
data_completion_t
completion,
const
void
*data);
908
935
ZOOAPI
int
zoo_aset
(
zhandle_t
*zh,
const
char
*path,
const
char
*buffer,
int
buflen,
936
int
version,
stat_completion_t
completion,
const
void
*data);
937
958
ZOOAPI
int
zoo_aget_children
(
zhandle_t
*zh,
const
char
*path,
int
watch,
959
strings_completion_t
completion,
const
void
*data);
960
987
ZOOAPI
int
zoo_awget_children
(
zhandle_t
*zh,
const
char
*path,
988
watcher_fn
watcher,
void
* watcherCtx,
989
strings_completion_t
completion,
const
void
*data);
990
1013
ZOOAPI
int
zoo_aget_children2
(
zhandle_t
*zh,
const
char
*path,
int
watch,
1014
strings_stat_completion_t
completion,
const
void
*data);
1015
1044
ZOOAPI
int
zoo_awget_children2
(
zhandle_t
*zh,
const
char
*path,
1045
watcher_fn
watcher,
void
* watcherCtx,
1046
strings_stat_completion_t
completion,
const
void
*data);
1047
1067
ZOOAPI
int
zoo_async
(
zhandle_t
*zh,
const
char
*path,
1068
string_completion_t
completion,
const
void
*data);
1069
1070
1089
ZOOAPI
int
zoo_aget_acl
(
zhandle_t
*zh,
const
char
*path,
acl_completion_t
completion,
1090
const
void
*data);
1091
1114
ZOOAPI
int
zoo_aset_acl
(
zhandle_t
*zh,
const
char
*path,
int
version,
1115
struct
ACL_vector *acl,
void_completion_t
,
const
void
*data);
1116
1133
ZOOAPI
int
zoo_amulti
(
zhandle_t
*zh,
int
count,
const
zoo_op_t
*ops,
1134
zoo_op_result_t
*results,
void_completion_t
,
const
void
*data);
1135
1142
ZOOAPI
const
char
*
zerror
(
int
c);
1143
1171
ZOOAPI
int
zoo_add_auth
(
zhandle_t
*zh,
const
char
* scheme,
const
char
* cert,
1172
int
certLen,
void_completion_t
completion,
const
void
*data);
1173
1182
ZOOAPI
int
is_unrecoverable
(
zhandle_t
*zh);
1183
1187
ZOOAPI
void
zoo_set_debug_level
(ZooLogLevel logLevel);
1188
1196
ZOOAPI
void
zoo_set_log_stream
(FILE* logStream);
1197
1209
ZOOAPI
void
zoo_deterministic_conn_order
(
int
yesOrNo);
1210
1248
ZOOAPI
int
zoo_create
(
zhandle_t
*zh,
const
char
*path,
const
char
*value,
1249
int
valuelen,
const
struct
ACL_vector *acl,
int
flags,
1250
char
*path_buffer,
int
path_buffer_len);
1251
1271
ZOOAPI
int
zoo_delete
(
zhandle_t
*zh,
const
char
*path,
int
version);
1272
1273
1292
ZOOAPI
int
zoo_exists
(
zhandle_t
*zh,
const
char
*path,
int
watch,
struct
Stat *stat);
1293
1318
ZOOAPI
int
zoo_wexists
(
zhandle_t
*zh,
const
char
*path,
1319
watcher_fn
watcher,
void
* watcherCtx,
struct
Stat *stat);
1320
1341
ZOOAPI
int
zoo_get
(
zhandle_t
*zh,
const
char
*path,
int
watch,
char
*buffer,
1342
int
* buffer_len,
struct
Stat *stat);
1343
1370
ZOOAPI
int
zoo_wget
(
zhandle_t
*zh,
const
char
*path,
1371
watcher_fn
watcher,
void
* watcherCtx,
1372
char
*buffer,
int
* buffer_len,
struct
Stat *stat);
1373
1396
ZOOAPI
int
zoo_set
(
zhandle_t
*zh,
const
char
*path,
const
char
*buffer,
1397
int
buflen,
int
version);
1398
1423
ZOOAPI
int
zoo_set2
(
zhandle_t
*zh,
const
char
*path,
const
char
*buffer,
1424
int
buflen,
int
version,
struct
Stat *stat);
1425
1443
ZOOAPI
int
zoo_get_children
(
zhandle_t
*zh,
const
char
*path,
int
watch,
1444
struct
String_vector *strings);
1445
1469
ZOOAPI
int
zoo_wget_children
(
zhandle_t
*zh,
const
char
*path,
1470
watcher_fn
watcher,
void
* watcherCtx,
1471
struct
String_vector *strings);
1472
1493
ZOOAPI
int
zoo_get_children2
(
zhandle_t
*zh,
const
char
*path,
int
watch,
1494
struct
String_vector *strings,
struct
Stat *stat);
1495
1522
ZOOAPI
int
zoo_wget_children2
(
zhandle_t
*zh,
const
char
*path,
1523
watcher_fn
watcher,
void
* watcherCtx,
1524
struct
String_vector *strings,
struct
Stat *stat);
1525
1542
ZOOAPI
int
zoo_get_acl
(
zhandle_t
*zh,
const
char
*path,
struct
ACL_vector *acl,
1543
struct
Stat *stat);
1544
1563
ZOOAPI
int
zoo_set_acl
(
zhandle_t
*zh,
const
char
*path,
int
version,
1564
const
struct
ACL_vector *acl);
1565
1577
ZOOAPI
int
zoo_multi
(
zhandle_t
*zh,
int
count,
const
zoo_op_t
*ops,
zoo_op_result_t
*results);
1578
1579
#ifdef __cplusplus
1580
}
1581
#endif
1582
1583
#endif
/*ZOOKEEPER_H_*/
Generated on Fri Jan 11 2013 10:46:04 for zookeeper-3.4.3 by
1.8.3