zookeeper.h 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295
  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. #ifndef ZOOKEEPER_H_
  19. #define ZOOKEEPER_H_
  20. #include <stdlib.h>
  21. /* we must not include config.h as a public header */
  22. #ifndef WIN32
  23. #include <sys/socket.h>
  24. #include <sys/time.h>
  25. #endif
  26. #ifdef WIN32
  27. #include <winsock2.h> /* must always be included before ws2tcpip.h */
  28. #include <ws2tcpip.h> /* for struct sock_addr and socklen_t */
  29. #endif
  30. #include <stdio.h>
  31. #include <ctype.h>
  32. #include "proto.h"
  33. #include "zookeeper_version.h"
  34. #include "recordio.h"
  35. #include "zookeeper.jute.h"
  36. /**
  37. * \file zookeeper.h
  38. * \brief ZooKeeper functions and definitions.
  39. *
  40. * ZooKeeper is a network service that may be backed by a cluster of
  41. * synchronized servers. The data in the service is represented as a tree
  42. * of data nodes. Each node has data, children, an ACL, and status information.
  43. * The data for a node is read and write in its entirety.
  44. *
  45. * ZooKeeper clients can leave watches when they queries the data or children
  46. * of a node. If a watch is left, that client will be notified of the change.
  47. * The notification is a one time trigger. Subsequent chances to the node will
  48. * not trigger a notification unless the client issues a query with the watch
  49. * flag set. If the client is ever disconnected from the service, the watches do
  50. * not need to be reset. The client automatically resets the watches.
  51. *
  52. * When a node is created, it may be flagged as an ephemeral node. Ephemeral
  53. * nodes are automatically removed when a client session is closed or when
  54. * a session times out due to inactivity (the ZooKeeper runtime fills in
  55. * periods of inactivity with pings). Ephemeral nodes cannot have children.
  56. *
  57. * ZooKeeper clients are identified by a server assigned session id. For
  58. * security reasons The server
  59. * also generates a corresponding password for a session. A client may save its
  60. * id and corresponding password to persistent storage in order to use the
  61. * session across program invocation boundaries.
  62. */
  63. /* Support for building on various platforms */
  64. // on cygwin we should take care of exporting/importing symbols properly
  65. #ifdef DLL_EXPORT
  66. # define ZOOAPI __declspec(dllexport)
  67. #else
  68. # if (defined(__CYGWIN__) || defined(WIN32)) && !defined(USE_STATIC_LIB)
  69. # define ZOOAPI __declspec(dllimport)
  70. # else
  71. # define ZOOAPI
  72. # endif
  73. #endif
  74. /** zookeeper return constants **/
  75. enum ZOO_ERRORS {
  76. ZOK = 0, /*!< Everything is OK */
  77. /** System and server-side errors.
  78. * This is never thrown by the server, it shouldn't be used other than
  79. * to indicate a range. Specifically error codes greater than this
  80. * value, but lesser than {@link #ZAPIERROR}, are system errors. */
  81. ZSYSTEMERROR = -1,
  82. ZRUNTIMEINCONSISTENCY = -2, /*!< A runtime inconsistency was found */
  83. ZDATAINCONSISTENCY = -3, /*!< A data inconsistency was found */
  84. ZCONNECTIONLOSS = -4, /*!< Connection to the server has been lost */
  85. ZMARSHALLINGERROR = -5, /*!< Error while marshalling or unmarshalling data */
  86. ZUNIMPLEMENTED = -6, /*!< Operation is unimplemented */
  87. ZOPERATIONTIMEOUT = -7, /*!< Operation timeout */
  88. ZBADARGUMENTS = -8, /*!< Invalid arguments */
  89. ZINVALIDSTATE = -9, /*!< Invliad zhandle state */
  90. ZNEWCONFIGNOQUORUM = -13, /*!< No quorum of new config is connected and
  91. up-to-date with the leader of last commmitted
  92. config - try invoking reconfiguration after new
  93. servers are connected and synced */
  94. ZRECONFIGINPROGRESS = -14, /*!< Reconfiguration requested while another
  95. reconfiguration is currently in progress. This
  96. is currently not supported. Please retry. */
  97. /** API errors.
  98. * This is never thrown by the server, it shouldn't be used other than
  99. * to indicate a range. Specifically error codes greater than this
  100. * value are API errors (while values less than this indicate a
  101. * {@link #ZSYSTEMERROR}).
  102. */
  103. ZAPIERROR = -100,
  104. ZNONODE = -101, /*!< Node does not exist */
  105. ZNOAUTH = -102, /*!< Not authenticated */
  106. ZBADVERSION = -103, /*!< Version conflict */
  107. ZNOCHILDRENFOREPHEMERALS = -108, /*!< Ephemeral nodes may not have children */
  108. ZNODEEXISTS = -110, /*!< The node already exists */
  109. ZNOTEMPTY = -111, /*!< The node has children */
  110. ZSESSIONEXPIRED = -112, /*!< The session has been expired by the server */
  111. ZINVALIDCALLBACK = -113, /*!< Invalid callback specified */
  112. ZINVALIDACL = -114, /*!< Invalid ACL specified */
  113. ZAUTHFAILED = -115, /*!< Client authentication failed */
  114. ZCLOSING = -116, /*!< ZooKeeper is closing */
  115. ZNOTHING = -117, /*!< (not error) no server responses to process */
  116. ZSESSIONMOVED = -118, /*!<session moved to another server, so operation is ignored */
  117. ZNOTREADONLY = -119, /*!< state-changing request is passed to read-only server */
  118. ZEPHEMERALONLOCALSESSION = -120, /*!< Attempt to create ephemeral node on a local session */
  119. ZNOWATCHER = -121, /*!< The watcher couldn't be found */
  120. ZRECONFIGDISABLED = -123 /*!< Attempts to perform a reconfiguration operation when reconfiguration feature is disabled */
  121. };
  122. #ifdef __cplusplus
  123. extern "C" {
  124. #endif
  125. /**
  126. * @name Debug levels
  127. */
  128. typedef enum {ZOO_LOG_LEVEL_ERROR=1,ZOO_LOG_LEVEL_WARN=2,ZOO_LOG_LEVEL_INFO=3,ZOO_LOG_LEVEL_DEBUG=4} ZooLogLevel;
  129. /**
  130. * @name ACL Consts
  131. */
  132. extern ZOOAPI const int ZOO_PERM_READ;
  133. extern ZOOAPI const int ZOO_PERM_WRITE;
  134. extern ZOOAPI const int ZOO_PERM_CREATE;
  135. extern ZOOAPI const int ZOO_PERM_DELETE;
  136. extern ZOOAPI const int ZOO_PERM_ADMIN;
  137. extern ZOOAPI const int ZOO_PERM_ALL;
  138. #define ZOO_CONFIG_NODE "/zookeeper/config"
  139. /* flags for zookeeper_init{,2} */
  140. #define ZOO_READONLY 1
  141. /** Disable logging of the client environment at initialization time. */
  142. #define ZOO_NO_LOG_CLIENTENV 2
  143. /** This Id represents anyone. */
  144. extern ZOOAPI struct Id ZOO_ANYONE_ID_UNSAFE;
  145. /** This Id is only usable to set ACLs. It will get substituted with the
  146. * Id's the client authenticated with.
  147. */
  148. extern ZOOAPI struct Id ZOO_AUTH_IDS;
  149. /** This is a completely open ACL*/
  150. extern ZOOAPI struct ACL_vector ZOO_OPEN_ACL_UNSAFE;
  151. /** This ACL gives the world the ability to read. */
  152. extern ZOOAPI struct ACL_vector ZOO_READ_ACL_UNSAFE;
  153. /** This ACL gives the creators authentication id's all permissions. */
  154. extern ZOOAPI struct ACL_vector ZOO_CREATOR_ALL_ACL;
  155. /**
  156. * @name Interest Consts
  157. * These constants are used to express interest in an event and to
  158. * indicate to zookeeper which events have occurred. They can
  159. * be ORed together to express multiple interests. These flags are
  160. * used in the interest and event parameters of
  161. * \ref zookeeper_interest and \ref zookeeper_process.
  162. */
  163. // @{
  164. extern ZOOAPI const int ZOOKEEPER_WRITE;
  165. extern ZOOAPI const int ZOOKEEPER_READ;
  166. // @}
  167. /**
  168. * @name Create Mode
  169. *
  170. * These modes are used by zoo_create to affect node create.
  171. */
  172. // @{
  173. extern ZOOAPI const int ZOO_PERSISTENT;
  174. extern ZOOAPI const int ZOO_EPHEMERAL;
  175. extern ZOOAPI const int ZOO_PERSISTENT_SEQUENTIAL;
  176. extern ZOOAPI const int ZOO_EPHEMERAL_SEQUENTIAL;
  177. extern ZOOAPI const int ZOO_CONTAINER;
  178. extern ZOOAPI const int ZOO_PERSISTENT_WITH_TTL;
  179. extern ZOOAPI const int ZOO_PERSISTENT_SEQUENTIAL_WITH_TTL;
  180. /**
  181. * \deprecated ZOO_SEQUENCE Create Flag has been deprecated. Use ZOO_PERSISTENT_SEQUENTIAL
  182. * or ZOO_EPHEMERAL_SEQUENTIAL instead of it.
  183. */
  184. extern ZOOAPI const int ZOO_SEQUENCE;
  185. // @}
  186. /**
  187. * @name State Consts
  188. * These constants represent the states of a zookeeper connection. They are
  189. * possible parameters of the watcher callback.
  190. */
  191. // @{
  192. extern ZOOAPI const int ZOO_EXPIRED_SESSION_STATE;
  193. extern ZOOAPI const int ZOO_AUTH_FAILED_STATE;
  194. extern ZOOAPI const int ZOO_CONNECTING_STATE;
  195. extern ZOOAPI const int ZOO_ASSOCIATING_STATE;
  196. extern ZOOAPI const int ZOO_CONNECTED_STATE;
  197. extern ZOOAPI const int ZOO_READONLY_STATE;
  198. extern ZOOAPI const int ZOO_NOTCONNECTED_STATE;
  199. // @}
  200. /**
  201. * @name Watch Types
  202. * These constants indicate the event that caused the watch event. They are
  203. * possible values of the first parameter of the watcher callback.
  204. */
  205. // @{
  206. /**
  207. * \brief a node has been created.
  208. *
  209. * This is only generated by watches on non-existent nodes. These watches
  210. * are set using \ref zoo_exists.
  211. */
  212. extern ZOOAPI const int ZOO_CREATED_EVENT;
  213. /**
  214. * \brief a node has been deleted.
  215. *
  216. * This is only generated by watches on nodes. These watches
  217. * are set using \ref zoo_exists and \ref zoo_get.
  218. */
  219. extern ZOOAPI const int ZOO_DELETED_EVENT;
  220. /**
  221. * \brief a node has changed.
  222. *
  223. * This is only generated by watches on nodes. These watches
  224. * are set using \ref zoo_exists and \ref zoo_get.
  225. */
  226. extern ZOOAPI const int ZOO_CHANGED_EVENT;
  227. /**
  228. * \brief a change as occurred in the list of children.
  229. *
  230. * This is only generated by watches on the child list of a node. These watches
  231. * are set using \ref zoo_get_children or \ref zoo_get_children2.
  232. */
  233. extern ZOOAPI const int ZOO_CHILD_EVENT;
  234. /**
  235. * \brief a session has been lost.
  236. *
  237. * This is generated when a client loses contact or reconnects with a server.
  238. */
  239. extern ZOOAPI const int ZOO_SESSION_EVENT;
  240. /**
  241. * \brief a watch has been removed.
  242. *
  243. * This is generated when the server for some reason, probably a resource
  244. * constraint, will no longer watch a node for a client.
  245. */
  246. extern ZOOAPI const int ZOO_NOTWATCHING_EVENT;
  247. // @}
  248. /**
  249. * \brief ZooKeeper handle.
  250. *
  251. * This is the handle that represents a connection to the ZooKeeper service.
  252. * It is needed to invoke any ZooKeeper function. A handle is obtained using
  253. * \ref zookeeper_init.
  254. */
  255. typedef struct _zhandle zhandle_t;
  256. /**
  257. * \brief client id structure.
  258. *
  259. * This structure holds the id and password for the session. This structure
  260. * should be treated as opaque. It is received from the server when a session
  261. * is established and needs to be sent back as-is when reconnecting a session.
  262. */
  263. typedef struct {
  264. int64_t client_id;
  265. char passwd[16];
  266. } clientid_t;
  267. /**
  268. * \brief zoo_op structure.
  269. *
  270. * This structure holds all the arguments necessary for one op as part
  271. * of a containing multi_op via \ref zoo_multi or \ref zoo_amulti.
  272. * This structure should be treated as opaque and initialized via
  273. * \ref zoo_create_op_init, \ref zoo_delete_op_init, \ref zoo_set_op_init
  274. * and \ref zoo_check_op_init.
  275. */
  276. typedef struct zoo_op {
  277. int type;
  278. union {
  279. // CREATE
  280. struct {
  281. const char *path;
  282. const char *data;
  283. int datalen;
  284. char *buf;
  285. int buflen;
  286. const struct ACL_vector *acl;
  287. int flags;
  288. int64_t ttl;
  289. } create_op;
  290. // DELETE
  291. struct {
  292. const char *path;
  293. int version;
  294. } delete_op;
  295. // SET
  296. struct {
  297. const char *path;
  298. const char *data;
  299. int datalen;
  300. int version;
  301. struct Stat *stat;
  302. } set_op;
  303. // CHECK
  304. struct {
  305. const char *path;
  306. int version;
  307. } check_op;
  308. };
  309. } zoo_op_t;
  310. /**
  311. * \brief zoo_create_op_init.
  312. *
  313. * This function initializes a zoo_op_t with the arguments for a ZOO_CREATE_OP.
  314. *
  315. * \param op A pointer to the zoo_op_t to be initialized.
  316. * \param path The name of the node. Expressed as a file name with slashes
  317. * separating ancestors of the node.
  318. * \param value The data to be stored in the node.
  319. * \param valuelen The number of bytes in data. To set the data to be NULL use
  320. * value as NULL and valuelen as -1.
  321. * \param acl The initial ACL of the node. The ACL must not be null or empty.
  322. * \param mode this parameter should be one of the Create Modes.
  323. * \param path_buffer Buffer which will be filled with the path of the
  324. * new node (this might be different than the supplied path
  325. * because of the ZOO_SEQUENCE flag). The path string will always be
  326. * null-terminated. This parameter may be NULL if path_buffer_len = 0.
  327. * \param path_buffer_len Size of path buffer; if the path of the new
  328. * node (including space for the null terminator) exceeds the buffer size,
  329. * the path string will be truncated to fit. The actual path of the
  330. * new node in the server will not be affected by the truncation.
  331. * The path string will always be null-terminated.
  332. */
  333. void zoo_create_op_init(zoo_op_t *op, const char *path, const char *value,
  334. int valuelen, const struct ACL_vector *acl, int mode,
  335. char *path_buffer, int path_buffer_len);
  336. /**
  337. * \brief zoo_delete_op_init.
  338. *
  339. * This function initializes a zoo_op_t with the arguments for a ZOO_DELETE_OP.
  340. *
  341. * \param op A pointer to the zoo_op_t to be initialized.
  342. * \param path the name of the node. Expressed as a file name with slashes
  343. * separating ancestors of the node.
  344. * \param version the expected version of the node. The function will fail if the
  345. * actual version of the node does not match the expected version.
  346. * If -1 is used the version check will not take place.
  347. */
  348. void zoo_delete_op_init(zoo_op_t *op, const char *path, int version);
  349. /**
  350. * \brief zoo_set_op_init.
  351. *
  352. * This function initializes an zoo_op_t with the arguments for a ZOO_SETDATA_OP.
  353. *
  354. * \param op A pointer to the zoo_op_t to be initialized.
  355. * \param path the name of the node. Expressed as a file name with slashes
  356. * separating ancestors of the node.
  357. * \param buffer the buffer holding data to be written to the node.
  358. * \param buflen the number of bytes from buffer to write. To set NULL as data
  359. * use buffer as NULL and buflen as -1.
  360. * \param version the expected version of the node. The function will fail if
  361. * the actual version of the node does not match the expected version. If -1 is
  362. * used the version check will not take place.
  363. */
  364. void zoo_set_op_init(zoo_op_t *op, const char *path, const char *buffer,
  365. int buflen, int version, struct Stat *stat);
  366. /**
  367. * \brief zoo_check_op_init.
  368. *
  369. * This function initializes an zoo_op_t with the arguments for a ZOO_CHECK_OP.
  370. *
  371. * \param op A pointer to the zoo_op_t to be initialized.
  372. * \param path The name of the node. Expressed as a file name with slashes
  373. * separating ancestors of the node.
  374. * \param version the expected version of the node. The function will fail if the
  375. * actual version of the node does not match the expected version.
  376. */
  377. void zoo_check_op_init(zoo_op_t *op, const char *path, int version);
  378. /**
  379. * \brief zoo_op_result structure.
  380. *
  381. * This structure holds the result for an op submitted as part of a multi_op
  382. * via \ref zoo_multi or \ref zoo_amulti.
  383. */
  384. typedef struct zoo_op_result {
  385. int err;
  386. char *value;
  387. int valuelen;
  388. struct Stat *stat;
  389. } zoo_op_result_t;
  390. /**
  391. * \brief signature of a watch function.
  392. *
  393. * There are two ways to receive watch notifications: legacy and watcher object.
  394. * <p>
  395. * The legacy style, an application wishing to receive events from ZooKeeper must
  396. * first implement a function with this signature and pass a pointer to the function
  397. * to \ref zookeeper_init. Next, the application sets a watch by calling one of
  398. * the getter API that accept the watch integer flag (for example, \ref zoo_aexists,
  399. * \ref zoo_get, etc).
  400. * <p>
  401. * The watcher object style uses an instance of a "watcher object" which in
  402. * the C world is represented by a pair: a pointer to a function implementing this
  403. * signature and a pointer to watcher context -- handback user-specific data.
  404. * When a watch is triggered this function will be called along with
  405. * the watcher context. An application wishing to use this style must use
  406. * the getter API functions with the "w" prefix in their names (for example, \ref
  407. * zoo_awexists, \ref zoo_wget, etc).
  408. *
  409. * \param zh zookeeper handle
  410. * \param type event type. This is one of the *_EVENT constants.
  411. * \param state connection state. The state value will be one of the *_STATE constants.
  412. * \param path znode path for which the watcher is triggered. NULL if the event
  413. * type is ZOO_SESSION_EVENT
  414. * \param watcherCtx watcher context.
  415. */
  416. typedef void (*watcher_fn)(zhandle_t *zh, int type,
  417. int state, const char *path,void *watcherCtx);
  418. /**
  419. * \brief typedef for setting the log callback. It's a function pointer which
  420. * returns void and accepts a const char* as its only argument.
  421. *
  422. * \param message message to be passed to the callback function.
  423. */
  424. typedef void (*log_callback_fn)(const char *message);
  425. /**
  426. * \brief create a handle to used communicate with zookeeper.
  427. *
  428. * This method creates a new handle and a zookeeper session that corresponds
  429. * to that handle. Session establishment is asynchronous, meaning that the
  430. * session should not be considered established until (and unless) an
  431. * event of state ZOO_CONNECTED_STATE is received.
  432. * \param host comma separated host:port pairs, each corresponding to a zk
  433. * server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002"
  434. * \param fn the global watcher callback function. When notifications are
  435. * triggered this function will be invoked.
  436. * \param clientid the id of a previously established session that this
  437. * client will be reconnecting to. Pass 0 if not reconnecting to a previous
  438. * session. Clients can access the session id of an established, valid,
  439. * connection by calling \ref zoo_client_id. If the session corresponding to
  440. * the specified clientid has expired, or if the clientid is invalid for
  441. * any reason, the returned zhandle_t will be invalid -- the zhandle_t
  442. * state will indicate the reason for failure (typically
  443. * ZOO_EXPIRED_SESSION_STATE).
  444. * \param context the handback object that will be associated with this instance
  445. * of zhandle_t. Application can access it (for example, in the watcher
  446. * callback) using \ref zoo_get_context. The object is not used by zookeeper
  447. * internally and can be null.
  448. * \param flags reserved for future use. Should be set to zero.
  449. * \return a pointer to the opaque zhandle structure. If it fails to create
  450. * a new zhandle the function returns NULL and the errno variable
  451. * indicates the reason.
  452. */
  453. ZOOAPI zhandle_t *zookeeper_init(const char *host, watcher_fn fn,
  454. int recv_timeout, const clientid_t *clientid, void *context, int flags);
  455. /**
  456. * \brief create a handle to communicate with zookeeper.
  457. *
  458. * This function is identical to \ref zookeeper_init except it allows one
  459. * to specify an additional callback to be used for all logging for that
  460. * specific connection. For more details on the logging callback see
  461. * \ref zoo_get_log_callback and \ref zoo_set_log_callback.
  462. *
  463. * This method creates a new handle and a zookeeper session that corresponds
  464. * to that handle. Session establishment is asynchronous, meaning that the
  465. * session should not be considered established until (and unless) an
  466. * event of state ZOO_CONNECTED_STATE is received.
  467. * \param host comma separated host:port pairs, each corresponding to a zk
  468. * server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002"
  469. * \param fn the global watcher callback function. When notifications are
  470. * triggered this function will be invoked.
  471. * \param clientid the id of a previously established session that this
  472. * client will be reconnecting to. Pass 0 if not reconnecting to a previous
  473. * session. Clients can access the session id of an established, valid,
  474. * connection by calling \ref zoo_client_id. If the session corresponding to
  475. * the specified clientid has expired, or if the clientid is invalid for
  476. * any reason, the returned zhandle_t will be invalid -- the zhandle_t
  477. * state will indicate the reason for failure (typically
  478. * ZOO_EXPIRED_SESSION_STATE).
  479. * \param context the handback object that will be associated with this instance
  480. * of zhandle_t. Application can access it (for example, in the watcher
  481. * callback) using \ref zoo_get_context. The object is not used by zookeeper
  482. * internally and can be null.
  483. * \param flags reserved for future use. Should be set to zero.
  484. * \param log_callback All log messages will be passed to this callback function.
  485. * For more details see \ref zoo_get_log_callback and \ref zoo_set_log_callback.
  486. * \return a pointer to the opaque zhandle structure. If it fails to create
  487. * a new zhandle the function returns NULL and the errno variable
  488. * indicates the reason.
  489. */
  490. ZOOAPI zhandle_t *zookeeper_init2(const char *host, watcher_fn fn,
  491. int recv_timeout, const clientid_t *clientid, void *context, int flags,
  492. log_callback_fn log_callback);
  493. /**
  494. * \brief update the list of servers this client will connect to.
  495. *
  496. * This method allows a client to update the connection string by providing
  497. * a new comma separated list of host:port pairs, each corresponding to a
  498. * ZooKeeper server.
  499. *
  500. * This function invokes a probabilistic load-balancing algorithm which may cause
  501. * the client to disconnect from its current host to achieve expected uniform
  502. * connections per server in the new list. In case the current host to which the
  503. * client is connected is not in the new list this call will always cause the
  504. * connection to be dropped. Otherwise, the decision is based on whether the
  505. * number of servers has increased or decreased and by how much.
  506. *
  507. * If the connection is dropped, the client moves to a special "reconfig" mode
  508. * where he chooses a new server to connect to using the probabilistic algorithm.
  509. * After finding a server or exhaustively trying all the servers in the new list,
  510. * the client moves back to the normal mode of operation where it will pick an
  511. * arbitrary server from the 'host' string.
  512. *
  513. * See {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1355} for the
  514. * protocol and its evaluation,
  515. *
  516. * \param host comma separated host:port pairs, each corresponding to a zk
  517. * server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002"
  518. * \return ZOK on success or one of the following errcodes on failure:
  519. * ZBADARGUMENTS - invalid input parameters
  520. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  521. * ZSYSTEMERROR -- a system (OS) error occured; it's worth checking errno to get details
  522. */
  523. ZOOAPI int zoo_set_servers(zhandle_t *zh, const char *hosts);
  524. /**
  525. * \brief cycle to the next server on the next connection attempt.
  526. *
  527. * Note: typically this method should NOT be used outside of testing.
  528. *
  529. * This method allows a client to cycle through the list of servers in it's
  530. * connection pool to be used on the next connection attempt. This function does
  531. * not actually trigger a connection or state change in any way. Its purpose is
  532. * to allow testing changing servers on the fly and the probabilistic load
  533. * balancing algorithm.
  534. */
  535. ZOOAPI void zoo_cycle_next_server(zhandle_t *zh);
  536. /**
  537. * \brief get current host:port this client is connecting/connected to.
  538. *
  539. * Note: typically this method should NOT be used outside of testing.
  540. *
  541. * This method allows a client to get the current host:port that this client
  542. * is either in the process of connecting to or is currently connected to. This
  543. * is mainly used for testing purposes but might also come in handy as a general
  544. * purpose tool to be used by other clients.
  545. */
  546. ZOOAPI const char* zoo_get_current_server(zhandle_t* zh);
  547. /**
  548. * \brief close the zookeeper handle and free up any resources.
  549. *
  550. * After this call, the client session will no longer be valid. The function
  551. * will flush any outstanding send requests before return. As a result it may
  552. * block.
  553. *
  554. * This method should only be called only once on a zookeeper handle. Calling
  555. * twice will cause undefined (and probably undesirable behavior). Calling any other
  556. * zookeeper method after calling close is undefined behaviour and should be avoided.
  557. *
  558. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  559. * \return a result code. Regardless of the error code returned, the zhandle
  560. * will be destroyed and all resources freed.
  561. *
  562. * ZOK - success
  563. * ZBADARGUMENTS - invalid input parameters
  564. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  565. * ZOPERATIONTIMEOUT - failed to flush the buffers within the specified timeout.
  566. * ZCONNECTIONLOSS - a network error occurred while attempting to send request to server
  567. * ZSYSTEMERROR -- a system (OS) error occurred; it's worth checking errno to get details
  568. */
  569. ZOOAPI int zookeeper_close(zhandle_t *zh);
  570. /**
  571. * \brief return the client session id, only valid if the connections
  572. * is currently connected (ie. last watcher state is ZOO_CONNECTED_STATE)
  573. */
  574. ZOOAPI const clientid_t *zoo_client_id(zhandle_t *zh);
  575. /**
  576. * \brief return the timeout for this session, only valid if the connections
  577. * is currently connected (ie. last watcher state is ZOO_CONNECTED_STATE). This
  578. * value may change after a server re-connect.
  579. */
  580. ZOOAPI int zoo_recv_timeout(zhandle_t *zh);
  581. /**
  582. * \brief return the context for this handle.
  583. */
  584. ZOOAPI const void *zoo_get_context(zhandle_t *zh);
  585. /**
  586. * \brief set the context for this handle.
  587. */
  588. ZOOAPI void zoo_set_context(zhandle_t *zh, void *context);
  589. /**
  590. * \brief set a watcher function
  591. * \return previous watcher function
  592. */
  593. ZOOAPI watcher_fn zoo_set_watcher(zhandle_t *zh,watcher_fn newFn);
  594. /**
  595. * \brief returns the socket address for the current connection
  596. * \return socket address of the connected host or NULL on failure, only valid if the
  597. * connection is current connected
  598. */
  599. ZOOAPI struct sockaddr* zookeeper_get_connected_host(zhandle_t *zh,
  600. struct sockaddr *addr, socklen_t *addr_len);
  601. #ifndef THREADED
  602. /**
  603. * \brief Returns the events that zookeeper is interested in.
  604. *
  605. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  606. * \param fd is the file descriptor of interest
  607. * \param interest is an or of the ZOOKEEPER_WRITE and ZOOKEEPER_READ flags to
  608. * indicate the I/O of interest on fd.
  609. * \param tv a timeout value to be used with select/poll system call
  610. * \return a result code.
  611. * ZOK - success
  612. * ZBADARGUMENTS - invalid input parameters
  613. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  614. * ZCONNECTIONLOSS - a network error occurred while attempting to establish
  615. * a connection to the server
  616. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  617. * ZOPERATIONTIMEOUT - hasn't received anything from the server for 2/3 of the
  618. * timeout value specified in zookeeper_init()
  619. * ZSYSTEMERROR -- a system (OS) error occurred; it's worth checking errno to get details
  620. */
  621. #ifdef WIN32
  622. ZOOAPI int zookeeper_interest(zhandle_t *zh, SOCKET *fd, int *interest,
  623. struct timeval *tv);
  624. #else
  625. ZOOAPI int zookeeper_interest(zhandle_t *zh, int *fd, int *interest,
  626. struct timeval *tv);
  627. #endif
  628. /**
  629. * \brief Notifies zookeeper that an event of interest has happened.
  630. *
  631. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  632. * \param events will be an OR of the ZOOKEEPER_WRITE and ZOOKEEPER_READ flags.
  633. * \return a result code.
  634. * ZOK - success
  635. * ZBADARGUMENTS - invalid input parameters
  636. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  637. * ZCONNECTIONLOSS - a network error occurred while attempting to send request to server
  638. * ZSESSIONEXPIRED - connection attempt failed -- the session's expired
  639. * ZAUTHFAILED - authentication request failed, e.i. invalid credentials
  640. * ZRUNTIMEINCONSISTENCY - a server response came out of order
  641. * ZSYSTEMERROR -- a system (OS) error occurred; it's worth checking errno to get details
  642. * ZNOTHING -- not an error; simply indicates that there no more data from the server
  643. * to be processed (when called with ZOOKEEPER_READ flag).
  644. */
  645. ZOOAPI int zookeeper_process(zhandle_t *zh, int events);
  646. #endif
  647. /**
  648. * \brief signature of a completion function for a call that returns void.
  649. *
  650. * This method will be invoked at the end of a asynchronous call and also as
  651. * a result of connection loss or timeout.
  652. * \param rc the error code of the call. Connection loss/timeout triggers
  653. * the completion with one of the following error codes:
  654. * ZCONNECTIONLOSS -- lost connection to the server
  655. * ZOPERATIONTIMEOUT -- connection timed out
  656. * Data related events trigger the completion with error codes listed the
  657. * Exceptions section of the documentation of the function that initiated the
  658. * call. (Zero indicates call was successful.)
  659. * \param data the pointer that was passed by the caller when the function
  660. * that this completion corresponds to was invoked. The programmer
  661. * is responsible for any memory freeing associated with the data
  662. * pointer.
  663. */
  664. typedef void (*void_completion_t)(int rc, const void *data);
  665. /**
  666. * \brief signature of a completion function that returns a Stat structure.
  667. *
  668. * This method will be invoked at the end of a asynchronous call and also as
  669. * a result of connection loss or timeout.
  670. * \param rc the error code of the call. Connection loss/timeout triggers
  671. * the completion with one of the following error codes:
  672. * ZCONNECTIONLOSS -- lost connection to the server
  673. * ZOPERATIONTIMEOUT -- connection timed out
  674. * Data related events trigger the completion with error codes listed the
  675. * Exceptions section of the documentation of the function that initiated the
  676. * call. (Zero indicates call was successful.)
  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. typedef void (*stat_completion_t)(int rc, const struct Stat *stat,
  686. const void *data);
  687. /**
  688. * \brief signature of a completion function that returns data.
  689. *
  690. * This method will be invoked at the end of a asynchronous call and also as
  691. * a result of connection loss or timeout.
  692. * \param rc the error code of the call. Connection loss/timeout triggers
  693. * the completion with one of the following error codes:
  694. * ZCONNECTIONLOSS -- lost connection to the server
  695. * ZOPERATIONTIMEOUT -- connection timed out
  696. * Data related events trigger the completion with error codes listed the
  697. * Exceptions section of the documentation of the function that initiated the
  698. * call. (Zero indicates call was successful.)
  699. * \param value the value of the information returned by the asynchronous call.
  700. * If a non zero error code is returned, the content of value is undefined.
  701. * The programmer is NOT responsible for freeing value.
  702. * \param value_len the number of bytes in value.
  703. * \param stat a pointer to the stat information for the node involved in
  704. * this function. If a non zero error code is returned, the content of
  705. * stat is undefined. The programmer is NOT responsible for freeing stat.
  706. * \param data the pointer that was passed by the caller when the function
  707. * that this completion corresponds to was invoked. The programmer
  708. * is responsible for any memory freeing associated with the data
  709. * pointer.
  710. */
  711. typedef void (*data_completion_t)(int rc, const char *value, int value_len,
  712. const struct Stat *stat, const void *data);
  713. /**
  714. * \brief signature of a completion function that returns a list of strings.
  715. *
  716. * This method will be invoked at the end of a asynchronous call and also as
  717. * a result of connection loss or timeout.
  718. * \param rc the error code of the call. Connection loss/timeout triggers
  719. * the completion with one of the following error codes:
  720. * ZCONNECTIONLOSS -- lost connection to the server
  721. * ZOPERATIONTIMEOUT -- connection timed out
  722. * Data related events trigger the completion with error codes listed the
  723. * Exceptions section of the documentation of the function that initiated the
  724. * call. (Zero indicates call was successful.)
  725. * \param strings a pointer to the structure containng the list of strings of the
  726. * names of the children of a node. If a non zero error code is returned,
  727. * the content of strings is undefined. The programmer is NOT responsible
  728. * for freeing strings.
  729. * \param data the pointer that was passed by the caller when the function
  730. * that this completion corresponds to was invoked. The programmer
  731. * is responsible for any memory freeing associated with the data
  732. * pointer.
  733. */
  734. typedef void (*strings_completion_t)(int rc,
  735. const struct String_vector *strings, const void *data);
  736. /**
  737. * \brief signature of a completion function that returns a string and stat.
  738. * .
  739. *
  740. * This method will be invoked at the end of a asynchronous call and also as
  741. * a result of connection loss or timeout.
  742. * \param rc the error code of the call. Connection loss/timeout triggers
  743. * the completion with one of the following error codes:
  744. * ZCONNECTIONLOSS -- lost connection to the server
  745. * ZOPERATIONTIMEOUT -- connection timed out
  746. * Data related events trigger the completion with error codes listed the
  747. * Exceptions section of the documentation of the function that initiated the
  748. * call. (Zero indicates call was successful.)
  749. * \param value the value of the string returned.
  750. * \param stat a pointer to the stat information for the node involved in
  751. * this function. If a non zero error code is returned, the content of
  752. * stat is undefined. The programmer is NOT responsible for freeing stat.
  753. * \param data the pointer that was passed by the caller when the function
  754. * that this completion corresponds to was invoked. The programmer
  755. * is responsible for any memory freeing associated with the data
  756. * pointer.
  757. */
  758. typedef void (*string_stat_completion_t)(int rc,
  759. const char *string, const struct Stat *stat, const void *data);
  760. /**
  761. * \brief signature of a completion function that returns a list of strings and stat.
  762. * .
  763. *
  764. * This method will be invoked at the end of a asynchronous call and also as
  765. * a result of connection loss or timeout.
  766. * \param rc the error code of the call. Connection loss/timeout triggers
  767. * the completion with one of the following error codes:
  768. * ZCONNECTIONLOSS -- lost connection to the server
  769. * ZOPERATIONTIMEOUT -- connection timed out
  770. * Data related events trigger the completion with error codes listed the
  771. * Exceptions section of the documentation of the function that initiated the
  772. * call. (Zero indicates call was successful.)
  773. * \param strings a pointer to the structure containng the list of strings of the
  774. * names of the children of a node. If a non zero error code is returned,
  775. * the content of strings is undefined. The programmer is NOT responsible
  776. * for freeing strings.
  777. * \param stat a pointer to the stat information for the node involved in
  778. * this function. If a non zero error code is returned, the content of
  779. * stat is undefined. The programmer is NOT responsible for freeing stat.
  780. * \param data the pointer that was passed by the caller when the function
  781. * that this completion corresponds to was invoked. The programmer
  782. * is responsible for any memory freeing associated with the data
  783. * pointer.
  784. */
  785. typedef void (*strings_stat_completion_t)(int rc,
  786. const struct String_vector *strings, const struct Stat *stat,
  787. const void *data);
  788. /**
  789. * \brief signature of a completion function that returns a list of strings.
  790. *
  791. * This method will be invoked at the end of a asynchronous call and also as
  792. * a result of connection loss or timeout.
  793. * \param rc the error code of the call. Connection loss/timeout triggers
  794. * the completion with one of the following error codes:
  795. * ZCONNECTIONLOSS -- lost connection to the server
  796. * ZOPERATIONTIMEOUT -- connection timed out
  797. * Data related events trigger the completion with error codes listed the
  798. * Exceptions section of the documentation of the function that initiated the
  799. * call. (Zero indicates call was successful.)
  800. * \param value the value of the string returned.
  801. * \param data the pointer that was passed by the caller when the function
  802. * that this completion corresponds to was invoked. The programmer
  803. * is responsible for any memory freeing associated with the data
  804. * pointer.
  805. */
  806. typedef void
  807. (*string_completion_t)(int rc, const char *value, const void *data);
  808. /**
  809. * \brief signature of a completion function that returns an ACL.
  810. *
  811. * This method will be invoked at the end of a asynchronous call and also as
  812. * a result of connection loss or timeout.
  813. * \param rc the error code of the call. Connection loss/timeout triggers
  814. * the completion with one of the following error codes:
  815. * ZCONNECTIONLOSS -- lost connection to the server
  816. * ZOPERATIONTIMEOUT -- connection timed out
  817. * Data related events trigger the completion with error codes listed the
  818. * Exceptions section of the documentation of the function that initiated the
  819. * call. (Zero indicates call was successful.)
  820. * \param acl a pointer to the structure containng the ACL of a node. If a non
  821. * zero error code is returned, the content of strings is undefined. The
  822. * programmer is NOT responsible for freeing acl.
  823. * \param stat a pointer to the stat information for the node involved in
  824. * this function. If a non zero error code is returned, the content of
  825. * stat is undefined. The programmer is NOT responsible for freeing stat.
  826. * \param data the pointer that was passed by the caller when the function
  827. * that this completion corresponds to was invoked. The programmer
  828. * is responsible for any memory freeing associated with the data
  829. * pointer.
  830. */
  831. typedef void (*acl_completion_t)(int rc, struct ACL_vector *acl,
  832. struct Stat *stat, const void *data);
  833. /**
  834. * \brief get the state of the zookeeper connection.
  835. *
  836. * The return value will be one of the \ref State Consts.
  837. */
  838. ZOOAPI int zoo_state(zhandle_t *zh);
  839. /**
  840. * \brief create a node.
  841. *
  842. * This method will create a node in ZooKeeper. A node can only be created if
  843. * it does not already exist. The Create Mode affects the creation of nodes.
  844. * If ZOO_EPHEMERAL mode is chosen, the node will automatically get removed if the
  845. * client session goes away. If ZOO_CONTAINER flag is set, a container node will be
  846. * created. For ZOO_*_SEQUENTIAL modes, a unique monotonically increasing
  847. * sequence number is appended to the path name. The sequence number is always fixed
  848. * length of 10 digits, 0 padded.
  849. *
  850. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  851. * \param path The name of the node. Expressed as a file name with slashes
  852. * separating ancestors of the node.
  853. * \param value The data to be stored in the node.
  854. * \param valuelen The number of bytes in data.
  855. * \param acl The initial ACL of the node. The ACL must not be null or empty.
  856. * \param mode this parameter should be one of the Create Modes.
  857. * \param completion the routine to invoke when the request completes. The completion
  858. * will be triggered with one of the following codes passed in as the rc argument:
  859. * ZOK operation completed successfully
  860. * ZNONODE the parent node does not exist.
  861. * ZNODEEXISTS the node already exists
  862. * ZNOAUTH the client does not have permission.
  863. * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
  864. * \param data The data that will be passed to the completion routine when the
  865. * function completes.
  866. * \return ZOK on success or one of the following errcodes on failure:
  867. * ZBADARGUMENTS - invalid input parameters
  868. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  869. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  870. */
  871. ZOOAPI int zoo_acreate(zhandle_t *zh, const char *path, const char *value,
  872. int valuelen, const struct ACL_vector *acl, int mode,
  873. string_completion_t completion, const void *data);
  874. /**
  875. * \brief create a node.
  876. *
  877. * This method will create a node in ZooKeeper. A node can only be created if
  878. * it does not already exist. The Create Mode affects the creation of nodes.
  879. * If ZOO_EPHEMERAL mode is chosen, the node will automatically get removed if the
  880. * client session goes away. If ZOO_CONTAINER flag is set, a container node will be
  881. * created. For ZOO_*_SEQUENTIAL modes, a unique monotonically increasing
  882. * sequence number is appended to the path name. The sequence number is always fixed
  883. * length of 10 digits, 0 padded. When ZOO_*_WITH_TTL is selected, a ttl node will be
  884. * created.
  885. *
  886. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  887. * \param path The name of the node. Expressed as a file name with slashes
  888. * separating ancestors of the node.
  889. * \param value The data to be stored in the node.
  890. * \param valuelen The number of bytes in data.
  891. * \param acl The initial ACL of the node. The ACL must not be null or empty.
  892. * \param mode this parameter should be one of the Create Modes.
  893. * \param ttl the value of ttl in milliseconds. It must be positive for ZOO_*_WITH_TTL
  894. * Create modes, otherwise it must be -1.
  895. * \param completion the routine to invoke when the request completes. The completion
  896. * will be triggered with one of the following codes passed in as the rc argument:
  897. * ZOK operation completed successfully
  898. * ZNONODE the parent node does not exist.
  899. * ZNODEEXISTS the node already exists
  900. * ZNOAUTH the client does not have permission.
  901. * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
  902. * \param data The data that will be passed to the completion routine when the
  903. * function completes.
  904. * \return ZOK on success or one of the following errcodes on failure:
  905. * ZBADARGUMENTS - invalid input parameters
  906. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  907. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  908. */
  909. ZOOAPI int zoo_acreate_ttl(zhandle_t *zh, const char *path, const char *value,
  910. int valuelen, const struct ACL_vector *acl, int mode, int64_t ttl,
  911. string_completion_t completion, const void *data);
  912. /**
  913. * \brief create a node asynchronously and returns stat details.
  914. *
  915. * This method will create a node in ZooKeeper. A node can only be created if
  916. * it does not already exist. The Create Mode affects the creation of nodes.
  917. * If ZOO_EPHEMERAL mode is chosen, the node will automatically get removed if the
  918. * client session goes away. If ZOO_CONTAINER flag is set, a container node will be
  919. * created. For ZOO_*_SEQUENTIAL modes, a unique monotonically increasing
  920. * sequence number is appended to the path name. The sequence number is always fixed
  921. * length of 10 digits, 0 padded.
  922. *
  923. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  924. * \param path The name of the node. Expressed as a file name with slashes
  925. * separating ancestors of the node.
  926. * \param value The data to be stored in the node.
  927. * \param valuelen The number of bytes in data.
  928. * \param acl The initial ACL of the node. The ACL must not be null or empty.
  929. * \param mode this parameter should be one of the Create Modes.
  930. * \param completion the routine to invoke when the request completes. The completion
  931. * will be triggered with one of the following codes passed in as the rc argument:
  932. * ZOK operation completed successfully
  933. * ZNONODE the parent node does not exist.
  934. * ZNODEEXISTS the node already exists
  935. * ZNOAUTH the client does not have permission.
  936. * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
  937. * \param data The data that will be passed to the completion routine when the
  938. * function completes.
  939. * \return ZOK on success or one of the following errcodes on failure:
  940. * ZBADARGUMENTS - invalid input parameters
  941. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  942. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  943. */
  944. ZOOAPI int zoo_acreate2(zhandle_t *zh, const char *path, const char *value,
  945. int valuelen, const struct ACL_vector *acl, int mode,
  946. string_stat_completion_t completion, const void *data);
  947. /**
  948. * \brief create a node asynchronously and returns stat details.
  949. *
  950. * This method will create a node in ZooKeeper. A node can only be created if
  951. * it does not already exist. The Create Mode affects the creation of nodes.
  952. * If ZOO_EPHEMERAL mode is chosen, the node will automatically get removed if the
  953. * client session goes away. If ZOO_CONTAINER flag is set, a container node will be
  954. * created. For ZOO_*_SEQUENTIAL modes, a unique monotonically increasing
  955. * sequence number is appended to the path name. The sequence number is always fixed
  956. * length of 10 digits, 0 padded. When ZOO_*_WITH_TTL is selected, a ttl node will be
  957. * created.
  958. *
  959. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  960. * \param path The name of the node. Expressed as a file name with slashes
  961. * separating ancestors of the node.
  962. * \param value The data to be stored in the node.
  963. * \param valuelen The number of bytes in data.
  964. * \param acl The initial ACL of the node. The ACL must not be null or empty.
  965. * \param mode this parameter should be one of the Create Modes.
  966. * \param ttl the value of ttl in milliseconds. It must be positive for ZOO_*_WITH_TTL
  967. * Create modes, otherwise it must be -1.
  968. * \param completion the routine to invoke when the request completes. The completion
  969. * will be triggered with one of the following codes passed in as the rc argument:
  970. * ZOK operation completed successfully
  971. * ZNONODE the parent node does not exist.
  972. * ZNODEEXISTS the node already exists
  973. * ZNOAUTH the client does not have permission.
  974. * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
  975. * \param data The data that will be passed to the completion routine when the
  976. * function completes.
  977. * \return ZOK on success or one of the following errcodes on failure:
  978. * ZBADARGUMENTS - invalid input parameters
  979. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  980. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  981. */
  982. ZOOAPI int zoo_acreate2_ttl(zhandle_t *zh, const char *path, const char *value,
  983. int valuelen, const struct ACL_vector *acl, int mode, int64_t ttl,
  984. string_stat_completion_t completion, const void *data);
  985. /**
  986. * \brief delete a node in zookeeper.
  987. *
  988. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  989. * \param path the name of the node. Expressed as a file name with slashes
  990. * separating ancestors of the node.
  991. * \param version the expected version of the node. The function will fail if the
  992. * actual version of the node does not match the expected version.
  993. * If -1 is used the version check will not take place.
  994. * \param completion the routine to invoke when the request completes. The completion
  995. * will be triggered with one of the following codes passed in as the rc argument:
  996. * ZOK operation completed successfully
  997. * ZNONODE the node does not exist.
  998. * ZNOAUTH the client does not have permission.
  999. * ZBADVERSION expected version does not match actual version.
  1000. * ZNOTEMPTY children are present; node cannot be deleted.
  1001. * \param data the data that will be passed to the completion routine when
  1002. * the function completes.
  1003. * \return ZOK on success or one of the following errcodes on failure:
  1004. * ZBADARGUMENTS - invalid input parameters
  1005. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1006. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1007. */
  1008. ZOOAPI int zoo_adelete(zhandle_t *zh, const char *path, int version,
  1009. void_completion_t completion, const void *data);
  1010. /**
  1011. * \brief checks the existence of a node in zookeeper.
  1012. *
  1013. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1014. * \param path the name of the node. Expressed as a file name with slashes
  1015. * separating ancestors of the node.
  1016. * \param watch if nonzero, a watch will be set at the server to notify the
  1017. * client if the node changes. The watch will be set even if the node does not
  1018. * exist. This allows clients to watch for nodes to appear.
  1019. * \param completion the routine to invoke when the request completes. The completion
  1020. * will be triggered with one of the following codes passed in as the rc argument:
  1021. * ZOK operation completed successfully
  1022. * ZNONODE the node does not exist.
  1023. * ZNOAUTH the client does not have permission.
  1024. * \param data the data that will be passed to the completion routine when the
  1025. * function completes.
  1026. * \return ZOK on success or one of the following errcodes on failure:
  1027. * ZBADARGUMENTS - invalid input parameters
  1028. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1029. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1030. */
  1031. ZOOAPI int zoo_aexists(zhandle_t *zh, const char *path, int watch,
  1032. stat_completion_t completion, const void *data);
  1033. /**
  1034. * \brief checks the existence of a node in zookeeper.
  1035. *
  1036. * This function is similar to \ref zoo_axists except it allows one specify
  1037. * a watcher object - a function pointer and associated context. The function
  1038. * will be called once the watch has fired. The associated context data will be
  1039. * passed to the function as the watcher context parameter.
  1040. *
  1041. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1042. * \param path the name of the node. Expressed as a file name with slashes
  1043. * separating ancestors of the node.
  1044. * \param watcher if non-null a watch will set on the specified znode on the server.
  1045. * The watch will be set even if the node does not exist. This allows clients
  1046. * to watch for nodes to appear.
  1047. * \param watcherCtx user specific data, will be passed to the watcher callback.
  1048. * Unlike the global context set by \ref zookeeper_init, this watcher context
  1049. * is associated with the given instance of the watcher only.
  1050. * \param completion the routine to invoke when the request completes. The completion
  1051. * will be triggered with one of the following codes passed in as the rc argument:
  1052. * ZOK operation completed successfully
  1053. * ZNONODE the node does not exist.
  1054. * ZNOAUTH the client does not have permission.
  1055. * \param data the data that will be passed to the completion routine when the
  1056. * function completes.
  1057. * \return ZOK on success or one of the following errcodes on failure:
  1058. * ZBADARGUMENTS - invalid input parameters
  1059. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1060. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1061. */
  1062. ZOOAPI int zoo_awexists(zhandle_t *zh, const char *path,
  1063. watcher_fn watcher, void* watcherCtx,
  1064. stat_completion_t completion, const void *data);
  1065. /**
  1066. * \brief gets the data associated with a node.
  1067. *
  1068. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1069. * \param path the name of the node. Expressed as a file name with slashes
  1070. * separating ancestors of the node.
  1071. * \param watch if nonzero, a watch will be set at the server to notify
  1072. * the client if the node changes.
  1073. * \param completion the routine to invoke when the request completes. The completion
  1074. * will be triggered with one of the following codes passed in as the rc argument:
  1075. * ZOK operation completed successfully
  1076. * ZNONODE the node does not exist.
  1077. * ZNOAUTH the client does not have permission.
  1078. * \param data the data that will be passed to the completion routine when
  1079. * the function completes.
  1080. * \return ZOK on success or one of the following errcodes on failure:
  1081. * ZBADARGUMENTS - invalid input parameters
  1082. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1083. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1084. */
  1085. ZOOAPI int zoo_aget(zhandle_t *zh, const char *path, int watch,
  1086. data_completion_t completion, const void *data);
  1087. /**
  1088. * \brief gets the data associated with a node.
  1089. *
  1090. * This function is similar to \ref zoo_aget except it allows one specify
  1091. * a watcher object rather than a boolean watch flag.
  1092. *
  1093. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1094. * \param path the name of the node. Expressed as a file name with slashes
  1095. * separating ancestors of the node.
  1096. * \param watcher if non-null, a watch will be set at the server to notify
  1097. * the client if the node changes.
  1098. * \param watcherCtx user specific data, will be passed to the watcher callback.
  1099. * Unlike the global context set by \ref zookeeper_init, this watcher context
  1100. * is associated with the given instance of the watcher only.
  1101. * \param completion the routine to invoke when the request completes. The completion
  1102. * will be triggered with one of the following codes passed in as the rc argument:
  1103. * ZOK operation completed successfully
  1104. * ZNONODE the node does not exist.
  1105. * ZNOAUTH the client does not have permission.
  1106. * \param data the data that will be passed to the completion routine when
  1107. * the function completes.
  1108. * \return ZOK on success or one of the following errcodes on failure:
  1109. * ZBADARGUMENTS - invalid input parameters
  1110. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1111. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1112. */
  1113. ZOOAPI int zoo_awget(zhandle_t *zh, const char *path,
  1114. watcher_fn watcher, void* watcherCtx,
  1115. data_completion_t completion, const void *data);
  1116. /**
  1117. * \brief gets the last committed configuration of the ZooKeeper cluster as it is known to
  1118. * the server to which the client is connected.
  1119. *
  1120. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1121. * \param watch if nonzero, a watch will be set at the server to notify
  1122. * the client if the configuration changes.
  1123. * \param completion the routine to invoke when the request completes. The completion
  1124. * will be triggered with one of the following codes passed in as the rc argument:
  1125. * ZOK operation completed successfully
  1126. * ZNONODE the configuration node (/zookeeper/config) does not exist.
  1127. * ZNOAUTH the client does not have permission to access the configuration node.
  1128. * \param data the configuration data that will be passed to the completion routine when
  1129. * the function completes.
  1130. * \return ZOK on success or one of the following errcodes on failure:
  1131. * ZBADARGUMENTS - invalid input parameters
  1132. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1133. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1134. */
  1135. ZOOAPI int zoo_agetconfig(zhandle_t *zh, int watch,
  1136. data_completion_t completion, const void *data);
  1137. /**
  1138. * \brief gets the last committed configuration of the ZooKeeper cluster as it is known to
  1139. * the server to which the client is connected.
  1140. *
  1141. * This function is similar to \ref zoo_agetconfig except it allows one specify
  1142. * a watcher object rather than a boolean watch flag.
  1143. *
  1144. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1145. * \param watcher if non-null, a watch will be set at the server to notify
  1146. * the client if the node changes.
  1147. * \param watcherCtx user specific data, will be passed to the watcher callback.
  1148. * Unlike the global context set by \ref zookeeper_init, this watcher context
  1149. * is associated with the given instance of the watcher only.
  1150. * \param completion the routine to invoke when the request completes. The completion
  1151. * will be triggered with one of the following codes passed in as the rc argument:
  1152. * ZOK operation completed successfully
  1153. * ZNONODE the configuration node (/zookeeper/config) does not exist.
  1154. * ZNOAUTH the client does not have permission to access the configuration node.
  1155. * \param data the configuration data that will be passed to the completion routine when
  1156. * the function completes.
  1157. * \return ZOK on success or one of the following errcodes on failure:
  1158. * ZBADARGUMENTS - invalid input parameters
  1159. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1160. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1161. */
  1162. ZOOAPI int zoo_awgetconfig(zhandle_t *zh, watcher_fn watcher, void* watcherCtx,
  1163. data_completion_t completion, const void *data);
  1164. /**
  1165. * \brief asynchronous reconfiguration interface - allows changing ZK cluster
  1166. * ensemble membership and roles of ensemble peers.
  1167. *
  1168. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1169. * \param joining - comma separated list of servers to be added to the ensemble.
  1170. * Each has a configuration line for a server to be added (as would appear in a
  1171. * configuration file), only for maj. quorums. NULL for non-incremental reconfiguration.
  1172. * \param leaving - comma separated list of server IDs to be removed from the ensemble.
  1173. * Each has an id of a server to be removed, only for maj. quorums. NULL for
  1174. * non-incremental reconfiguration.
  1175. * \param members - comma separated list of new membership (e.g., contents of a
  1176. * membership configuration file) - for use only with a non-incremental
  1177. * reconfiguration. NULL for incremental reconfiguration.
  1178. * \param version - version of config from which we want to reconfigure - if
  1179. * current config is different reconfiguration will fail. Should be -1 to disable
  1180. * this option.
  1181. * \param completion - the routine to invoke when the request completes. The
  1182. * completion will be triggered with one of the following codes passed in as the
  1183. * rc argument:
  1184. * ZOK operation completed successfully
  1185. * \param data the configuration data that will be passed to the completion routine
  1186. * when the function completes.
  1187. * \return return value of the function call.
  1188. * ZOK operation completed successfully
  1189. * ZBADARGUMENTS - invalid input parameters (one case when this is returned is
  1190. * when the new config has less than 2 servers)
  1191. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1192. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1193. * ZNEWCONFIGNOQUORUM - no quorum of new config is connected and up-to-date with
  1194. * the leader of last committed config - try invoking reconfiguration after new servers are connected and synced
  1195. * ZRECONFIGINPROGRESS - another reconfig is currently in progress
  1196. */
  1197. ZOOAPI int zoo_areconfig(zhandle_t *zh, const char *joining, const char *leaving,
  1198. const char *members, int64_t version, data_completion_t dc, const void *data);
  1199. /**
  1200. * \brief sets the data associated with a node.
  1201. *
  1202. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1203. * \param path the name of the node. Expressed as a file name with slashes
  1204. * separating ancestors of the node.
  1205. * \param buffer the buffer holding data to be written to the node.
  1206. * \param buflen the number of bytes from buffer to write.
  1207. * \param version the expected version of the node. The function will fail if
  1208. * the actual version of the node does not match the expected version. If -1 is
  1209. * used the version check will not take place. * completion: If null,
  1210. * the function will execute synchronously. Otherwise, the function will return
  1211. * immediately and invoke the completion routine when the request completes.
  1212. * \param completion the routine to invoke when the request completes. The completion
  1213. * will be triggered with one of the following codes passed in as the rc argument:
  1214. * ZOK operation completed successfully
  1215. * ZNONODE the node does not exist.
  1216. * ZNOAUTH the client does not have permission.
  1217. * ZBADVERSION expected version does not match actual version.
  1218. * \param data the data that will be passed to the completion routine when
  1219. * the function completes.
  1220. * \return ZOK on success or one of the following errcodes on failure:
  1221. * ZBADARGUMENTS - invalid input parameters
  1222. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1223. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1224. */
  1225. ZOOAPI int zoo_aset(zhandle_t *zh, const char *path, const char *buffer, int buflen,
  1226. int version, stat_completion_t completion, const void *data);
  1227. /**
  1228. * \brief lists the children of a node.
  1229. *
  1230. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1231. * \param path the name of the node. Expressed as a file name with slashes
  1232. * separating ancestors of the node.
  1233. * \param watch if nonzero, a watch will be set at the server to notify
  1234. * the client if the node changes.
  1235. * \param completion the routine to invoke when the request completes. The completion
  1236. * will be triggered with one of the following codes passed in as the rc argument:
  1237. * ZOK operation completed successfully
  1238. * ZNONODE the node does not exist.
  1239. * ZNOAUTH the client does not have permission.
  1240. * \param data the data that will be passed to the completion routine when
  1241. * the function completes.
  1242. * \return ZOK on success or one of the following errcodes on failure:
  1243. * ZBADARGUMENTS - invalid input parameters
  1244. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1245. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1246. */
  1247. ZOOAPI int zoo_aget_children(zhandle_t *zh, const char *path, int watch,
  1248. strings_completion_t completion, const void *data);
  1249. /**
  1250. * \brief lists the children of a node.
  1251. *
  1252. * This function is similar to \ref zoo_aget_children except it allows one specify
  1253. * a watcher object rather than a boolean watch flag.
  1254. *
  1255. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1256. * \param path the name of the node. Expressed as a file name with slashes
  1257. * separating ancestors of the node.
  1258. * \param watcher if non-null, a watch will be set at the server to notify
  1259. * the client if the node changes.
  1260. * \param watcherCtx user specific data, will be passed to the watcher callback.
  1261. * Unlike the global context set by \ref zookeeper_init, this watcher context
  1262. * is associated with the given instance of the watcher only.
  1263. * \param completion the routine to invoke when the request completes. The completion
  1264. * will be triggered with one of the following codes passed in as the rc argument:
  1265. * ZOK operation completed successfully
  1266. * ZNONODE the node does not exist.
  1267. * ZNOAUTH the client does not have permission.
  1268. * \param data the data that will be passed to the completion routine when
  1269. * the function completes.
  1270. * \return ZOK on success or one of the following errcodes on failure:
  1271. * ZBADARGUMENTS - invalid input parameters
  1272. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1273. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1274. */
  1275. ZOOAPI int zoo_awget_children(zhandle_t *zh, const char *path,
  1276. watcher_fn watcher, void* watcherCtx,
  1277. strings_completion_t completion, const void *data);
  1278. /**
  1279. * \brief lists the children of a node, and get the parent stat.
  1280. *
  1281. * This function is new in version 3.3.0
  1282. *
  1283. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1284. * \param path the name of the node. Expressed as a file name with slashes
  1285. * separating ancestors of the node.
  1286. * \param watch if nonzero, a watch will be set at the server to notify
  1287. * the client if the node changes.
  1288. * \param completion the routine to invoke when the request completes. The completion
  1289. * will be triggered with one of the following codes passed in as the rc argument:
  1290. * ZOK operation completed successfully
  1291. * ZNONODE the node does not exist.
  1292. * ZNOAUTH the client does not have permission.
  1293. * \param data the data that will be passed to the completion routine when
  1294. * the function completes.
  1295. * \return ZOK on success or one of the following errcodes on failure:
  1296. * ZBADARGUMENTS - invalid input parameters
  1297. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1298. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1299. */
  1300. ZOOAPI int zoo_aget_children2(zhandle_t *zh, const char *path, int watch,
  1301. strings_stat_completion_t completion, const void *data);
  1302. /**
  1303. * \brief lists the children of a node, and get the parent stat.
  1304. *
  1305. * This function is similar to \ref zoo_aget_children2 except it allows one specify
  1306. * a watcher object rather than a boolean watch flag.
  1307. *
  1308. * This function is new in version 3.3.0
  1309. *
  1310. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1311. * \param path the name of the node. Expressed as a file name with slashes
  1312. * separating ancestors of the node.
  1313. * \param watcher if non-null, a watch will be set at the server to notify
  1314. * the client if the node changes.
  1315. * \param watcherCtx user specific data, will be passed to the watcher callback.
  1316. * Unlike the global context set by \ref zookeeper_init, this watcher context
  1317. * is associated with the given instance of the watcher only.
  1318. * \param completion the routine to invoke when the request completes. The completion
  1319. * will be triggered with one of the following codes passed in as the rc argument:
  1320. * ZOK operation completed successfully
  1321. * ZNONODE the node does not exist.
  1322. * ZNOAUTH the client does not have permission.
  1323. * \param data the data that will be passed to the completion routine when
  1324. * the function completes.
  1325. * \return ZOK on success or one of the following errcodes on failure:
  1326. * ZBADARGUMENTS - invalid input parameters
  1327. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1328. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1329. */
  1330. ZOOAPI int zoo_awget_children2(zhandle_t *zh, const char *path,
  1331. watcher_fn watcher, void* watcherCtx,
  1332. strings_stat_completion_t completion, const void *data);
  1333. /**
  1334. * \brief Flush leader channel.
  1335. *
  1336. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1337. * \param path the name of the node. Expressed as a file name with slashes
  1338. * separating ancestors of the node.
  1339. * \param completion the routine to invoke when the request completes. The completion
  1340. * will be triggered with one of the following codes passed in as the rc argument:
  1341. * ZOK operation completed successfully
  1342. * ZNONODE the node does not exist.
  1343. * ZNOAUTH the client does not have permission.
  1344. * \param data the data that will be passed to the completion routine when
  1345. * the function completes.
  1346. * \return ZOK on success or one of the following errcodes on failure:
  1347. * ZBADARGUMENTS - invalid input parameters
  1348. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1349. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1350. */
  1351. ZOOAPI int zoo_async(zhandle_t *zh, const char *path,
  1352. string_completion_t completion, const void *data);
  1353. /**
  1354. * \brief gets the acl associated with a node.
  1355. *
  1356. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1357. * \param path the name of the node. Expressed as a file name with slashes
  1358. * separating ancestors of the node.
  1359. * \param completion the routine to invoke when the request completes. The completion
  1360. * will be triggered with one of the following codes passed in as the rc argument:
  1361. * ZOK operation completed successfully
  1362. * ZNONODE the node does not exist.
  1363. * ZNOAUTH the client does not have permission.
  1364. * \param data the data that will be passed to the completion routine when
  1365. * the function completes.
  1366. * \return ZOK on success or one of the following errcodes on failure:
  1367. * ZBADARGUMENTS - invalid input parameters
  1368. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1369. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1370. */
  1371. ZOOAPI int zoo_aget_acl(zhandle_t *zh, const char *path, acl_completion_t completion,
  1372. const void *data);
  1373. /**
  1374. * \brief sets the acl associated with a node.
  1375. *
  1376. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1377. * \param path the name of the node. Expressed as a file name with slashes
  1378. * separating ancestors of the node.
  1379. * \param buffer the buffer holding the acls to be written to the node.
  1380. * \param buflen the number of bytes from buffer to write.
  1381. * \param completion the routine to invoke when the request completes. The completion
  1382. * will be triggered with one of the following codes passed in as the rc argument:
  1383. * ZOK operation completed successfully
  1384. * ZNONODE the node does not exist.
  1385. * ZNOAUTH the client does not have permission.
  1386. * ZINVALIDACL invalid ACL specified
  1387. * ZBADVERSION expected version does not match actual version.
  1388. * \param data the data that will be passed to the completion routine when
  1389. * the function completes.
  1390. * \return ZOK on success or one of the following errcodes on failure:
  1391. * ZBADARGUMENTS - invalid input parameters
  1392. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1393. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1394. */
  1395. ZOOAPI int zoo_aset_acl(zhandle_t *zh, const char *path, int version,
  1396. struct ACL_vector *acl, void_completion_t, const void *data);
  1397. /**
  1398. * \brief atomically commits multiple zookeeper operations.
  1399. *
  1400. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1401. * \param count the number of operations
  1402. * \param ops an array of operations to commit
  1403. * \param results an array to hold the results of the operations
  1404. * \param completion the routine to invoke when the request completes. The completion
  1405. * will be triggered with any of the error codes that can that can be returned by the
  1406. * ops supported by a multi op (see \ref zoo_acreate, \ref zoo_adelete, \ref zoo_aset).
  1407. * \param data the data that will be passed to the completion routine when
  1408. * the function completes.
  1409. * \return the return code for the function call. This can be any of the
  1410. * values that can be returned by the ops supported by a multi op (see
  1411. * \ref zoo_acreate, \ref zoo_adelete, \ref zoo_aset).
  1412. */
  1413. ZOOAPI int zoo_amulti(zhandle_t *zh, int count, const zoo_op_t *ops,
  1414. zoo_op_result_t *results, void_completion_t, const void *data);
  1415. /**
  1416. * \brief return an error string.
  1417. *
  1418. * \param return code
  1419. * \return string corresponding to the return code
  1420. */
  1421. ZOOAPI const char* zerror(int c);
  1422. /**
  1423. * \brief specify application credentials.
  1424. *
  1425. * The application calls this function to specify its credentials for purposes
  1426. * of authentication. The server will use the security provider specified by
  1427. * the scheme parameter to authenticate the client connection. If the
  1428. * authentication request has failed:
  1429. * - the server connection is dropped
  1430. * - the watcher is called with the ZOO_AUTH_FAILED_STATE value as the state
  1431. * parameter.
  1432. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1433. * \param scheme the id of authentication scheme. Natively supported:
  1434. * "digest" password-based authentication
  1435. * \param cert application credentials. The actual value depends on the scheme.
  1436. * \param certLen the length of the data parameter
  1437. * \param completion the routine to invoke when the request completes. One of
  1438. * the following result codes may be passed into the completion callback:
  1439. * ZOK operation completed successfully
  1440. * ZAUTHFAILED authentication failed
  1441. * \param data the data that will be passed to the completion routine when the
  1442. * function completes.
  1443. * \return ZOK on success or one of the following errcodes on failure:
  1444. * ZBADARGUMENTS - invalid input parameters
  1445. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1446. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1447. * ZSYSTEMERROR - a system error occurred
  1448. */
  1449. ZOOAPI int zoo_add_auth(zhandle_t *zh,const char* scheme,const char* cert,
  1450. int certLen, void_completion_t completion, const void *data);
  1451. /**
  1452. * \brief checks if the current zookeeper connection state can't be recovered.
  1453. *
  1454. * The application must close the zhandle and try to reconnect.
  1455. *
  1456. * \param zh the zookeeper handle (see \ref zookeeper_init)
  1457. * \return ZINVALIDSTATE if connection is unrecoverable
  1458. */
  1459. ZOOAPI int is_unrecoverable(zhandle_t *zh);
  1460. /**
  1461. * \brief sets the debugging level for the library
  1462. */
  1463. ZOOAPI void zoo_set_debug_level(ZooLogLevel logLevel);
  1464. /**
  1465. * \brief sets the stream to be used by the library for logging
  1466. *
  1467. * The zookeeper library uses stderr as its default log stream. Application
  1468. * must make sure the stream is writable. Passing in NULL resets the stream
  1469. * to its default value (stderr).
  1470. */
  1471. ZOOAPI void zoo_set_log_stream(FILE* logStream);
  1472. /**
  1473. * \brief gets the callback to be used by this connection for logging.
  1474. *
  1475. * This is a per-connection logging mechanism that will take priority over
  1476. * the library-wide default log stream. That is, zookeeper library will first
  1477. * try to use a per-connection callback if available and if not, will fallback
  1478. * to using the logging stream. Passing in NULL resets the callback and will
  1479. * cause it to then fallback to using the logging stream as described in \ref
  1480. * zoo_set_log_stream.
  1481. */
  1482. ZOOAPI log_callback_fn zoo_get_log_callback(const zhandle_t *zh);
  1483. /**
  1484. * \brief sets the callback to be used by the library for logging
  1485. *
  1486. * Setting this callback has the effect of overriding the default log stream.
  1487. * Zookeeper will first try to use a per-connection callback if available
  1488. * and if not, will fallback to using the logging stream. Passing in NULL
  1489. * resets the callback and will cause it to then fallback to using the logging
  1490. * stream as described in \ref zoo_set_log_stream.
  1491. *
  1492. * Note: The provided callback will be invoked by multiple threads and therefore
  1493. * it needs to be thread-safe.
  1494. */
  1495. ZOOAPI void zoo_set_log_callback(zhandle_t *zh, log_callback_fn callback);
  1496. /**
  1497. * \brief enable/disable quorum endpoint order randomization
  1498. *
  1499. * Note: typically this method should NOT be used outside of testing.
  1500. *
  1501. * If passed a non-zero value, will make the client connect to quorum peers
  1502. * in the order as specified in the zookeeper_init() call.
  1503. * A zero value causes zookeeper_init() to permute the peer endpoints
  1504. * which is good for more even client connection distribution among the
  1505. * quorum peers.
  1506. */
  1507. ZOOAPI void zoo_deterministic_conn_order(int yesOrNo);
  1508. /**
  1509. * Type of watches: used to select which type of watches should be removed
  1510. */
  1511. typedef enum {
  1512. ZWATCHTYPE_CHILD = 1,
  1513. ZWATCHTYPE_DATA = 2,
  1514. ZWATCHTYPE_ANY = 3
  1515. } ZooWatcherType;
  1516. /**
  1517. * \brief removes the watches for the given path and watcher type.
  1518. *
  1519. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1520. * \param path the path for which watches will be removed
  1521. * \param wtype the watcher type to be removed
  1522. * \param watcher the watcher to be removed, if null all watches for that
  1523. * path (and watcher type) will be removed
  1524. * \param watcherCtx the contex associated with the watcher to be removed
  1525. * \param local whether the watches will be removed locally even if there is
  1526. * no server connection
  1527. * \return the return code for the function call.
  1528. * ZOK - operation completed successfully
  1529. * ZNOWATCHER - the watcher couldn't be found.
  1530. * ZINVALIDSTATE - if !local, zhandle state is either ZOO_SESSION_EXPIRED_STATE
  1531. * or ZOO_AUTH_FAILED_STATE
  1532. * ZBADARGUMENTS - invalid input parameters
  1533. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1534. * ZSYSTEMERROR - a system error occured
  1535. */
  1536. ZOOAPI int zoo_aremove_watches(zhandle_t *zh, const char *path,
  1537. ZooWatcherType wtype, watcher_fn watcher, void *watcherCtx, int local,
  1538. void_completion_t *completion, const void *data);
  1539. /**
  1540. * \brief removes all the watches for the given path and watcher type.
  1541. *
  1542. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1543. * \param path the path for which watches will be removed
  1544. * \param wtype the watcher type to be removed
  1545. * \param local whether the watches will be removed locally even if there is
  1546. * no server connection
  1547. * \return the return code for the function call.
  1548. * ZOK - operation completed successfully
  1549. * ZNOWATCHER - the watcher couldn't be found.
  1550. * ZINVALIDSTATE - if !local, zhandle state is either ZOO_SESSION_EXPIRED_STATE
  1551. * or ZOO_AUTH_FAILED_STATE
  1552. * ZBADARGUMENTS - invalid input parameters
  1553. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1554. * ZSYSTEMERROR - a system error occured
  1555. */
  1556. ZOOAPI int zoo_remove_all_watches(zhandle_t *zh, const char *path,
  1557. ZooWatcherType wtype, int local);
  1558. /**
  1559. * \brief removes all the watches for the given path and watcher type.
  1560. *
  1561. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1562. * \param path the path for which watches will be removed
  1563. * \param wtype the watcher type to be removed
  1564. * \param local whether the watches will be removed locally even if there is
  1565. * no server connection
  1566. * \return the return code for the function call.
  1567. * ZOK - operation completed successfully
  1568. * ZNOWATCHER - the watcher couldn't be found.
  1569. * ZINVALIDSTATE - if !local, zhandle state is either ZOO_SESSION_EXPIRED_STATE
  1570. * or ZOO_AUTH_FAILED_STATE
  1571. * ZBADARGUMENTS - invalid input parameters
  1572. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1573. * ZSYSTEMERROR - a system error occured
  1574. */
  1575. ZOOAPI int zoo_aremove_all_watches(zhandle_t *zh, const char *path,
  1576. ZooWatcherType wtype, int local, void_completion_t *completion,
  1577. const void *data);
  1578. #ifdef THREADED
  1579. /**
  1580. * \brief create a node synchronously.
  1581. *
  1582. * This method will create a node in ZooKeeper. A node can only be created if
  1583. * it does not already exist. The Create Mode affects the creation of nodes.
  1584. * If ZOO_EPHEMERAL mode is chosen, the node will automatically get removed if the
  1585. * client session goes away. If ZOO_CONTAINER flag is set, a container node will be
  1586. * created. For ZOO_*_SEQUENTIAL modes, a unique monotonically increasing
  1587. * sequence number is appended to the path name. The sequence number is always fixed
  1588. * length of 10 digits, 0 padded.
  1589. *
  1590. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1591. * \param path The name of the node. Expressed as a file name with slashes
  1592. * separating ancestors of the node.
  1593. * \param value The data to be stored in the node.
  1594. * \param valuelen The number of bytes in data. To set the data to be NULL use
  1595. * value as NULL and valuelen as -1.
  1596. * \param acl The initial ACL of the node. The ACL must not be null or empty.
  1597. * \param mode this parameter should be one of the Create Modes.
  1598. * \param path_buffer Buffer which will be filled with the path of the
  1599. * new node (this might be different than the supplied path
  1600. * because of the ZOO_SEQUENCE flag). The path string will always be
  1601. * null-terminated. This parameter may be NULL if path_buffer_len = 0.
  1602. * \param path_buffer_len Size of path buffer; if the path of the new
  1603. * node (including space for the null terminator) exceeds the buffer size,
  1604. * the path string will be truncated to fit. The actual path of the
  1605. * new node in the server will not be affected by the truncation.
  1606. * The path string will always be null-terminated.
  1607. * \return one of the following codes are returned:
  1608. * ZOK operation completed successfully
  1609. * ZNONODE the parent node does not exist.
  1610. * ZNODEEXISTS the node already exists
  1611. * ZNOAUTH the client does not have permission.
  1612. * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
  1613. * ZBADARGUMENTS - invalid input parameters
  1614. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1615. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1616. */
  1617. ZOOAPI int zoo_create(zhandle_t *zh, const char *path, const char *value,
  1618. int valuelen, const struct ACL_vector *acl, int mode,
  1619. char *path_buffer, int path_buffer_len);
  1620. /**
  1621. * \brief create a node synchronously.
  1622. *
  1623. * This method will create a node in ZooKeeper. A node can only be created if
  1624. * it does not already exist. The Create Mode affects the creation of nodes.
  1625. * If ZOO_EPHEMERAL mode is chosen, the node will automatically get removed if the
  1626. * client session goes away. If ZOO_CONTAINER flag is set, a container node will be
  1627. * created. For ZOO_*_SEQUENTIAL modes, a unique monotonically increasing
  1628. * sequence number is appended to the path name. The sequence number is always fixed
  1629. * length of 10 digits, 0 padded. When ZOO_*_WITH_TTL is selected, a ttl node will be
  1630. * created.
  1631. *
  1632. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1633. * \param path The name of the node. Expressed as a file name with slashes
  1634. * separating ancestors of the node.
  1635. * \param value The data to be stored in the node.
  1636. * \param valuelen The number of bytes in data. To set the data to be NULL use
  1637. * value as NULL and valuelen as -1.
  1638. * \param acl The initial ACL of the node. The ACL must not be null or empty.
  1639. * \param mode this parameter should be one of the Create Modes.
  1640. * \param ttl the value of ttl in milliseconds. It must be positive for ZOO_*_WITH_TTL
  1641. * Create modes, otherwise it must be -1.
  1642. * \param path_buffer Buffer which will be filled with the path of the
  1643. * new node (this might be different than the supplied path
  1644. * because of the ZOO_SEQUENCE flag). The path string will always be
  1645. * null-terminated. This parameter may be NULL if path_buffer_len = 0.
  1646. * \param path_buffer_len Size of path buffer; if the path of the new
  1647. * node (including space for the null terminator) exceeds the buffer size,
  1648. * the path string will be truncated to fit. The actual path of the
  1649. * new node in the server will not be affected by the truncation.
  1650. * The path string will always be null-terminated.
  1651. * \return one of the following codes are returned:
  1652. * ZOK operation completed successfully
  1653. * ZNONODE the parent node does not exist.
  1654. * ZNODEEXISTS the node already exists
  1655. * ZNOAUTH the client does not have permission.
  1656. * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
  1657. * ZBADARGUMENTS - invalid input parameters
  1658. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1659. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1660. */
  1661. ZOOAPI int zoo_create_ttl(zhandle_t *zh, const char *path, const char *value,
  1662. int valuelen, const struct ACL_vector *acl, int mode, int64_t ttl,
  1663. char *path_buffer, int path_buffer_len);
  1664. /**
  1665. * \brief create a node synchronously and collect stat details.
  1666. *
  1667. * This method will create a node in ZooKeeper. A node can only be created if
  1668. * it does not already exist. The Create Mode affects the creation of nodes.
  1669. * If ZOO_EPHEMERAL mode is chosen, the node will automatically get removed if the
  1670. * client session goes away. If ZOO_CONTAINER flag is set, a container node will be
  1671. * created. For ZOO_*_SEQUENTIAL modes, a unique monotonically increasing
  1672. * sequence number is appended to the path name. The sequence number is always fixed
  1673. * length of 10 digits, 0 padded.
  1674. *
  1675. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1676. * \param path The name of the node. Expressed as a file name with slashes
  1677. * separating ancestors of the node.
  1678. * \param value The data to be stored in the node.
  1679. * \param valuelen The number of bytes in data. To set the data to be NULL use
  1680. * value as NULL and valuelen as -1.
  1681. * \param acl The initial ACL of the node. The ACL must not be null or empty.
  1682. * \param mode this parameter should be one of the Create Modes.
  1683. * \param path_buffer Buffer which will be filled with the path of the
  1684. * new node (this might be different than the supplied path
  1685. * because of the ZOO_SEQUENCE flag). The path string will always be
  1686. * null-terminated. This parameter may be NULL if path_buffer_len = 0.
  1687. * \param path_buffer_len Size of path buffer; if the path of the new
  1688. * node (including space for the null terminator) exceeds the buffer size,
  1689. * the path string will be truncated to fit. The actual path of the
  1690. * new node in the server will not be affected by the truncation.
  1691. * The path string will always be null-terminated.
  1692. * \param stat The Stat struct to store Stat info into.
  1693. * \return one of the following codes are returned:
  1694. * ZOK operation completed successfully
  1695. * ZNONODE the parent node does not exist.
  1696. * ZNODEEXISTS the node already exists
  1697. * ZNOAUTH the client does not have permission.
  1698. * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
  1699. * ZBADARGUMENTS - invalid input parameters
  1700. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1701. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1702. */
  1703. ZOOAPI int zoo_create2(zhandle_t *zh, const char *path, const char *value,
  1704. int valuelen, const struct ACL_vector *acl, int mode,
  1705. char *path_buffer, int path_buffer_len, struct Stat *stat);
  1706. /**
  1707. * \brief create a node synchronously and collect stat details.
  1708. *
  1709. * This method will create a node in ZooKeeper. A node can only be created if
  1710. * it does not already exist. The Create Mode affects the creation of nodes.
  1711. * If ZOO_EPHEMERAL mode is chosen, the node will automatically get removed if the
  1712. * client session goes away. If ZOO_CONTAINER flag is set, a container node will be
  1713. * created. For ZOO_*_SEQUENTIAL modes, a unique monotonically increasing
  1714. * sequence number is appended to the path name. The sequence number is always fixed
  1715. * length of 10 digits, 0 padded. When ZOO_*_WITH_TTL is selected, a ttl node will be
  1716. * created.
  1717. *
  1718. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1719. * \param path The name of the node. Expressed as a file name with slashes
  1720. * separating ancestors of the node.
  1721. * \param value The data to be stored in the node.
  1722. * \param valuelen The number of bytes in data. To set the data to be NULL use
  1723. * value as NULL and valuelen as -1.
  1724. * \param acl The initial ACL of the node. The ACL must not be null or empty.
  1725. * \param mode this parameter should be one of the Create Modes.
  1726. * \param ttl the value of ttl in milliseconds. It must be positive for ZOO_*_WITH_TTL
  1727. * Create modes, otherwise it must be -1.
  1728. * \param path_buffer Buffer which will be filled with the path of the
  1729. * new node (this might be different than the supplied path
  1730. * because of the ZOO_SEQUENCE flag). The path string will always be
  1731. * null-terminated. This parameter may be NULL if path_buffer_len = 0.
  1732. * \param path_buffer_len Size of path buffer; if the path of the new
  1733. * node (including space for the null terminator) exceeds the buffer size,
  1734. * the path string will be truncated to fit. The actual path of the
  1735. * new node in the server will not be affected by the truncation.
  1736. * The path string will always be null-terminated.
  1737. * \param stat The Stat struct to store Stat info into.
  1738. * \return one of the following codes are returned:
  1739. * ZOK operation completed successfully
  1740. * ZNONODE the parent node does not exist.
  1741. * ZNODEEXISTS the node already exists
  1742. * ZNOAUTH the client does not have permission.
  1743. * ZNOCHILDRENFOREPHEMERALS cannot create children of ephemeral nodes.
  1744. * ZBADARGUMENTS - invalid input parameters
  1745. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1746. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1747. */
  1748. ZOOAPI int zoo_create2_ttl(zhandle_t *zh, const char *path, const char *value,
  1749. int valuelen, const struct ACL_vector *acl, int mode, int64_t ttl,
  1750. char *path_buffer, int path_buffer_len, struct Stat *stat);
  1751. /**
  1752. * \brief delete a node in zookeeper synchronously.
  1753. *
  1754. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1755. * \param path the name of the node. Expressed as a file name with slashes
  1756. * separating ancestors of the node.
  1757. * \param version the expected version of the node. The function will fail if the
  1758. * actual version of the node does not match the expected version.
  1759. * If -1 is used the version check will not take place.
  1760. * \return one of the following values is returned.
  1761. * ZOK operation completed successfully
  1762. * ZNONODE the node does not exist.
  1763. * ZNOAUTH the client does not have permission.
  1764. * ZBADVERSION expected version does not match actual version.
  1765. * ZNOTEMPTY children are present; node cannot be deleted.
  1766. * ZBADARGUMENTS - invalid input parameters
  1767. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1768. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1769. */
  1770. ZOOAPI int zoo_delete(zhandle_t *zh, const char *path, int version);
  1771. /**
  1772. * \brief checks the existence of a node in zookeeper synchronously.
  1773. *
  1774. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1775. * \param path the name of the node. Expressed as a file name with slashes
  1776. * separating ancestors of the node.
  1777. * \param watch if nonzero, a watch will be set at the server to notify the
  1778. * client if the node changes. The watch will be set even if the node does not
  1779. * exist. This allows clients to watch for nodes to appear.
  1780. * \param the return stat value of the node.
  1781. * \return return code of the function call.
  1782. * ZOK operation completed successfully
  1783. * ZNONODE the node does not exist.
  1784. * ZNOAUTH the client does not have permission.
  1785. * ZBADARGUMENTS - invalid input parameters
  1786. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1787. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1788. */
  1789. ZOOAPI int zoo_exists(zhandle_t *zh, const char *path, int watch, struct Stat *stat);
  1790. /**
  1791. * \brief checks the existence of a node in zookeeper synchronously.
  1792. *
  1793. * This function is similar to \ref zoo_exists except it allows one specify
  1794. * a watcher object rather than a boolean watch flag.
  1795. *
  1796. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1797. * \param path the name of the node. Expressed as a file name with slashes
  1798. * separating ancestors of the node.
  1799. * \param watcher if non-null a watch will set on the specified znode on the server.
  1800. * The watch will be set even if the node does not exist. This allows clients
  1801. * to watch for nodes to appear.
  1802. * \param watcherCtx user specific data, will be passed to the watcher callback.
  1803. * Unlike the global context set by \ref zookeeper_init, this watcher context
  1804. * is associated with the given instance of the watcher only.
  1805. * \param the return stat value of the node.
  1806. * \return return code of the function call.
  1807. * ZOK operation completed successfully
  1808. * ZNONODE the node does not exist.
  1809. * ZNOAUTH the client does not have permission.
  1810. * ZBADARGUMENTS - invalid input parameters
  1811. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1812. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1813. */
  1814. ZOOAPI int zoo_wexists(zhandle_t *zh, const char *path,
  1815. watcher_fn watcher, void* watcherCtx, struct Stat *stat);
  1816. /**
  1817. * \brief gets the data associated with a node synchronously.
  1818. *
  1819. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1820. * \param path the name of the node. Expressed as a file name with slashes
  1821. * separating ancestors of the node.
  1822. * \param watch if nonzero, a watch will be set at the server to notify
  1823. * the client if the node changes.
  1824. * \param buffer the buffer holding the node data returned by the server
  1825. * \param buffer_len is the size of the buffer pointed to by the buffer parameter.
  1826. * It'll be set to the actual data length upon return. If the data is NULL, length is -1.
  1827. * \param stat if not NULL, will hold the value of stat for the path on return.
  1828. * \return return value of the function call.
  1829. * ZOK operation completed successfully
  1830. * ZNONODE the node does not exist.
  1831. * ZNOAUTH the client does not have permission.
  1832. * ZBADARGUMENTS - invalid input parameters
  1833. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1834. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1835. */
  1836. ZOOAPI int zoo_get(zhandle_t *zh, const char *path, int watch, char *buffer,
  1837. int* buffer_len, struct Stat *stat);
  1838. /**
  1839. * \brief gets the data associated with a node synchronously.
  1840. *
  1841. * This function is similar to \ref zoo_get except it allows one specify
  1842. * a watcher object rather than a boolean watch flag.
  1843. *
  1844. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1845. * \param path the name of the node. Expressed as a file name with slashes
  1846. * separating ancestors of the node.
  1847. * \param watcher if non-null, a watch will be set at the server to notify
  1848. * the client if the node changes.
  1849. * \param watcherCtx user specific data, will be passed to the watcher callback.
  1850. * Unlike the global context set by \ref zookeeper_init, this watcher context
  1851. * is associated with the given instance of the watcher only.
  1852. * \param buffer the buffer holding the node data returned by the server
  1853. * \param buffer_len is the size of the buffer pointed to by the buffer parameter.
  1854. * It'll be set to the actual data length upon return. If the data is NULL, length is -1.
  1855. * \param stat if not NULL, will hold the value of stat for the path on return.
  1856. * \return return value of the function call.
  1857. * ZOK operation completed successfully
  1858. * ZNONODE the node does not exist.
  1859. * ZNOAUTH the client does not have permission.
  1860. * ZBADARGUMENTS - invalid input parameters
  1861. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1862. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1863. */
  1864. ZOOAPI int zoo_wget(zhandle_t *zh, const char *path,
  1865. watcher_fn watcher, void* watcherCtx,
  1866. char *buffer, int* buffer_len, struct Stat *stat);
  1867. /**
  1868. * \brief gets the last committed configuration of the ZooKeeper cluster as it is known to
  1869. * the server to which the client is connected, synchronously.
  1870. *
  1871. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1872. * \param watch if nonzero, a watch will be set at the server to notify
  1873. * the client if the node changes.
  1874. * \param buffer the buffer holding the configuration data returned by the server
  1875. * \param buffer_len is the size of the buffer pointed to by the buffer parameter.
  1876. * It'll be set to the actual data length upon return. If the data is NULL, length is -1.
  1877. * \param stat if not NULL, will hold the value of stat for the path on return.
  1878. * \return return value of the function call.
  1879. * ZOK operation completed successfully
  1880. * ZNONODE the configuration node (/zookeeper/config) does not exist.
  1881. * ZNOAUTH the client does not have permission to access the configuration node.
  1882. * ZBADARGUMENTS - invalid input parameters
  1883. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1884. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1885. */
  1886. ZOOAPI int zoo_getconfig(zhandle_t *zh, int watch, char *buffer,
  1887. int* buffer_len, struct Stat *stat);
  1888. /**
  1889. * \brief gets the last committed configuration of the ZooKeeper cluster as it is known to
  1890. * the server to which the client is connected, synchronously.
  1891. *
  1892. * This function is similar to \ref zoo_getconfig except it allows one specify
  1893. * a watcher object rather than a boolean watch flag.
  1894. *
  1895. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1896. * \param watcher if non-null, a watch will be set at the server to notify
  1897. * the client if the node changes.
  1898. * \param watcherCtx user specific data, will be passed to the watcher callback.
  1899. * Unlike the global context set by \ref zookeeper_init, this watcher context
  1900. * is associated with the given instance of the watcher only.
  1901. * \param buffer the buffer holding the configuration data returned by the server
  1902. * \param buffer_len is the size of the buffer pointed to by the buffer parameter.
  1903. * It'll be set to the actual data length upon return. If the data is NULL, length is -1.
  1904. * \param stat if not NULL, will hold the value of stat for the path on return.
  1905. * \return return value of the function call.
  1906. * ZOK operation completed successfully
  1907. * ZNONODE the configuration node (/zookeeper/config) does not exist.
  1908. * ZNOAUTH the client does not have permission to access the configuration node.
  1909. * ZBADARGUMENTS - invalid input parameters
  1910. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1911. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1912. */
  1913. ZOOAPI int zoo_wgetconfig(zhandle_t *zh, watcher_fn watcher, void* watcherCtx,
  1914. char *buffer, int* buffer_len, struct Stat *stat);
  1915. /**
  1916. * \brief synchronous reconfiguration interface - allows changing ZK cluster
  1917. * ensemble membership and roles of ensemble peers.
  1918. *
  1919. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1920. * \param joining - comma separated list of servers to be added to the ensemble.
  1921. * Each has a configuration line for a server to be added (as would appear in a
  1922. * configuration file), only for maj. quorums. NULL for non-incremental reconfiguration.
  1923. * \param leaving - comma separated list of server IDs to be removed from the ensemble.
  1924. * Each has an id of a server to be removed, only for maj. quorums. NULL for
  1925. * non-incremental reconfiguration.
  1926. * \param members - comma separated list of new membership (e.g., contents of a
  1927. * membership configuration file) - for use only with a non-incremental
  1928. * reconfiguration. NULL for incremental reconfiguration.
  1929. * \param version - zxid of config from which we want to reconfigure - if
  1930. * current config is different reconfiguration will fail. Should be -1 to
  1931. * disable this option.
  1932. * \param buffer the buffer holding the configuration data returned by the server
  1933. * \param buffer_len is the size of the buffer pointed to by the buffer parameter.
  1934. * It'll be set to the actual data length upon return. If the data is NULL, length
  1935. * is -1.
  1936. * \param stat if not NULL, will hold the value of stat for the path on return.
  1937. * \return return value of the function call.
  1938. * ZOK operation completed successfully
  1939. * ZBADARGUMENTS - invalid input parameters (one case when this is returned is
  1940. * when the new config has less than 2 servers)
  1941. * ZINVALIDSTATE - zhandle state is either in ZOO_SESSION_EXPIRED_STATE or
  1942. * ZOO_AUTH_FAILED_STATE
  1943. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1944. * ZNEWCONFIGNOQUORUM - no quorum of new config is connected and up-to-date with
  1945. * the leader of last committed config - try invoking reconfiguration after new
  1946. * servers are connected and synced
  1947. * ZRECONFIGINPROGRESS - another reconfig is currently in progress
  1948. */
  1949. ZOOAPI int zoo_reconfig(zhandle_t *zh, const char *joining, const char *leaving,
  1950. const char *members, int64_t version, char *buffer, int* buffer_len,
  1951. struct Stat *stat);
  1952. /**
  1953. * \brief sets the data associated with a node. See zoo_set2 function if
  1954. * you require access to the stat information associated with the znode.
  1955. *
  1956. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1957. * \param path the name of the node. Expressed as a file name with slashes
  1958. * separating ancestors of the node.
  1959. * \param buffer the buffer holding data to be written to the node.
  1960. * \param buflen the number of bytes from buffer to write. To set NULL as data
  1961. * use buffer as NULL and buflen as -1.
  1962. * \param version the expected version of the node. The function will fail if
  1963. * the actual version of the node does not match the expected version. If -1 is
  1964. * used the version check will not take place.
  1965. * \return the return code for the function call.
  1966. * ZOK operation completed successfully
  1967. * ZNONODE the node does not exist.
  1968. * ZNOAUTH the client does not have permission.
  1969. * ZBADVERSION expected version does not match actual version.
  1970. * ZBADARGUMENTS - invalid input parameters
  1971. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1972. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1973. */
  1974. ZOOAPI int zoo_set(zhandle_t *zh, const char *path, const char *buffer,
  1975. int buflen, int version);
  1976. /**
  1977. * \brief sets the data associated with a node. This function is the same
  1978. * as zoo_set except that it also provides access to stat information
  1979. * associated with the znode.
  1980. *
  1981. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  1982. * \param path the name of the node. Expressed as a file name with slashes
  1983. * separating ancestors of the node.
  1984. * \param buffer the buffer holding data to be written to the node.
  1985. * \param buflen the number of bytes from buffer to write. To set NULL as data
  1986. * use buffer as NULL and buflen as -1.
  1987. * \param version the expected version of the node. The function will fail if
  1988. * the actual version of the node does not match the expected version. If -1 is
  1989. * used the version check will not take place.
  1990. * \param stat if not NULL, will hold the value of stat for the path on return.
  1991. * \return the return code for the function call.
  1992. * ZOK operation completed successfully
  1993. * ZNONODE the node does not exist.
  1994. * ZNOAUTH the client does not have permission.
  1995. * ZBADVERSION expected version does not match actual version.
  1996. * ZBADARGUMENTS - invalid input parameters
  1997. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  1998. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  1999. */
  2000. ZOOAPI int zoo_set2(zhandle_t *zh, const char *path, const char *buffer,
  2001. int buflen, int version, struct Stat *stat);
  2002. /**
  2003. * \brief lists the children of a node synchronously.
  2004. *
  2005. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  2006. * \param path the name of the node. Expressed as a file name with slashes
  2007. * separating ancestors of the node.
  2008. * \param watch if nonzero, a watch will be set at the server to notify
  2009. * the client if the node changes.
  2010. * \param strings return value of children paths.
  2011. * \return the return code of the function.
  2012. * ZOK operation completed successfully
  2013. * ZNONODE the node does not exist.
  2014. * ZNOAUTH the client does not have permission.
  2015. * ZBADARGUMENTS - invalid input parameters
  2016. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  2017. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  2018. */
  2019. ZOOAPI int zoo_get_children(zhandle_t *zh, const char *path, int watch,
  2020. struct String_vector *strings);
  2021. /**
  2022. * \brief lists the children of a node synchronously.
  2023. *
  2024. * This function is similar to \ref zoo_get_children except it allows one specify
  2025. * a watcher object rather than a boolean watch flag.
  2026. *
  2027. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  2028. * \param path the name of the node. Expressed as a file name with slashes
  2029. * separating ancestors of the node.
  2030. * \param watcher if non-null, a watch will be set at the server to notify
  2031. * the client if the node changes.
  2032. * \param watcherCtx user specific data, will be passed to the watcher callback.
  2033. * Unlike the global context set by \ref zookeeper_init, this watcher context
  2034. * is associated with the given instance of the watcher only.
  2035. * \param strings return value of children paths.
  2036. * \return the return code of the function.
  2037. * ZOK operation completed successfully
  2038. * ZNONODE the node does not exist.
  2039. * ZNOAUTH the client does not have permission.
  2040. * ZBADARGUMENTS - invalid input parameters
  2041. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  2042. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  2043. */
  2044. ZOOAPI int zoo_wget_children(zhandle_t *zh, const char *path,
  2045. watcher_fn watcher, void* watcherCtx,
  2046. struct String_vector *strings);
  2047. /**
  2048. * \brief lists the children of a node and get its stat synchronously.
  2049. *
  2050. * This function is new in version 3.3.0
  2051. *
  2052. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  2053. * \param path the name of the node. Expressed as a file name with slashes
  2054. * separating ancestors of the node.
  2055. * \param watch if nonzero, a watch will be set at the server to notify
  2056. * the client if the node changes.
  2057. * \param strings return value of children paths.
  2058. * \param stat return value of node stat.
  2059. * \return the return code of the function.
  2060. * ZOK operation completed successfully
  2061. * ZNONODE the node does not exist.
  2062. * ZNOAUTH the client does not have permission.
  2063. * ZBADARGUMENTS - invalid input parameters
  2064. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  2065. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  2066. */
  2067. ZOOAPI int zoo_get_children2(zhandle_t *zh, const char *path, int watch,
  2068. struct String_vector *strings, struct Stat *stat);
  2069. /**
  2070. * \brief lists the children of a node and get its stat synchronously.
  2071. *
  2072. * This function is similar to \ref zoo_get_children except it allows one specify
  2073. * a watcher object rather than a boolean watch flag.
  2074. *
  2075. * This function is new in version 3.3.0
  2076. *
  2077. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  2078. * \param path the name of the node. Expressed as a file name with slashes
  2079. * separating ancestors of the node.
  2080. * \param watcher if non-null, a watch will be set at the server to notify
  2081. * the client if the node changes.
  2082. * \param watcherCtx user specific data, will be passed to the watcher callback.
  2083. * Unlike the global context set by \ref zookeeper_init, this watcher context
  2084. * is associated with the given instance of the watcher only.
  2085. * \param strings return value of children paths.
  2086. * \param stat return value of node stat.
  2087. * \return the return code of the function.
  2088. * ZOK operation completed successfully
  2089. * ZNONODE the node does not exist.
  2090. * ZNOAUTH the client does not have permission.
  2091. * ZBADARGUMENTS - invalid input parameters
  2092. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  2093. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  2094. */
  2095. ZOOAPI int zoo_wget_children2(zhandle_t *zh, const char *path,
  2096. watcher_fn watcher, void* watcherCtx,
  2097. struct String_vector *strings, struct Stat *stat);
  2098. /**
  2099. * \brief gets the acl associated with a node synchronously.
  2100. *
  2101. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  2102. * \param path the name of the node. Expressed as a file name with slashes
  2103. * separating ancestors of the node.
  2104. * \param acl the return value of acls on the path.
  2105. * \param stat returns the stat of the path specified.
  2106. * \return the return code for the function call.
  2107. * ZOK operation completed successfully
  2108. * ZNONODE the node does not exist.
  2109. * ZNOAUTH the client does not have permission.
  2110. * ZBADARGUMENTS - invalid input parameters
  2111. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  2112. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  2113. */
  2114. ZOOAPI int zoo_get_acl(zhandle_t *zh, const char *path, struct ACL_vector *acl,
  2115. struct Stat *stat);
  2116. /**
  2117. * \brief sets the acl associated with a node synchronously.
  2118. *
  2119. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  2120. * \param path the name of the node. Expressed as a file name with slashes
  2121. * separating ancestors of the node.
  2122. * \param version the expected version of the path.
  2123. * \param acl the acl to be set on the path.
  2124. * \return the return code for the function call.
  2125. * ZOK operation completed successfully
  2126. * ZNONODE the node does not exist.
  2127. * ZNOAUTH the client does not have permission.
  2128. * ZINVALIDACL invalid ACL specified
  2129. * ZBADVERSION expected version does not match actual version.
  2130. * ZBADARGUMENTS - invalid input parameters
  2131. * ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
  2132. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  2133. */
  2134. ZOOAPI int zoo_set_acl(zhandle_t *zh, const char *path, int version,
  2135. const struct ACL_vector *acl);
  2136. /**
  2137. * \brief atomically commits multiple zookeeper operations synchronously.
  2138. *
  2139. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  2140. * \param count the number of operations
  2141. * \param ops an array of operations to commit
  2142. * \param results an array to hold the results of the operations
  2143. * \return the return code for the function call. This can be any of the
  2144. * values that can be returned by the ops supported by a multi op (see
  2145. * \ref zoo_acreate, \ref zoo_adelete, \ref zoo_aset).
  2146. */
  2147. ZOOAPI int zoo_multi(zhandle_t *zh, int count, const zoo_op_t *ops, zoo_op_result_t *results);
  2148. /**
  2149. * \brief removes the watches for the given path and watcher type.
  2150. *
  2151. * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init
  2152. * \param path the path for which watches will be removed
  2153. * \param wtype the watcher type to be removed
  2154. * \param watcher the watcher to be removed, if null all watches for that
  2155. * path (and watcher type) will be removed
  2156. * \param watcherCtx the contex associated with the watcher to be removed
  2157. * \param local whether the watches will be removed locally even if there is
  2158. * no server connection
  2159. * \return the return code for the function call.
  2160. * ZOK - operation completed successfully
  2161. * ZNOWATCHER - the watcher couldn't be found.
  2162. * ZINVALIDSTATE - if !local, zhandle state is either ZOO_SESSION_EXPIRED_STATE
  2163. * or ZOO_AUTH_FAILED_STATE
  2164. * ZBADARGUMENTS - invalid input parameters
  2165. * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
  2166. * ZSYSTEMERROR - a system error occured
  2167. */
  2168. ZOOAPI int zoo_remove_watches(zhandle_t *zh, const char *path,
  2169. ZooWatcherType wtype, watcher_fn watcher, void *watcherCtx, int local);
  2170. #endif
  2171. #ifdef __cplusplus
  2172. }
  2173. #endif
  2174. #endif /*ZOOKEEPER_H_*/