1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 //#ifndef ZOOKEEPER_H_
20 //enum 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 
37 module deimos.zookeeper.zookeeper;
38 
39 public import deimos.zookeeper.zookeeper_version;
40 public import deimos.zookeeper.proto;
41 public import deimos.zookeeper.recordio;
42 public import deimos.zookeeper.zookeeper_jute;
43 
44 import core.stdc.stdlib;
45 import core.stdc.stdio;
46 import core.stdc.ctype;
47 import std.string;
48 
49 version(Windows){}
50 else {
51 	import core.sys.posix.sys.socket;
52 	import core.sys.posix.sys.time;
53 }
54 extern(C):
55 
56 /**
57  * \file zookeeper.h 
58  * \brief ZooKeeper functions and definitions.
59  * 
60  * ZooKeeper is a network service that may be backed by a cluster of
61  * synchronized servers. The data in the service is represented as a tree
62  * of data nodes. Each node has data, children, an ACL, and status information.
63  * The data for a node is read and write in its entirety.
64  * 
65  * ZooKeeper clients can leave watches when they queries the data or children
66  * of a node. If a watch is left, that client will be notified of the change.
67  * The notification is a one time trigger. Subsequent chances to the node will
68  * not trigger a notification unless the client issues a query with the watch
69  * flag set. If the client is ever disconnected from the service, the watches do 
70  * not need to be reset. The client automatically resets the watches.
71  * 
72  * When a node is created, it may be flagged as an ephemeral node. Ephemeral
73  * nodes are automatically removed when a client session is closed or when
74  * a session times out due to inactivity (the ZooKeeper runtime fills in
75  * periods of inactivity with pings). Ephemeral nodes cannot have children.
76  * 
77  * ZooKeeper clients are identified by a server assigned session id. For
78  * security reasons The server
79  * also generates a corresponding password for a session. A client may save its
80  * id and corresponding password to persistent storage in order to use the
81  * session across program invocation boundaries.
82  */
83 
84 /* Support for building on various platforms */
85 
86 // on cygwin we should take care of exporting/importing symbols properly 
87 //#ifdef DLL_EXPORT
88 //#    define  __declspec(dllexport)
89 //#else
90 //#  if (defined(__CYGWIN__) || defined(WIN32)) && !defined(USE_STATIC_LIB)
91 //#    define  __declspec(dllimport)
92 //#  else
93 //#    define ZOOAPI
94 //#  endif
95 //#endif
96 
97 /** zookeeper return constants **/
98 
99 enum ZOO_ERRORS {
100   ZOK = 0, /*!< Everything is OK */
101 
102   /** System and server-side errors.
103    * This is never thrown by the server, it shouldn't be used other than
104    * to indicate a range. Specifically error codes greater than this
105    * value, but lesser than {@link #ZAPIERROR}, are system errors. */
106   ZSYSTEMERROR = -1,
107   ZRUNTIMEINCONSISTENCY = -2, /*!< A runtime inconsistency was found */
108   ZDATAINCONSISTENCY = -3, /*!< A data inconsistency was found */
109   ZCONNECTIONLOSS = -4, /*!< Connection to the server has been lost */
110   ZMARSHALLINGERROR = -5, /*!< Error while marshalling or unmarshalling data */
111   ZUNIMPLEMENTED = -6, /*!< Operation is unimplemented */
112   ZOPERATIONTIMEOUT = -7, /*!< Operation timeout */
113   ZBADARGUMENTS = -8, /*!< Invalid arguments */
114   ZINVALIDSTATE = -9, /*!< Invliad zhandle state */
115 
116   /** API errors.
117    * This is never thrown by the server, it shouldn't be used other than
118    * to indicate a range. Specifically error codes greater than this
119    * value are API errors (while values less than this indicate a 
120    * {@link #ZSYSTEMERROR}).
121    */
122   ZAPIERROR = -100,
123   ZNONODE = -101, /*!< Node does not exist */
124   ZNOAUTH = -102, /*!< Not authenticated */
125   ZBADVERSION = -103, /*!< Version conflict */
126   ZNOCHILDRENFOREPHEMERALS = -108, /*!< Ephemeral nodes may not have children */
127   ZNODEEXISTS = -110, /*!< The node already exists */
128   ZNOTEMPTY = -111, /*!< The node has children */
129   ZSESSIONEXPIRED = -112, /*!< The session has been expired by the server */
130   ZINVALIDCALLBACK = -113, /*!< Invalid callback specified */
131   ZINVALIDACL = -114, /*!< Invalid ACL specified */
132   ZAUTHFAILED = -115, /*!< Client authentication failed */
133   ZCLOSING = -116, /*!< ZooKeeper is closing */
134   ZNOTHING = -117, /*!< (not error) no server responses to process */
135   ZSESSIONMOVED = -118 /*!<session moved to another server, so operation is ignored */ 
136 };
137 
138 //#ifdef __cplusplus
139 //extern "C" {
140 //#endif
141 
142 /**
143 *  @name Debug levels
144 */
145 enum ZooLogLevel {ZOO_LOG_LEVEL_ERROR=1,ZOO_LOG_LEVEL_WARN=2,ZOO_LOG_LEVEL_INFO=3,ZOO_LOG_LEVEL_DEBUG=4};
146 
147 
148 enum WATCHER_EVENT_XID  = -1;
149 enum PING_XID = -2;
150 enum AUTH_XID = -4;
151 enum SET_WATCHES_XID = -8;
152 
153 /* zookeeper state constants */
154 enum EXPIRED_SESSION_STATE_DEF = -112;
155 enum AUTH_FAILED_STATE_DEF =  -113;
156 enum CONNECTING_STATE_DEF = 1;
157 enum ASSOCIATING_STATE_DEF = 2;
158 enum CONNECTED_STATE_DEF = 3;
159 enum READONLY_STATE_DEF = 5;
160 enum NOTCONNECTED_STATE_DEF = 999;
161 
162 /* zookeeper event type constants */
163 enum CREATED_EVENT_DEF = 1;
164 enum DELETED_EVENT_DEF = 2;
165 enum CHANGED_EVENT_DEF = 3;
166 enum CHILD_EVENT_DEF =  4;
167 enum SESSION_EVENT_DEF = -1;
168 enum NOTWATCHING_EVENT_DEF = -2;
169 
170 /**
171  * @name ACL Consts
172  */
173 const int ZOO_PERM_READ = 1 << 0;
174 const int ZOO_PERM_WRITE = 1 << 1;
175 const int ZOO_PERM_CREATE = 1 << 2;
176 const int ZOO_PERM_DELETE = 1 << 3;
177 const int ZOO_PERM_ADMIN = 1 << 4;
178 const int ZOO_PERM_ALL = 0x1f;
179 
180 /** This Id represents anyone. */
181 //__gshared Id ZOO_ANYONE_ID_UNSAFE = {"world\0".ptr, "anyone\0".ptr};
182 /** This Id is only usable to set ACLs. It will get substituted with the
183  * Id's the client authenticated with.
184  */
185 //__gshared Id ZOO_AUTH_IDS = {"auth\0".ptr, "\0".ptr};
186 
187 //static __gshared ACL[] _OPEN_ACL_UNSAFE_ACL = {{0x1f, {"world", "anyone"}}};
188 //static __gshared ACL[] _READ_ACL_UNSAFE_ACL = {{0x01, {"world", "anyone"}}};
189 //static __gshared ACL[] _CREATOR_ALL_ACL_ACL = {{0x1f, {"auth", ""}}};
190 
191 /** This is a completely open ACL*/
192 //__gshared ACL_vector ZOO_OPEN_ACL_UNSAFE = { 1, _OPEN_ACL_UNSAFE_ACL};
193 /** This ACL gives the world the ability to read. */
194 //__gshared ACL_vector ZOO_READ_ACL_UNSAFE = { 1, _READ_ACL_UNSAFE_ACL};
195 /** This ACL gives the creators authentication id's all permissions. */
196 //__gshared ACL_vector ZOO_CREATOR_ALL_ACL = { 1, _CREATOR_ALL_ACL_ACL};
197 
198 /**
199  * @name Interest Consts
200  * These constants are used to express interest in an event and to
201  * indicate to zookeeper which events have occurred. They can
202  * be ORed together to express multiple interests. These flags are
203  * used in the interest and event parameters of 
204  * \ref zookeeper_interest and \ref zookeeper_process.
205  */
206 // @{
207 const int ZOOKEEPER_WRITE = 1 << 0;
208 const int ZOOKEEPER_READ = 1 << 1;
209 // @}
210 
211 /**
212  * @name Create Flags
213  * 
214  * These flags are used by zoo_create to affect node create. They may
215  * be ORed together to combine effects.
216  */
217 // @{
218 const int ZOO_EPHEMERAL = 1 << 0;
219 const int ZOO_SEQUENCE = 1 << 1;
220 // @}
221 
222 /**
223  * @name State Consts
224  * These constants represent the states of a zookeeper connection. They are
225  * possible parameters of the watcher callback.
226  */
227 // @{
228 const int ZOO_EXPIRED_SESSION_STATE = EXPIRED_SESSION_STATE_DEF;
229 const int ZOO_AUTH_FAILED_STATE = AUTH_FAILED_STATE_DEF;
230 const int ZOO_CONNECTING_STATE = CONNECTING_STATE_DEF;
231 const int ZOO_ASSOCIATING_STATE = ASSOCIATING_STATE_DEF;
232 const int ZOO_CONNECTED_STATE = CONNECTED_STATE_DEF;
233 const int ZOO_READONLY_STATE = READONLY_STATE_DEF;
234 const int ZOO_NOTCONNECTED_STATE = NOTCONNECTED_STATE_DEF;
235 // @}
236 
237 /**
238  * @name Watch Types
239  * These constants indicate the event that caused the watch event. They are
240  * possible values of the first parameter of the watcher callback.
241  */
242 // @{
243 /**
244  * \brief a node has been created.
245  * 
246  * This is only generated by watches on non-existent nodes. These watches
247  * are set using \ref zoo_exists.
248  */
249 
250 const int ZOO_CREATED_EVENT = CREATED_EVENT_DEF;
251 /**
252  * \brief a node has been deleted.
253  * 
254  * This is only generated by watches on nodes. These watches
255  * are set using \ref zoo_exists and \ref zoo_get.
256  */
257 const int ZOO_DELETED_EVENT = DELETED_EVENT_DEF;
258 /**
259  * \brief a node has changed.
260  * 
261  * This is only generated by watches on nodes. These watches
262  * are set using \ref zoo_exists and \ref zoo_get.
263  */
264 const int ZOO_CHANGED_EVENT = CHANGED_EVENT_DEF;
265 /**
266  * \brief a change as occurred in the list of children.
267  * 
268  * This is only generated by watches on the child list of a node. These watches
269  * are set using \ref zoo_get_children or \ref zoo_get_children2.
270  */
271 const int ZOO_CHILD_EVENT = CHILD_EVENT_DEF;
272 /**
273  * \brief a session has been lost.
274  * 
275  * This is generated when a client loses contact or reconnects with a server.
276  */
277 const int ZOO_SESSION_EVENT = SESSION_EVENT_DEF;
278 
279 /**
280  * \brief a watch has been removed.
281  * 
282  * This is generated when the server for some reason, probably a resource
283  * constraint, will no longer watch a node for a client.
284  */
285 const int ZOO_NOTWATCHING_EVENT = NOTWATCHING_EVENT_DEF;
286 // @}
287 
288 /**
289  * \brief ZooKeeper handle.
290  * 
291  * This is the handle that represents a connection to the ZooKeeper service.
292  * It is needed to invoke any ZooKeeper function. A handle is obtained using
293  * \ref zookeeper_init.
294  */
295 struct _zhandle{};
296 alias  zhandle_t = _zhandle;
297 
298 /**
299  * \brief client id structure.
300  * 
301  * This structure holds the id and password for the session. This structure
302  * should be treated as opaque. It is received from the server when a session
303  * is established and needs to be sent back as-is when reconnecting a session.
304  */
305 struct clientid_t {
306     int64_t client_id;
307     char[16] passwd;
308 } ;
309 
310 /**
311  * \brief zoo_op structure.
312  *
313  * This structure holds all the arguments necessary for one op as part
314  * of a containing multi_op via \ref zoo_multi or \ref zoo_amulti.
315  * This structure should be treated as opaque and initialized via 
316  * \ref zoo_create_op_init, \ref zoo_delete_op_init, \ref zoo_set_op_init
317  * and \ref zoo_check_op_init.
318  */
319 struct zoo_op {
320     int type;
321     union {
322         // CREATE
323 		struct CREATE{
324             const char *path;
325             const char *data;
326             int datalen;
327 	        char *buf;
328             int buflen;
329             const ACL_vector *acl;
330             int flags;
331         } ;
332 		CREATE create_op;
333 
334         // DELETE 
335 		struct DELETE {
336             const char *path;
337             int version_;
338         } ;
339 		DELETE delete_op;
340         
341         // SET
342 		struct SET{
343             const char *path;
344             const char *data;
345             int datalen;
346             int version_;
347             Stat *stat;
348         } ;
349 		SET set_op;
350         
351         // CHECK
352 		struct CHECK {
353             const char *path;
354             int version_;
355         } ;
356 		CHECK check_op;
357     };
358 } ;
359 alias zoo_op_t = zoo_op;
360 
361 /**
362  * \brief zoo_create_op_init.
363  *
364  * This function initializes a zoo_op_t with the arguments for a ZOO_CREATE_OP.
365  *
366  * \param op A pointer to the zoo_op_t to be initialized.
367  * \param path The name of the node. Expressed as a file name with slashes 
368  * separating ancestors of the node.
369  * \param value The data to be stored in the node.
370  * \param valuelen The number of bytes in data. To set the data to be NULL use
371  * value as NULL and valuelen as -1.
372  * \param acl The initial ACL of the node. The ACL must not be null or empty.
373  * \param flags this parameter can be set to 0 for normal create or an OR
374  *    of the Create Flags
375  * \param path_buffer Buffer which will be filled with the path of the
376  *    new node (this might be different than the supplied path
377  *    because of the ZOO_SEQUENCE flag).  The path string will always be
378  *    null-terminated. This parameter may be NULL if path_buffer_len = 0.
379  * \param path_buffer_len Size of path buffer; if the path of the new
380  *    node (including space for the null terminator) exceeds the buffer size,
381  *    the path string will be truncated to fit.  The actual path of the
382  *    new node in the server will not be affected by the truncation.
383  *    The path string will always be null-terminated.
384  */
385 void zoo_create_op_init(zoo_op_t *op, const char *path, const char *value,
386         int valuelen,  const ACL_vector *acl, int flags, 
387         char *path_buffer, int path_buffer_len);
388 
389 /**
390  * \brief zoo_delete_op_init.
391  *
392  * This function initializes a zoo_op_t with the arguments for a ZOO_DELETE_OP.
393  *
394  * \param op A pointer to the zoo_op_t to be initialized.
395  * \param path the name of the node. Expressed as a file name with slashes 
396  * separating ancestors of the node.
397  * \param version the expected version of the node. The function will fail if the
398  *    actual version of the node does not match the expected version.
399  *  If -1 is used the version check will not take place. 
400  */
401 void zoo_delete_op_init(zoo_op_t *op, const char *path, int version_);
402 
403 /**
404  * \brief zoo_set_op_init.
405  *
406  * This function initializes an zoo_op_t with the arguments for a ZOO_SETDATA_OP.
407  *
408  * \param op A pointer to the zoo_op_t to be initialized.
409  * \param path the name of the node. Expressed as a file name with slashes 
410  * separating ancestors of the node.
411  * \param buffer the buffer holding data to be written to the node.
412  * \param buflen the number of bytes from buffer to write. To set NULL as data 
413  * use buffer as NULL and buflen as -1.
414  * \param version the expected version of the node. The function will fail if 
415  * the actual version of the node does not match the expected version. If -1 is 
416  * used the version check will not take place. 
417  */
418 void zoo_set_op_init(zoo_op_t *op, const char *path, const char *buffer, 
419         int buflen, int version_, Stat *stat);
420 
421 /**
422  * \brief zoo_check_op_init.
423  *
424  * This function initializes an zoo_op_t with the arguments for a ZOO_CHECK_OP.
425  *
426  * \param op A pointer to the zoo_op_t to be initialized.
427  * \param path The name of the node. Expressed as a file name with slashes 
428  * separating ancestors of the node.
429  * \param version the expected version of the node. The function will fail if the
430  *    actual version of the node does not match the expected version.
431  */
432 void zoo_check_op_init(zoo_op_t *op, const char *path, int version_);
433 
434 /**
435  * \brief zoo_op_result structure.
436  *
437  * This structure holds the result for an op submitted as part of a multi_op
438  * via \ref zoo_multi or \ref zoo_amulti.
439  */
440 struct zoo_op_result {
441     int err;
442     char *value;
443 	int valuelen;
444      Stat *stat;
445 } ; 
446 alias  zoo_op_result_t = zoo_op_result;
447 /**
448  * \brief signature of a watch function.
449  * 
450  * There are two ways to receive watch notifications: legacy and watcher object.
451  * <p>
452  * The legacy style, an application wishing to receive events from ZooKeeper must 
453  * first implement a function with this signature and pass a pointer to the function 
454  * to \ref zookeeper_init. Next, the application sets a watch by calling one of 
455  * the getter API that accept the watch integer flag (for example, \ref zoo_aexists, 
456  * \ref zoo_get, etc).
457  * <p>
458  * The watcher object style uses an instance of a "watcher object" which in 
459  * the C world is represented by a pair: a pointer to a function implementing this
460  * signature and a pointer to watcher context -- handback user-specific data. 
461  * When a watch is triggered this function will be called along with 
462  * the watcher context. An application wishing to use this style must use
463  * the getter API functions with the "w" prefix in their names (for example, \ref
464  * zoo_awexists, \ref zoo_wget, etc).
465  * 
466  * \param zh zookeeper handle
467  * \param type event type. This is one of the *_EVENT constants. 
468  * \param state connection state. The state value will be one of the *_STATE constants.
469  * \param path znode path for which the watcher is triggered. NULL if the event 
470  * type is ZOO_SESSION_EVENT
471  * \param watcherCtx watcher context.
472  */
473 //typedef void (*watcher_fn)(zhandle_t *zh, int type, 
474 //        int state, const char *path,void *watcherCtx);
475 alias watcher_fn = void function (zhandle_t *zh, int type,  int state, const char *path,void *watcherCtx);
476 /**
477  * \brief create a handle to used communicate with zookeeper.
478  * 
479  * This method creates a new handle and a zookeeper session that corresponds
480  * to that handle. Session establishment is asynchronous, meaning that the
481  * session should not be considered established until (and unless) an
482  * event of state ZOO_CONNECTED_STATE is received.
483  * \param host comma separated host:port pairs, each corresponding to a zk
484  *   server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002"
485  * \param fn the global watcher callback function. When notifications are
486  *   triggered this function will be invoked.
487  * \param clientid the id of a previously established session that this
488  *   client will be reconnecting to. Pass 0 if not reconnecting to a previous
489  *   session. Clients can access the session id of an established, valid,
490  *   connection by calling \ref zoo_client_id. If the session corresponding to
491  *   the specified clientid has expired, or if the clientid is invalid for 
492  *   any reason, the returned zhandle_t will be invalid -- the zhandle_t 
493  *   state will indicate the reason for failure (typically
494  *   ZOO_EXPIRED_SESSION_STATE).
495  * \param context the handback object that will be associated with this instance 
496  *   of zhandle_t. Application can access it (for example, in the watcher 
497  *   callback) using \ref zoo_get_context. The object is not used by zookeeper 
498  *   internally and can be null.
499  * \param flags reserved for future use. Should be set to zero.
500  * \return a pointer to the opaque zhandle structure. If it fails to create 
501  * a new zhandle the function returns NULL and the errno variable 
502  * indicates the reason.
503  */
504  zhandle_t *zookeeper_init(const char *host, watcher_fn fn,
505   int recv_timeout, const clientid_t *clientid, void *context, int flags);
506 
507 /**
508  * \brief close the zookeeper handle and free up any resources.
509  * 
510  * After this call, the client session will no longer be valid. The function
511  * will flush any outstanding send requests before return. As a result it may 
512  * block.
513  *
514  * This method should only be called only once on a zookeeper handle. Calling
515  * twice will cause undefined (and probably undesirable behavior). Calling any other
516  * zookeeper method after calling close is undefined behaviour and should be avoided.
517  *
518  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
519  * \return a result code. Regardless of the error code returned, the zhandle 
520  * will be destroyed and all resources freed. 
521  *
522  * ZOK - success
523  * ZBADARGUMENTS - invalid input parameters
524  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
525  * ZOPERATIONTIMEOUT - failed to flush the buffers within the specified timeout.
526  * ZCONNECTIONLOSS - a network error occured while attempting to send request to server
527  * ZSYSTEMERROR -- a system (OS) error occured; it's worth checking errno to get details
528  */
529  int zookeeper_close(zhandle_t *zh);
530 
531 /**
532  * \brief return the client session id, only valid if the connections
533  * is currently connected (ie. last watcher state is ZOO_CONNECTED_STATE)
534  */
535  const(clientid_t) *zoo_client_id(zhandle_t *zh);
536 
537 /**
538  * \brief return the timeout for this session, only valid if the connections
539  * is currently connected (ie. last watcher state is ZOO_CONNECTED_STATE). This
540  * value may change after a server re-connect.
541  */
542  int zoo_recv_timeout(zhandle_t *zh);
543 
544 /**
545  * \brief return the context for this handle.
546  */
547  const(void) * zoo_get_context(zhandle_t *zh);
548 
549 /**
550  * \brief set the context for this handle.
551  */
552  void zoo_set_context(zhandle_t *zh, void *context);
553 
554 /**
555  * \brief set a watcher function
556  * \return previous watcher function
557  */
558  watcher_fn zoo_set_watcher(zhandle_t *zh,watcher_fn newFn);
559 
560 /**
561  * \brief returns the socket address for the current connection
562  * \return socket address of the connected host or NULL on failure, only valid if the
563  * connection is current connected
564  */
565 sockaddr* zookeeper_get_connected_host(zhandle_t *zh,sockaddr *addr, socklen_t *addr_len);
566 
567 //#ifndef THREADED
568 /**
569  * \brief Returns the events that zookeeper is interested in.
570  * 
571  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
572  * \param fd is the file descriptor of interest
573  * \param interest is an or of the ZOOKEEPER_WRITE and ZOOKEEPER_READ flags to
574  *    indicate the I/O of interest on fd.
575  * \param tv a timeout value to be used with select/poll system call
576  * \return a result code.
577  * ZOK - success
578  * ZBADARGUMENTS - invalid input parameters
579  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
580  * ZCONNECTIONLOSS - a network error occured while attempting to establish 
581  * a connection to the server
582  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
583  * ZOPERATIONTIMEOUT - hasn't received anything from the server for 2/3 of the
584  * timeout value specified in zookeeper_init()
585  * ZSYSTEMERROR -- a system (OS) error occured; it's worth checking errno to get details
586  */
587 //#ifdef WIN32
588 // int zookeeper_interest(zhandle_t *zh, SOCKET *fd, int *interest, 
589 //	struct timeval *tv);
590 //#else
591 // int zookeeper_interest(zhandle_t *zh, int *fd, int *interest, 
592 //	struct timeval *tv);
593 //#endif
594 
595 version(Windows){
596 	int zookeeper_interest(zhandle_t *zh, SOCKET *fd, int *interest, timeval *tv);
597 } else {
598 	int zookeeper_interest(zhandle_t *zh, int *fd, int *interest,  timeval *tv);
599 }
600 
601 /**
602  * \brief Notifies zookeeper that an event of interest has happened.
603  * 
604  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
605  * \param events will be an OR of the ZOOKEEPER_WRITE and ZOOKEEPER_READ flags.
606  * \return a result code. 
607  * ZOK - success
608  * ZBADARGUMENTS - invalid input parameters
609  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
610  * ZCONNECTIONLOSS - a network error occured while attempting to send request to server
611  * ZSESSIONEXPIRED - connection attempt failed -- the session's expired
612  * ZAUTHFAILED - authentication request failed, e.i. invalid credentials
613  * ZRUNTIMEINCONSISTENCY - a server response came out of order
614  * ZSYSTEMERROR -- a system (OS) error occured; it's worth checking errno to get details
615  * ZNOTHING -- not an error; simply indicates that there no more data from the server 
616  *              to be processed (when called with ZOOKEEPER_READ flag).
617  */
618  int zookeeper_process(zhandle_t *zh, int events);
619 //#endif
620 
621 /**
622  * \brief signature of a completion function for a call that returns void.
623  * 
624  * This method will be invoked at the end of a asynchronous call and also as 
625  * a result of connection loss or timeout.
626  * \param rc the error code of the call. Connection loss/timeout triggers 
627  * the completion with one of the following error codes:
628  * ZCONNECTIONLOSS -- lost connection to the server
629  * ZOPERATIONTIMEOUT -- connection timed out
630  * Data related events trigger the completion with error codes listed the 
631  * Exceptions section of the documentation of the function that initiated the
632  * call. (Zero indicates call was successful.)
633  * \param data the pointer that was passed by the caller when the function
634  *   that this completion corresponds to was invoked. The programmer
635  *   is responsible for any memory freeing associated with the data
636  *   pointer.
637  */
638 //typedef void (*void_completion_t)(int rc, const void *data);
639 alias void_completion_t = void function(int rc, const void *data);
640 /**
641  * \brief signature of a completion function that returns a Stat structure.
642  * 
643  * This method will be invoked at the end of a asynchronous call and also as 
644  * a result of connection loss or timeout.
645  * \param rc the error code of the call. Connection loss/timeout triggers 
646  * the completion with one of the following error codes:
647  * ZCONNECTIONLOSS -- lost connection to the server
648  * ZOPERATIONTIMEOUT -- connection timed out
649  * Data related events trigger the completion with error codes listed the 
650  * Exceptions section of the documentation of the function that initiated the
651  * call. (Zero indicates call was successful.)
652  * \param stat a pointer to the stat information for the node involved in
653  *   this function. If a non zero error code is returned, the content of
654  *   stat is undefined. The programmer is NOT responsible for freeing stat.
655  * \param data the pointer that was passed by the caller when the function
656  *   that this completion corresponds to was invoked. The programmer
657  *   is responsible for any memory freeing associated with the data
658  *   pointer.
659  */
660 	alias stat_completion_t= void function(int rc, const Stat *stat,const void *data);
661 /**
662  * \brief signature of a completion function that returns data.
663  * 
664  * This method will be invoked at the end of a asynchronous call and also as 
665  * a result of connection loss or timeout.
666  * \param rc the error code of the call. Connection loss/timeout triggers 
667  * the completion with one of the following error codes:
668  * ZCONNECTIONLOSS -- lost connection to the server
669  * ZOPERATIONTIMEOUT -- connection timed out
670  * Data related events trigger the completion with error codes listed the 
671  * Exceptions section of the documentation of the function that initiated the
672  * call. (Zero indicates call was successful.)
673  * \param value the value of the information returned by the asynchronous call.
674  *   If a non zero error code is returned, the content of value is undefined.
675  *   The programmer is NOT responsible for freeing value.
676  * \param value_len the number of bytes in value.
677  * \param stat a pointer to the stat information for the node involved in
678  *   this function. If a non zero error code is returned, the content of
679  *   stat is undefined. The programmer is NOT responsible for freeing stat.
680  * \param data the pointer that was passed by the caller when the function
681  *   that this completion corresponds to was invoked. The programmer
682  *   is responsible for any memory freeing associated with the data
683  *   pointer.
684  */
685 alias data_completion_t = void function(int rc, const char *value, int value_len,const Stat *stat, const void *data);
686 /**
687  * \brief signature of a completion function that returns a list of strings.
688  * 
689  * This method will be invoked at the end of a asynchronous call and also as 
690  * a result of connection loss or timeout.
691  * \param rc the error code of the call. Connection loss/timeout triggers 
692  * the completion with one of the following error codes:
693  * ZCONNECTIONLOSS -- lost connection to the server
694  * ZOPERATIONTIMEOUT -- connection timed out
695  * Data related events trigger the completion with error codes listed the 
696  * Exceptions section of the documentation of the function that initiated the
697  * call. (Zero indicates call was successful.)
698  * \param strings a pointer to the structure containng the list of strings of the
699  *   names of the children of a node. If a non zero error code is returned,
700  *   the content of strings is undefined. The programmer is NOT responsible
701  *   for freeing strings.
702  * \param data the pointer that was passed by the caller when the function
703  *   that this completion corresponds to was invoked. The programmer
704  *   is responsible for any memory freeing associated with the data
705  *   pointer.
706  */
707 	alias strings_completion_t = void function(int rc,const String_vector *strings, const void *data);
708 /**
709  * \brief signature of a completion function that returns a list of strings and stat.
710  * .
711  * 
712  * This method will be invoked at the end of a asynchronous call and also as 
713  * a result of connection loss or timeout.
714  * \param rc the error code of the call. Connection loss/timeout triggers 
715  * the completion with one of the following error codes:
716  * ZCONNECTIONLOSS -- lost connection to the server
717  * ZOPERATIONTIMEOUT -- connection timed out
718  * Data related events trigger the completion with error codes listed the 
719  * Exceptions section of the documentation of the function that initiated the
720  * call. (Zero indicates call was successful.)
721  * \param strings a pointer to the structure containng the list of strings of the
722  *   names of the children of a node. If a non zero error code is returned,
723  *   the content of strings is undefined. The programmer is NOT responsible
724  *   for freeing strings.
725  * \param stat a pointer to the stat information for the node involved in
726  *   this function. If a non zero error code is returned, the content of
727  *   stat is undefined. The programmer is NOT responsible for freeing stat.
728  * \param data the pointer that was passed by the caller when the function
729  *   that this completion corresponds to was invoked. The programmer
730  *   is responsible for any memory freeing associated with the data
731  *   pointer.
732  */
733 	alias strings_stat_completion_t = void function(int rc,const String_vector *strings,  const Stat *stat,const void *data);
734 /**
735  * \brief signature of a completion function that returns a list of strings.
736  * 
737  * This method will be invoked at the end of a asynchronous call and also as 
738  * a result of connection loss or timeout.
739  * \param rc the error code of the call. Connection loss/timeout triggers 
740  * the completion with one of the following error codes:
741  * ZCONNECTIONLOSS -- lost connection to the server
742  * ZOPERATIONTIMEOUT -- connection timed out
743  * Data related events trigger the completion with error codes listed the 
744  * Exceptions section of the documentation of the function that initiated the
745  * call. (Zero indicates call was successful.)
746  * \param value the value of the string returned.
747  * \param data the pointer that was passed by the caller when the function
748  *   that this completion corresponds to was invoked. The programmer
749  *   is responsible for any memory freeing associated with the data
750  *   pointer.
751  */
752 
753 		alias string_completion_t = void function(int rc, const char *value, const void *data);
754 
755 /**
756  * \brief signature of a completion function that returns an ACL.
757  * 
758  * This method will be invoked at the end of a asynchronous call and also as 
759  * a result of connection loss or timeout.
760  * \param rc the error code of the call. Connection loss/timeout triggers 
761  * the completion with one of the following error codes:
762  * ZCONNECTIONLOSS -- lost connection to the server
763  * ZOPERATIONTIMEOUT -- connection timed out
764  * Data related events trigger the completion with error codes listed the 
765  * Exceptions section of the documentation of the function that initiated the
766  * call. (Zero indicates call was successful.)
767  * \param acl a pointer to the structure containng the ACL of a node. If a non 
768  *   zero error code is returned, the content of strings is undefined. The
769  *   programmer is NOT responsible for freeing acl.
770  * \param stat a pointer to the stat information for the node involved in
771  *   this function. If a non zero error code is returned, the content of
772  *   stat is undefined. The programmer is NOT responsible for freeing stat.
773  * \param data the pointer that was passed by the caller when the function
774  *   that this completion corresponds to was invoked. The programmer
775  *   is responsible for any memory freeing associated with the data
776  *   pointer.
777  */
778 	alias acl_completion_t = void function(int rc,  ACL_vector *acl, Stat *stat, const void *data);
779 /**
780  * \brief get the state of the zookeeper connection.
781  * 
782  * The return value will be one of the \ref State Consts.
783  */
784  int zoo_state(zhandle_t *zh);
785 
786 /**
787  * \brief create a node.
788  * 
789  * This method will create a node in ZooKeeper. A node can only be created if
790  * it does not already exists. The Create Flags affect the creation of nodes.
791  * If ZOO_EPHEMERAL flag is set, the node will automatically get removed if the
792  * client session goes away. If the ZOO_SEQUENCE flag is set, a unique
793  * monotonically increasing sequence number is appended to the path name. The
794  * sequence number is always fixed length of 10 digits, 0 padded.
795  * 
796  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
797  * \param path The name of the node. Expressed as a file name with slashes 
798  * separating ancestors of the node.
799  * \param value The data to be stored in the node.
800  * \param valuelen The number of bytes in data.
801  * \param acl The initial ACL of the node. The ACL must not be null or empty.
802  * \param flags this parameter can be set to 0 for normal create or an OR
803  *    of the Create Flags
804  * \param completion the routine to invoke when the request completes. The completion
805  * will be triggered with one of the following codes passed in as the rc argument:
806  * ZOK operation completed successfully
807  * ZNONODE the parent node does not exist.
808  * ZNODEEXISTS the node already exists
809  * ZNOAUTH the client does not have permission.
810  * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
811  * \param data The data that will be passed to the completion routine when the 
812  * function completes.
813  * \return ZOK on success or one of the following errcodes on failure:
814  * ZBADARGUMENTS - invalid input parameters
815  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
816  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
817  */
818  int zoo_acreate(zhandle_t *zh, const char *path, const char *value, int valuelen, const  ACL_vector *acl, int flags,string_completion_t completion, const void *data);
819 
820 /**
821  * \brief delete a node in zookeeper.
822  * 
823  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
824  * \param path the name of the node. Expressed as a file name with slashes 
825  * separating ancestors of the node.
826  * \param version the expected version of the node. The function will fail if the
827  *    actual version of the node does not match the expected version.
828  *  If -1 is used the version check will not take place. 
829  * \param completion the routine to invoke when the request completes. The completion
830  * will be triggered with one of the following codes passed in as the rc argument:
831  * ZOK operation completed successfully
832  * ZNONODE the node does not exist.
833  * ZNOAUTH the client does not have permission.
834  * ZBADVERSION expected version does not match actual version.
835  * ZNOTEMPTY children are present; node cannot be deleted.
836  * \param data the data that will be passed to the completion routine when 
837  * the function completes.
838  * \return ZOK on success or one of the following errcodes on failure:
839  * ZBADARGUMENTS - invalid input parameters
840  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
841  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
842  */
843  int zoo_adelete(zhandle_t *zh, const char *path, int version_,  void_completion_t completion, const void *data);
844 
845 /**
846  * \brief checks the existence of a node in zookeeper.
847  * 
848  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
849  * \param path the name of the node. Expressed as a file name with slashes 
850  * separating ancestors of the node.
851  * \param watch if nonzero, a watch will be set at the server to notify the 
852  * client if the node changes. The watch will be set even if the node does not 
853  * exist. This allows clients to watch for nodes to appear.
854  * \param completion the routine to invoke when the request completes. The completion
855  * will be triggered with one of the following codes passed in as the rc argument:
856  * ZOK operation completed successfully
857  * ZNONODE the node does not exist.
858  * ZNOAUTH the client does not have permission.
859  * \param data the data that will be passed to the completion routine when the 
860  * function completes.
861  * \return ZOK on success or one of the following errcodes on failure:
862  * ZBADARGUMENTS - invalid input parameters
863  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
864  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
865  */
866  int zoo_aexists(zhandle_t *zh, const char *path, int watch, stat_completion_t completion, const void *data);
867 
868 /**
869  * \brief checks the existence of a node in zookeeper.
870  * 
871  * This function is similar to \ref zoo_axists except it allows one specify 
872  * a watcher object - a function pointer and associated context. The function
873  * will be called once the watch has fired. The associated context data will be 
874  * passed to the function as the watcher context parameter. 
875  * 
876  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
877  * \param path the name of the node. Expressed as a file name with slashes 
878  * separating ancestors of the node.
879  * \param watcher if non-null a watch will set on the specified znode on the server.
880  * The watch will be set even if the node does not exist. This allows clients 
881  * to watch for nodes to appear.
882  * \param watcherCtx user specific data, will be passed to the watcher callback.
883  * Unlike the global context set by \ref zookeeper_init, this watcher context
884  * is associated with the given instance of the watcher only.
885  * \param completion the routine to invoke when the request completes. The completion
886  * will be triggered with one of the following codes passed in as the rc argument:
887  * ZOK operation completed successfully
888  * ZNONODE the node does not exist.
889  * ZNOAUTH the client does not have permission.
890  * \param data the data that will be passed to the completion routine when the 
891  * function completes.
892  * \return ZOK on success or one of the following errcodes on failure:
893  * ZBADARGUMENTS - invalid input parameters
894  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
895  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
896  */
897  int zoo_awexists(zhandle_t *zh, const char *path,  watcher_fn watcher, void* watcherCtx,  stat_completion_t completion, const void *data);
898 
899 /**
900  * \brief gets the data associated with a node.
901  * 
902  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
903  * \param path the name of the node. Expressed as a file name with slashes 
904  * separating ancestors of the node.
905  * \param watch if nonzero, a watch will be set at the server to notify 
906  * the client if the node changes.
907  * \param completion the routine to invoke when the request completes. The completion
908  * will be triggered with one of the following codes passed in as the rc argument:
909  * ZOK operation completed successfully
910  * ZNONODE the node does not exist.
911  * ZNOAUTH the client does not have permission.
912  * \param data the data that will be passed to the completion routine when 
913  * the function completes.
914  * \return ZOK on success or one of the following errcodes on failure:
915  * ZBADARGUMENTS - invalid input parameters
916  * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
917  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
918  */
919  int zoo_aget(zhandle_t *zh, const char *path, int watch,  data_completion_t completion, const void *data);
920 
921 /**
922  * \brief gets the data associated with a node.
923  * 
924  * This function is similar to \ref zoo_aget except it allows one specify 
925  * a watcher object rather than a boolean watch flag. 
926  *
927  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
928  * \param path the name of the node. Expressed as a file name with slashes 
929  * separating ancestors of the node.
930  * \param watcher if non-null, a watch will be set at the server to notify 
931  * the client if the node changes.
932  * \param watcherCtx user specific data, will be passed to the watcher callback.
933  * Unlike the global context set by \ref zookeeper_init, this watcher context
934  * is associated with the given instance of the watcher only.
935  * \param completion the routine to invoke when the request completes. The completion
936  * will be triggered with one of the following codes passed in as the rc argument:
937  * ZOK operation completed successfully
938  * ZNONODE the node does not exist.
939  * ZNOAUTH the client does not have permission.
940  * \param data the data that will be passed to the completion routine when 
941  * the function completes.
942  * \return ZOK on success or one of the following errcodes on failure:
943  * ZBADARGUMENTS - invalid input parameters
944  * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
945  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
946  */
947  int zoo_awget(zhandle_t *zh, const char *path,  watcher_fn watcher, void* watcherCtx,  data_completion_t completion, const void *data);
948 
949 /**
950  * \brief sets the data associated with a node.
951  * 
952  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
953  * \param path the name of the node. Expressed as a file name with slashes 
954  * separating ancestors of the node.
955  * \param buffer the buffer holding data to be written to the node.
956  * \param buflen the number of bytes from buffer to write.
957  * \param version the expected version of the node. The function will fail if 
958  * the actual version of the node does not match the expected version. If -1 is 
959  * used the version check will not take place. * completion: If null, 
960  * the function will execute synchronously. Otherwise, the function will return 
961  * immediately and invoke the completion routine when the request completes.
962  * \param completion the routine to invoke when the request completes. The completion
963  * will be triggered with one of the following codes passed in as the rc argument:
964  * ZOK operation completed successfully
965  * ZNONODE the node does not exist.
966  * ZNOAUTH the client does not have permission.
967  * ZBADVERSION expected version does not match actual version.
968  * \param data the data that will be passed to the completion routine when 
969  * the function completes.
970  * \return ZOK on success or one of the following errcodes on failure:
971  * ZBADARGUMENTS - invalid input parameters
972  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
973  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
974  */
975  int zoo_aset(zhandle_t *zh, const char *path, const char *buffer, int buflen,int version_, stat_completion_t completion, const void *data);
976 
977 /**
978  * \brief lists the children of a node.
979  * 
980  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
981  * \param path the name of the node. Expressed as a file name with slashes 
982  * separating ancestors of the node.
983  * \param watch if nonzero, a watch will be set at the server to notify 
984  * the client if the node changes.
985  * \param completion the routine to invoke when the request completes. The completion
986  * will be triggered with one of the following codes passed in as the rc argument:
987  * ZOK operation completed successfully
988  * ZNONODE the node does not exist.
989  * ZNOAUTH the client does not have permission.
990  * \param data the data that will be passed to the completion routine when 
991  * the function completes.
992  * \return ZOK on success or one of the following errcodes on failure:
993  * ZBADARGUMENTS - invalid input parameters
994  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
995  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
996  */
997  int zoo_aget_children(zhandle_t *zh, const char *path, int watch, strings_completion_t completion, const void *data);
998 
999 /**
1000  * \brief lists the children of a node.
1001  * 
1002  * This function is similar to \ref zoo_aget_children except it allows one specify 
1003  * a watcher object rather than a boolean watch flag.
1004  *  
1005  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1006  * \param path the name of the node. Expressed as a file name with slashes 
1007  * separating ancestors of the node.
1008  * \param watcher if non-null, a watch will be set at the server to notify 
1009  * the client if the node changes.
1010  * \param watcherCtx user specific data, will be passed to the watcher callback.
1011  * Unlike the global context set by \ref zookeeper_init, this watcher context
1012  * is associated with the given instance of the watcher only.
1013  * \param completion the routine to invoke when the request completes. The completion
1014  * will be triggered with one of the following codes passed in as the rc argument:
1015  * ZOK operation completed successfully
1016  * ZNONODE the node does not exist.
1017  * ZNOAUTH the client does not have permission.
1018  * \param data the data that will be passed to the completion routine when 
1019  * the function completes.
1020  * \return ZOK on success or one of the following errcodes on failure:
1021  * ZBADARGUMENTS - invalid input parameters
1022  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1023  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1024  */
1025  int zoo_awget_children(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, strings_completion_t completion, const void *data);
1026 
1027 /**
1028  * \brief lists the children of a node, and get the parent stat.
1029  * 
1030  * This function is new in version 3.3.0
1031  *
1032  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1033  * \param path the name of the node. Expressed as a file name with slashes 
1034  * separating ancestors of the node.
1035  * \param watch if nonzero, a watch will be set at the server to notify 
1036  * the client if the node changes.
1037  * \param completion the routine to invoke when the request completes. The completion
1038  * will be triggered with one of the following codes passed in as the rc argument:
1039  * ZOK operation completed successfully
1040  * ZNONODE the node does not exist.
1041  * ZNOAUTH the client does not have permission.
1042  * \param data the data that will be passed to the completion routine when 
1043  * the function completes.
1044  * \return ZOK on success or one of the following errcodes on failure:
1045  * ZBADARGUMENTS - invalid input parameters
1046  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1047  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1048  */
1049  int zoo_aget_children2(zhandle_t *zh, const char *path, int watch, strings_stat_completion_t completion, const void *data);
1050 
1051 /**
1052  * \brief lists the children of a node, and get the parent stat.
1053  * 
1054  * This function is similar to \ref zoo_aget_children2 except it allows one specify 
1055  * a watcher object rather than a boolean watch flag.
1056  *  
1057  * This function is new in version 3.3.0
1058  *
1059  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1060  * \param path the name of the node. Expressed as a file name with slashes 
1061  * separating ancestors of the node.
1062  * \param watcher if non-null, a watch will be set at the server to notify 
1063  * the client if the node changes.
1064  * \param watcherCtx user specific data, will be passed to the watcher callback.
1065  * Unlike the global context set by \ref zookeeper_init, this watcher context
1066  * is associated with the given instance of the watcher only.
1067  * \param completion the routine to invoke when the request completes. The completion
1068  * will be triggered with one of the following codes passed in as the rc argument:
1069  * ZOK operation completed successfully
1070  * ZNONODE the node does not exist.
1071  * ZNOAUTH the client does not have permission.
1072  * \param data the data that will be passed to the completion routine when 
1073  * the function completes.
1074  * \return ZOK on success or one of the following errcodes on failure:
1075  * ZBADARGUMENTS - invalid input parameters
1076  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1077  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1078  */
1079  int zoo_awget_children2(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx,  strings_stat_completion_t completion, const void *data);
1080 
1081 /**
1082  * \brief Flush leader channel.
1083  *
1084  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1085  * \param path the name of the node. Expressed as a file name with slashes
1086  * separating ancestors of the node.
1087  * \param completion the routine to invoke when the request completes. The completion
1088  * will be triggered with one of the following codes passed in as the rc argument:
1089  * ZOK operation completed successfully
1090  * ZNONODE the node does not exist.
1091  * ZNOAUTH the client does not have permission.
1092  * \param data the data that will be passed to the completion routine when
1093  * the function completes.
1094  * \return ZOK on success or one of the following errcodes on failure:
1095  * ZBADARGUMENTS - invalid input parameters
1096  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1097  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1098  */
1099 
1100  int zoo_async(zhandle_t *zh, const char *path,  string_completion_t completion, const void *data);
1101 
1102 
1103 /**
1104  * \brief gets the acl associated with a node.
1105  * 
1106  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1107  * \param path the name of the node. Expressed as a file name with slashes 
1108  * separating ancestors of the node.
1109  * \param completion the routine to invoke when the request completes. The completion
1110  * will be triggered with one of the following codes passed in as the rc argument:
1111  * ZOK operation completed successfully
1112  * ZNONODE the node does not exist.
1113  * ZNOAUTH the client does not have permission.
1114  * \param data the data that will be passed to the completion routine when 
1115  * the function completes.
1116  * \return ZOK on success or one of the following errcodes on failure:
1117  * ZBADARGUMENTS - invalid input parameters
1118  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1119  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1120  */
1121  int zoo_aget_acl(zhandle_t *zh, const char *path, acl_completion_t completion, const void *data);
1122 
1123 /**
1124  * \brief sets the acl associated with a node.
1125  * 
1126  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1127  * \param path the name of the node. Expressed as a file name with slashes 
1128  * separating ancestors of the node.
1129  * \param buffer the buffer holding the acls to be written to the node.
1130  * \param buflen the number of bytes from buffer to write.
1131  * \param completion the routine to invoke when the request completes. The completion
1132  * will be triggered with one of the following codes passed in as the rc argument:
1133  * ZOK operation completed successfully
1134  * ZNONODE the node does not exist.
1135  * ZNOAUTH the client does not have permission.
1136  * ZINVALIDACL invalid ACL specified
1137  * ZBADVERSION expected version does not match actual version.
1138  * \param data the data that will be passed to the completion routine when 
1139  * the function completes.
1140  * \return ZOK on success or one of the following errcodes on failure:
1141  * ZBADARGUMENTS - invalid input parameters
1142  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1143  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1144  */
1145  int zoo_aset_acl(zhandle_t *zh, const char *path, int version_, ACL_vector *acl, void_completion_t, const void *data);
1146 
1147 /**
1148  * \brief atomically commits multiple zookeeper operations.
1149  *
1150  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1151  * \param count the number of operations
1152  * \param ops an array of operations to commit
1153  * \param results an array to hold the results of the operations
1154  * \param completion the routine to invoke when the request completes. The completion
1155  * will be triggered with any of the error codes that can that can be returned by the 
1156  * ops supported by a multi op (see \ref zoo_acreate, \ref zoo_adelete, \ref zoo_aset).
1157  * \param data the data that will be passed to the completion routine when
1158  * the function completes.
1159  * \return the return code for the function call. This can be any of the
1160  * values that can be returned by the ops supported by a multi op (see
1161  * \ref zoo_acreate, \ref zoo_adelete, \ref zoo_aset).
1162  */
1163  int zoo_amulti(zhandle_t *zh, int count, const zoo_op_t *ops, zoo_op_result_t *results, void_completion_t, const void *data);
1164 
1165 /**
1166  * \brief return an error string.
1167  * 
1168  * \param return code
1169  * \return string corresponding to the return code
1170  */
1171  const(char) * zerror(int c);
1172 
1173 /**
1174  * \brief specify application credentials.
1175  * 
1176  * The application calls this function to specify its credentials for purposes
1177  * of authentication. The server will use the security provider specified by 
1178  * the scheme parameter to authenticate the client connection. If the 
1179  * authentication request has failed:
1180  * - the server connection is dropped
1181  * - the watcher is called with the ZOO_AUTH_FAILED_STATE value as the state 
1182  * parameter.
1183  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1184  * \param scheme the id of authentication scheme. Natively supported:
1185  * "digest" password-based authentication
1186  * \param cert application credentials. The actual value depends on the scheme.
1187  * \param certLen the length of the data parameter
1188  * \param completion the routine to invoke when the request completes. One of 
1189  * the following result codes may be passed into the completion callback:
1190  * ZOK operation completed successfully
1191  * ZAUTHFAILED authentication failed 
1192  * \param data the data that will be passed to the completion routine when the 
1193  * function completes.
1194  * \return ZOK on success or one of the following errcodes on failure:
1195  * ZBADARGUMENTS - invalid input parameters
1196  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1197  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1198  * ZSYSTEMERROR - a system error occured
1199  */
1200  int zoo_add_auth(zhandle_t *zh,const char* scheme,const char* cert, int certLen, void_completion_t completion, const void *data);
1201 
1202 /**
1203  * \brief checks if the current zookeeper connection state can't be recovered.
1204  * 
1205  *  The application must close the zhandle and try to reconnect.
1206  * 
1207  * \param zh the zookeeper handle (see \ref zookeeper_init)
1208  * \return ZINVALIDSTATE if connection is unrecoverable
1209  */
1210  int is_unrecoverable(zhandle_t *zh);
1211 
1212 /**
1213  * \brief sets the debugging level for the library 
1214  */
1215  void zoo_set_debug_level(ZooLogLevel logLevel);
1216 
1217 /**
1218  * \brief sets the stream to be used by the library for logging 
1219  * 
1220  * The zookeeper library uses stderr as its default log stream. Application
1221  * must make sure the stream is writable. Passing in NULL resets the stream 
1222  * to its default value (stderr).
1223  */
1224  void zoo_set_log_stream(FILE* logStream);
1225 
1226 /**
1227  * \brief enable/disable quorum endpoint order randomization
1228  * 
1229  * Note: typically this method should NOT be used outside of testing.
1230  *
1231  * If passed a non-zero value, will make the client connect to quorum peers
1232  * in the order as specified in the zookeeper_init() call.
1233  * A zero value causes zookeeper_init() to permute the peer endpoints
1234  * which is good for more even client connection distribution among the 
1235  * quorum peers.
1236  */
1237  void zoo_deterministic_conn_order(int yesOrNo);
1238 
1239 /**
1240  * \brief create a node synchronously.
1241  * 
1242  * This method will create a node in ZooKeeper. A node can only be created if
1243  * it does not already exists. The Create Flags affect the creation of nodes.
1244  * If ZOO_EPHEMERAL flag is set, the node will automatically get removed if the
1245  * client session goes away. If the ZOO_SEQUENCE flag is set, a unique
1246  * monotonically increasing sequence number is appended to the path name.
1247  * 
1248  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1249  * \param path The name of the node. Expressed as a file name with slashes 
1250  * separating ancestors of the node.
1251  * \param value The data to be stored in the node.
1252  * \param valuelen The number of bytes in data. To set the data to be NULL use
1253  * value as NULL and valuelen as -1.
1254  * \param acl The initial ACL of the node. The ACL must not be null or empty.
1255  * \param flags this parameter can be set to 0 for normal create or an OR
1256  *    of the Create Flags
1257  * \param path_buffer Buffer which will be filled with the path of the
1258  *    new node (this might be different than the supplied path
1259  *    because of the ZOO_SEQUENCE flag).  The path string will always be
1260  *    null-terminated. This parameter may be NULL if path_buffer_len = 0.
1261  * \param path_buffer_len Size of path buffer; if the path of the new
1262  *    node (including space for the null terminator) exceeds the buffer size,
1263  *    the path string will be truncated to fit.  The actual path of the
1264  *    new node in the server will not be affected by the truncation.
1265  *    The path string will always be null-terminated.
1266  * \return  one of the following codes are returned:
1267  * ZOK operation completed successfully
1268  * ZNONODE the parent node does not exist.
1269  * ZNODEEXISTS the node already exists
1270  * ZNOAUTH the client does not have permission.
1271  * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
1272  * ZBADARGUMENTS - invalid input parameters
1273  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1274  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1275  */
1276  int zoo_create(zhandle_t *zh, const char *path, const char *value,int valuelen, const ACL_vector *acl, int flags,char *path_buffer, int path_buffer_len);
1277 
1278 /**
1279  * \brief delete a node in zookeeper synchronously.
1280  * 
1281  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1282  * \param path the name of the node. Expressed as a file name with slashes 
1283  * separating ancestors of the node.
1284  * \param version the expected version of the node. The function will fail if the
1285  *    actual version of the node does not match the expected version.
1286  *  If -1 is used the version check will not take place. 
1287  * \return one of the following values is returned.
1288  * ZOK operation completed successfully
1289  * ZNONODE the node does not exist.
1290  * ZNOAUTH the client does not have permission.
1291  * ZBADVERSION expected version does not match actual version.
1292  * ZNOTEMPTY children are present; node cannot be deleted.
1293  * ZBADARGUMENTS - invalid input parameters
1294  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1295  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1296  */
1297  int zoo_delete(zhandle_t *zh, const char *path, int version_);
1298 
1299 
1300 /**
1301  * \brief checks the existence of a node in zookeeper synchronously.
1302  * 
1303  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1304  * \param path the name of the node. Expressed as a file name with slashes 
1305  * separating ancestors of the node.
1306  * \param watch if nonzero, a watch will be set at the server to notify the 
1307  * client if the node changes. The watch will be set even if the node does not 
1308  * exist. This allows clients to watch for nodes to appear.
1309  * \param the return stat value of the node.
1310  * \return  return code of the function call.
1311  * ZOK operation completed successfully
1312  * ZNONODE the node does not exist.
1313  * ZNOAUTH the client does not have permission.
1314  * ZBADARGUMENTS - invalid input parameters
1315  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1316  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1317  */
1318  int zoo_exists(zhandle_t *zh, const char *path, int watch, Stat *stat);
1319 
1320 /**
1321  * \brief checks the existence of a node in zookeeper synchronously.
1322  * 
1323  * This function is similar to \ref zoo_exists except it allows one specify 
1324  * a watcher object rather than a boolean watch flag.
1325  * 
1326  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1327  * \param path the name of the node. Expressed as a file name with slashes 
1328  * separating ancestors of the node.
1329  * \param watcher if non-null a watch will set on the specified znode on the server.
1330  * The watch will be set even if the node does not exist. This allows clients 
1331  * to watch for nodes to appear.
1332  * \param watcherCtx user specific data, will be passed to the watcher callback.
1333  * Unlike the global context set by \ref zookeeper_init, this watcher context
1334  * is associated with the given instance of the watcher only.
1335  * \param the return stat value of the node.
1336  * \return  return code of the function call.
1337  * ZOK operation completed successfully
1338  * ZNONODE the node does not exist.
1339  * ZNOAUTH the client does not have permission.
1340  * ZBADARGUMENTS - invalid input parameters
1341  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1342  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1343  */
1344  int zoo_wexists(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, Stat *stat);
1345 
1346 /**
1347  * \brief gets the data associated with a node synchronously.
1348  * 
1349  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1350  * \param path the name of the node. Expressed as a file name with slashes 
1351  * separating ancestors of the node.
1352  * \param watch if nonzero, a watch will be set at the server to notify 
1353  * the client if the node changes.
1354  * \param buffer the buffer holding the node data returned by the server
1355  * \param buffer_len is the size of the buffer pointed to by the buffer parameter.
1356  * It'll be set to the actual data length upon return. If the data is NULL, length is -1.
1357  * \param stat if not NULL, will hold the value of stat for the path on return.
1358  * \return return value of the function call.
1359  * ZOK operation completed successfully
1360  * ZNONODE the node does not exist.
1361  * ZNOAUTH the client does not have permission.
1362  * ZBADARGUMENTS - invalid input parameters
1363  * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1364  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1365  */
1366  int zoo_get(zhandle_t *zh, const char *path, int watch, char *buffer, int* buffer_len, Stat *stat);
1367 
1368 /**
1369  * \brief gets the data associated with a node synchronously.
1370  * 
1371  * This function is similar to \ref zoo_get except it allows one specify 
1372  * a watcher object rather than a boolean watch flag.
1373  * 
1374  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1375  * \param path the name of the node. Expressed as a file name with slashes 
1376  * separating ancestors of the node.
1377  * \param watcher if non-null, a watch will be set at the server to notify 
1378  * the client if the node changes.
1379  * \param watcherCtx user specific data, will be passed to the watcher callback.
1380  * Unlike the global context set by \ref zookeeper_init, this watcher context
1381  * is associated with the given instance of the watcher only.
1382  * \param buffer the buffer holding the node data returned by the server
1383  * \param buffer_len is the size of the buffer pointed to by the buffer parameter.
1384  * It'll be set to the actual data length upon return. If the data is NULL, length is -1.
1385  * \param stat if not NULL, will hold the value of stat for the path on return.
1386  * \return return value of the function call.
1387  * ZOK operation completed successfully
1388  * ZNONODE the node does not exist.
1389  * ZNOAUTH the client does not have permission.
1390  * ZBADARGUMENTS - invalid input parameters
1391  * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1392  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1393  */
1394  int zoo_wget(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, char *buffer, int* buffer_len, Stat *stat);
1395 
1396 /**
1397  * \brief sets the data associated with a node. See zoo_set2 function if
1398  * you require access to the stat information associated with the znode.
1399  * 
1400  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1401  * \param path the name of the node. Expressed as a file name with slashes 
1402  * separating ancestors of the node.
1403  * \param buffer the buffer holding data to be written to the node.
1404  * \param buflen the number of bytes from buffer to write. To set NULL as data 
1405  * use buffer as NULL and buflen as -1.
1406  * \param version the expected version of the node. The function will fail if 
1407  * the actual version of the node does not match the expected version. If -1 is 
1408  * used the version check will not take place. 
1409  * \return the return code for the function call.
1410  * ZOK operation completed successfully
1411  * ZNONODE the node does not exist.
1412  * ZNOAUTH the client does not have permission.
1413  * ZBADVERSION expected version does not match actual version.
1414  * ZBADARGUMENTS - invalid input parameters
1415  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1416  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1417  */
1418  int zoo_set(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version_);
1419 
1420 /**
1421  * \brief sets the data associated with a node. This function is the same
1422  * as zoo_set except that it also provides access to stat information
1423  * associated with the znode.
1424  * 
1425  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1426  * \param path the name of the node. Expressed as a file name with slashes 
1427  * separating ancestors of the node.
1428  * \param buffer the buffer holding data to be written to the node.
1429  * \param buflen the number of bytes from buffer to write. To set NULL as data
1430  * use buffer as NULL and buflen as -1.
1431  * \param version the expected version of the node. The function will fail if 
1432  * the actual version of the node does not match the expected version. If -1 is 
1433  * used the version check will not take place. 
1434  * \param stat if not NULL, will hold the value of stat for the path on return.
1435  * \return the return code for the function call.
1436  * ZOK operation completed successfully
1437  * ZNONODE the node does not exist.
1438  * ZNOAUTH the client does not have permission.
1439  * ZBADVERSION expected version does not match actual version.
1440  * ZBADARGUMENTS - invalid input parameters
1441  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1442  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1443  */
1444  int zoo_set2(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version_, Stat *stat);
1445 
1446 /**
1447  * \brief lists the children of a node synchronously.
1448  * 
1449  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1450  * \param path the name of the node. Expressed as a file name with slashes 
1451  * separating ancestors of the node.
1452  * \param watch if nonzero, a watch will be set at the server to notify 
1453  * the client if the node changes.
1454  * \param strings return value of children paths.
1455  * \return the return code of the function.
1456  * ZOK operation completed successfully
1457  * ZNONODE the node does not exist.
1458  * ZNOAUTH the client does not have permission.
1459  * ZBADARGUMENTS - invalid input parameters
1460  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1461  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1462  */
1463  int zoo_get_children(zhandle_t *zh, const char *path, int watch, String_vector *strings);
1464 
1465 /**
1466  * \brief lists the children of a node synchronously.
1467  * 
1468  * This function is similar to \ref zoo_get_children except it allows one specify 
1469  * a watcher object rather than a boolean watch flag.
1470  * 
1471  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1472  * \param path the name of the node. Expressed as a file name with slashes 
1473  * separating ancestors of the node.
1474  * \param watcher if non-null, a watch will be set at the server to notify 
1475  * the client if the node changes.
1476  * \param watcherCtx user specific data, will be passed to the watcher callback.
1477  * Unlike the global context set by \ref zookeeper_init, this watcher context
1478  * is associated with the given instance of the watcher only.
1479  * \param strings return value of children paths.
1480  * \return the return code of the function.
1481  * ZOK operation completed successfully
1482  * ZNONODE the node does not exist.
1483  * ZNOAUTH the client does not have permission.
1484  * ZBADARGUMENTS - invalid input parameters
1485  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1486  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1487  */
1488  int zoo_wget_children(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, String_vector *strings);
1489 
1490 /**
1491  * \brief lists the children of a node and get its stat synchronously.
1492  * 
1493  * This function is new in version 3.3.0
1494  *
1495  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1496  * \param path the name of the node. Expressed as a file name with slashes 
1497  * separating ancestors of the node.
1498  * \param watch if nonzero, a watch will be set at the server to notify 
1499  * the client if the node changes.
1500  * \param strings return value of children paths.
1501  * \param stat return value of node stat.
1502  * \return the return code of the function.
1503  * ZOK operation completed successfully
1504  * ZNONODE the node does not exist.
1505  * ZNOAUTH the client does not have permission.
1506  * ZBADARGUMENTS - invalid input parameters
1507  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1508  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1509  */
1510  int zoo_get_children2(zhandle_t *zh, const char *path, int watch, String_vector *strings, Stat *stat);
1511 
1512 /**
1513  * \brief lists the children of a node and get its stat synchronously.
1514  * 
1515  * This function is similar to \ref zoo_get_children except it allows one specify 
1516  * a watcher object rather than a boolean watch flag.
1517  * 
1518  * This function is new in version 3.3.0
1519  *
1520  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1521  * \param path the name of the node. Expressed as a file name with slashes 
1522  * separating ancestors of the node.
1523  * \param watcher if non-null, a watch will be set at the server to notify 
1524  * the client if the node changes.
1525  * \param watcherCtx user specific data, will be passed to the watcher callback.
1526  * Unlike the global context set by \ref zookeeper_init, this watcher context
1527  * is associated with the given instance of the watcher only.
1528  * \param strings return value of children paths.
1529  * \param stat return value of node stat.
1530  * \return the return code of the function.
1531  * ZOK operation completed successfully
1532  * ZNONODE the node does not exist.
1533  * ZNOAUTH the client does not have permission.
1534  * ZBADARGUMENTS - invalid input parameters
1535  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1536  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1537  */
1538  int zoo_wget_children2(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, String_vector *strings, Stat *stat);
1539 
1540 /**
1541  * \brief gets the acl associated with a node synchronously.
1542  * 
1543  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1544  * \param path the name of the node. Expressed as a file name with slashes 
1545  * separating ancestors of the node.
1546  * \param acl the return value of acls on the path.
1547  * \param stat returns the stat of the path specified.
1548  * \return the return code for the function call.
1549  * ZOK operation completed successfully
1550  * ZNONODE the node does not exist.
1551  * ZNOAUTH the client does not have permission.
1552  * ZBADARGUMENTS - invalid input parameters
1553  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1554  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1555  */
1556  int zoo_get_acl(zhandle_t *zh, const char *path, ACL_vector *acl, Stat *stat);
1557 
1558 /**
1559  * \brief sets the acl associated with a node synchronously.
1560  * 
1561  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1562  * \param path the name of the node. Expressed as a file name with slashes 
1563  * separating ancestors of the node.
1564  * \param version the expected version of the path.
1565  * \param acl the acl to be set on the path. 
1566  * \return the return code for the function call.
1567  * ZOK operation completed successfully
1568  * ZNONODE the node does not exist.
1569  * ZNOAUTH the client does not have permission.
1570  * ZINVALIDACL invalid ACL specified
1571  * ZBADVERSION expected version does not match actual version.
1572  * ZBADARGUMENTS - invalid input parameters
1573  * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
1574  * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
1575  */
1576  int zoo_set_acl(zhandle_t *zh, const char *path, int version_, const ACL_vector *acl);
1577 
1578 /**
1579  * \brief atomically commits multiple zookeeper operations synchronously.
1580  *
1581  * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
1582  * \param count the number of operations
1583  * \param ops an array of operations to commit
1584  * \param results an array to hold the results of the operations
1585  * \return the return code for the function call. This can be any of the
1586  * values that can be returned by the ops supported by a multi op (see
1587  * \ref zoo_acreate, \ref zoo_adelete, \ref zoo_aset).
1588  */ 
1589  int zoo_multi(zhandle_t *zh, int count, const zoo_op_t *ops, zoo_op_result_t *results);