zookeeper.h 109 KB

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