ZooKeeper.pm 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285
  1. # Net::ZooKeeper - Perl extension for Apache ZooKeeper
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one
  4. # or more contributor license agreements. See the NOTICE file
  5. # distributed with this work for additional information
  6. # regarding copyright ownership. The ASF licenses this file
  7. # to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance
  9. # with the License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. use 5.008_008;
  19. use strict;
  20. use warnings;
  21. package Net::ZooKeeper;
  22. require Exporter;
  23. require XSLoader;
  24. our $VERSION = '0.36';
  25. our @ISA = qw(Exporter);
  26. our %EXPORT_TAGS = (
  27. 'errors' => [qw(
  28. ZOK
  29. ZSYSTEMERROR
  30. ZRUNTIMEINCONSISTENCY
  31. ZDATAINCONSISTENCY
  32. ZCONNECTIONLOSS
  33. ZMARSHALLINGERROR
  34. ZUNIMPLEMENTED
  35. ZOPERATIONTIMEOUT
  36. ZBADARGUMENTS
  37. ZINVALIDSTATE
  38. ZAPIERROR
  39. ZNONODE
  40. ZNOAUTH
  41. ZBADVERSION
  42. ZNOCHILDRENFOREPHEMERALS
  43. ZNODEEXISTS
  44. ZNOTEMPTY
  45. ZSESSIONEXPIRED
  46. ZINVALIDCALLBACK
  47. ZINVALIDACL
  48. ZAUTHFAILED
  49. ZCLOSING
  50. ZNOTHING
  51. )],
  52. 'node_flags' => [qw(
  53. ZOO_EPHEMERAL
  54. ZOO_SEQUENCE
  55. )],
  56. 'acl_perms' => [qw(
  57. ZOO_PERM_READ
  58. ZOO_PERM_WRITE
  59. ZOO_PERM_CREATE
  60. ZOO_PERM_DELETE
  61. ZOO_PERM_ADMIN
  62. ZOO_PERM_ALL
  63. )],
  64. 'acls' => [qw(
  65. ZOO_OPEN_ACL_UNSAFE
  66. ZOO_READ_ACL_UNSAFE
  67. ZOO_CREATOR_ALL_ACL
  68. )],
  69. 'events' => [qw(
  70. ZOO_CREATED_EVENT
  71. ZOO_DELETED_EVENT
  72. ZOO_CHANGED_EVENT
  73. ZOO_CHILD_EVENT
  74. ZOO_SESSION_EVENT
  75. ZOO_NOTWATCHING_EVENT
  76. )],
  77. 'states' => [qw(
  78. ZOO_EXPIRED_SESSION_STATE
  79. ZOO_AUTH_FAILED_STATE
  80. ZOO_CONNECTING_STATE
  81. ZOO_ASSOCIATING_STATE
  82. ZOO_CONNECTED_STATE
  83. )],
  84. 'log_levels' => [qw(
  85. ZOO_LOG_LEVEL_OFF
  86. ZOO_LOG_LEVEL_ERROR
  87. ZOO_LOG_LEVEL_WARN
  88. ZOO_LOG_LEVEL_INFO
  89. ZOO_LOG_LEVEL_DEBUG
  90. )]
  91. );
  92. {
  93. my %tags;
  94. push @{$EXPORT_TAGS{'all'}},
  95. grep {!$tags{$_}++} @{$EXPORT_TAGS{$_}} foreach (keys(%EXPORT_TAGS));
  96. }
  97. our @EXPORT_OK = ( @{$EXPORT_TAGS{'all'}} );
  98. XSLoader::load('Net::ZooKeeper', $VERSION);
  99. 1;
  100. __END__
  101. =head1 NAME
  102. Net::ZooKeeper - Perl extension for Apache ZooKeeper
  103. =head1 SYNOPSIS
  104. use Net::ZooKeeper qw(:node_flags :acls);
  105. my $zkh = Net::ZooKeeper->new('localhost:7000');
  106. $zkh->create('/foo', 'bar',
  107. 'flags' => ZOO_EPHEMERAL,
  108. 'acl' => ZOO_OPEN_ACL_UNSAFE) or
  109. die("unable to create node /foo: " . $zkh->get_error() . "\n");
  110. print "node /foo has value: " . $zkh->get('/foo') . "\n";
  111. $zkh->set('/foo', 'baz');
  112. print "node / has child nodes:\n";
  113. foreach my $path ($zkh->get_children('/')) {
  114. print " /$path\n";
  115. }
  116. my $stat = $zkh->stat();
  117. if ($zkh->exists('/foo', 'stat' => $stat)) {
  118. print "node /foo has stat info:\n";
  119. while (my($key,$value) = each(%{$stat})) {
  120. print " $key: $value\n";
  121. }
  122. }
  123. foreach my $acl_entry ($zkh->get_acl('/foo')) {
  124. print "node /foo has ACL entry:\n";
  125. print " perms: $acl_entry->{perms}\n";
  126. print " scheme: $acl_entry->{scheme}\n";
  127. print " id: $acl_entry->{id}\n";
  128. }
  129. my $watch = $zkh->watch('timeout' => 10000);
  130. $zkh->exists('/foo', 'watch' => $watch);
  131. if ($watch->wait()) {
  132. print "watch triggered on node /foo:\n";
  133. print " event: $watch->{event}\n";
  134. print " state: $watch->{state}\n";
  135. }
  136. else {
  137. print "watch timed out after 10 seconds\n";
  138. }
  139. $zkh->delete('/foo');
  140. =head1 DESCRIPTION
  141. Net::ZooKeeper provides a Perl interface to the synchronous C API
  142. of Apache ZooKeeper. ZooKeeper is coordination service for
  143. distributed applications.
  144. Each connection to ZooKeeper is represented as a handle object
  145. of the class Net::ZooKeeper, similar to the manner in which database
  146. connections are represented in the DBI module.
  147. To disconnect from ZooKeeper, simply destroy the Net::ZooKeeper
  148. handle object by undefining it or by explicitly calling the
  149. C<DESTROY()> method.
  150. The methods which may be invoked on Net::ZooKeeper handles
  151. correspond to the functions of the synchronous ZooKeeper C API;
  152. e.g., the Net::ZooKeeper method C<create()> calls the ZooKeeper
  153. C function C<zoo_create()>, C<delete()> calls C<zoo_delete()>,
  154. and so forth.
  155. The synchronous API functions wait for a response from the ZooKeeper
  156. cluster before returning a result to the caller. Using these
  157. functions permits Net::ZooKeeper to provide an interface similar
  158. to that of a DBI driver module.
  159. =head2 Internal POSIX Threads
  160. The use of the synchronous ZooKeeper C API still requires that
  161. the ZooKeeper C client code create several POSIX threads which run
  162. concurrently with the main thread containing the Perl interpreter.
  163. The synchronous API functions are wrappers of the asynchronous
  164. functions in the ZooKeeper C API. When a request is made by the
  165. caller's thread (i.e., the one with the running Perl interpreter),
  166. it is enqueued for delivery at a later time by the ZooKeeper C client
  167. code's IO thread. The caller's thread then waits for notification
  168. before returning from the synchronous API function.
  169. The IO thread dequeues the request and sends it to the ZooKeeper
  170. cluster, while also ensuring that a regular "heartbeat" is maintained
  171. with the cluster so that the current session does not time out.
  172. When the IO thread receives a response from
  173. the ZooKeeper cluster, it enqueues the response for delivery to the
  174. client by the second thread of the ZooKeeper client code, the
  175. completion thread.
  176. If the caller is using the asynchronous API, the completion thread
  177. invokes the appropriate callback function provided by the caller
  178. for the given request. In the case of Net::ZooKeeper, it is not
  179. viable for the completion thread to invoke a Perl callback function
  180. at arbitrary times; this could interfere with the state of the
  181. Perl interpreter.
  182. For this reason Net::ZooKeeper uses the synchronous API only. After
  183. enqueuing requests the synchronous API functions wait for notification
  184. of the corresponding response. The completion thread delivers these
  185. notifications, at which point the synchronous functions return to
  186. their caller.
  187. Note that the IO and completion threads are POSIX threads, not
  188. Perl ithreads. Net::ZooKeeper defined a C<CLONE_SKIP()> function so
  189. that if Perl ithreads are spawned while a Net::ZooKeeper connection
  190. is active, the Net::ZooKeeper handle objects inherited by the
  191. spawned ithread contain undefined values so that they can not be used.
  192. Thus each ithread will need to create its own private connections to a
  193. ZooKeeper cluster.
  194. Note also that before invoking C<fork()> to spawn a new process,
  195. all Net::ZooKeeper handles should be destroyed so that all
  196. connections to ZooKeeper are closed and all internal POSIX threads
  197. have exited. If a child process needs to communicate with
  198. ZooKeeper it should open its own private connections after it is
  199. created by C<fork()>.
  200. =head2 Signals
  201. The ZooKeeper C API uses TCP connections to communicate with
  202. the ZooKeeper cluster. These connections may generate SIGPIPE
  203. signals when they encounter errors, such as when a connection
  204. is terminated by a ZooKeeper server. Therefore most applications
  205. will want to trap or ignore SIGPIPE signals, e.g.:
  206. local $SIG{'PIPE'} = 'IGNORE';
  207. Ignoring SIGPIPE signals (or providing a signal handler that returns
  208. control to the interrupted program after receiving the signal)
  209. will allow the ZooKeeper C client code to detect the connection error
  210. and report it upon return from the next Net::ZooKeeper method.
  211. =head2 Error Handling
  212. Net::ZooKeeper methods return different values in the case of an
  213. error depending on their purpose and context. For example,
  214. C<exists()> returns true if the node exists and false otherwise,
  215. which may indicate either that the node does not exist or that
  216. an error occurred.
  217. After any method returns a false, empty, or undefined value which
  218. might indicate an error has occurred, the C<get_error()> method
  219. may be called to examine the specific error code, if any.
  220. If C<get_error()> returns C<ZOK>, no error has occurred. If the
  221. error code is less than C<ZAPIERROR>, it indicates a normal error
  222. condition reported by the ZooKeeper server, such as C<ZNONODE>
  223. (node does not exist) or C<ZNODEEXISTS> (node already exists).
  224. If the error code is greater than C<ZAPIERROR>, then a connection
  225. error or server error has occurred and the client should probably
  226. close the connection by undefining the Net::ZooKeeper handle object
  227. and, if necessary, attempt to create a new connection to the
  228. ZooKeeper cluster.
  229. =head2 Access Control
  230. If the ZooKeeper cluster is not configured with C<skipACL=yes> then
  231. it will respect the access controls set for each node in the
  232. ZooKeeper hierarchy. These access controls are defined using ACLs
  233. (Access Control Lists); see the ZooKeeper documentation for compete
  234. details.
  235. In Net::ZooKeeper, ACLs are represented as arrays of hashes, where
  236. each hash is an ACL entry that must contain three attributes,
  237. C<perms>, C<scheme>, and C<id>. The C<perms> attribute's value
  238. should be composed by combining ACL permission flags using the
  239. bitwise OR operator. See C<:acl_perms> for a list of the
  240. available ACL permission flags.
  241. The ACL for a node may be read using the C<get_acl()> method. A
  242. node's ACL may be set when the node is created by passing an ACL
  243. array as the value of the C<'acl'> option to the C<create()> method,
  244. and may be updated by passing an ACL array to the C<set_acl()> method.
  245. When a client connects to a ZooKeeper cluster it is automatically
  246. assigned authentication credentials based on its IP address.
  247. Additional authentication credentials may be added using
  248. the C<add_auth()> method. Once a credential has been added for
  249. the current session, there is no way to disable it.
  250. As an example, digest authentication may be enabled for a session
  251. by calling C<add_auth()> as follows:
  252. $zkh->add_auth('digest', "$username:$password");
  253. Note that the username and password are transmitted in cleartext
  254. to the ZooKeeper cluster.
  255. Such authentication credentials would enable access to a node
  256. whose ACL contained an entry with a C<scheme> attribute of
  257. C<'digest'> and an C<id> attribute containing a Base64-encoded
  258. SHA1 digest of the string C<"$username:$password">. The
  259. Perl modules Digest and MIME::Base64 may be used to create
  260. such ACL ID values as follows:
  261. use Digest qw();
  262. use MIME::Base64 qw();
  263. my $ctx = Digest->new('SHA-1')->add("$username:$password");
  264. my $digest = MIME::Base64::encode($ctx->digest());
  265. Note that using the C<b64digest()> method of the Digest module
  266. will not result in digest strings with the "=" suffix characters
  267. required by ZooKeeper.
  268. =head2 Logging
  269. As of ZooKeeper version 3.1.1, logging in the C client code is
  270. implemented with a single, shared file handle to which all
  271. of the internal POSIX threads write log messages; by default,
  272. this file handle is attached to STDERR.
  273. Moreover, this file handle is shared by all active ZooKeeper
  274. connections (each of which has its own private IO and completion
  275. threads; see L</Internal POSIX Threads> above).
  276. Net::ZooKeeper therefore does not provide per-connection handle
  277. attributes related to logging. The global function
  278. C<Net::ZooKeeper::set_log_level()> may be used to set the current
  279. log level. See C<:log_levels> for a list of the available log
  280. levels. The default log level is C<ZOO_LOG_LEVEL_OFF>.
  281. To capture ZooKeeper log messages to a file instead of STDERR,
  282. redirect STDERR to a new file handle in the normal Perl manner:
  283. open(OLDERR, '>&', fileno(STDERR)) or
  284. die("unable to dup STDERR: $!");
  285. open(STDERR, '>', $log_file) or
  286. die("unable to redirect STDERR: $!");
  287. =head2 Connection Order
  288. ZooKeeper clusters are typically made up of an odd number of
  289. ZooKeeper servers. When connecting to such a cluster, the
  290. C<new()> method should be passed a comma-separated list of
  291. the hostnames and ports for each of the servers in the cluster,
  292. e.g., C<'host1:7000,host2:7000,host2:7100'>.
  293. The default behaviour of the ZooKeeper client code is to
  294. reorder this list randomly before making any connections.
  295. A connection is then made to the first server in the reordered
  296. list. If that connection fails, the IO thread will
  297. automatically attempt to reconnect to the cluster, this time
  298. to the next server in the list; when the last server in the list
  299. is reached, the IO thread will continue again with the first
  300. server.
  301. For certain purposes it may be necessary for ZooKeeper clients
  302. to know the exact order in which the IO thread will attempt to
  303. connect to the servers of a cluster. To do so, call
  304. C<Net::ZooKeeper::set_deterministic_conn_order(1)>. Note,
  305. however, that this will affect all Net::ZooKeeper object
  306. handles created by the current process.
  307. =head1 ATTRIBUTES
  308. =head2 Net::ZooKeeper
  309. The Net::ZooKeeper class provides the main interface to the
  310. ZooKeeper client API. The following attributes are available
  311. for each Net::ZooKeeper handle object and are specific to
  312. that handle and the method calls invoked on it. As with DBI
  313. handle objects, attributes may be read and written through
  314. a hash interface, e.g.:
  315. print sprintf("Session timeout is %.2f seconds.\n",
  316. $zkh->{session_timeout} / 1000);
  317. $zkh->{watch_timeout} = 10000;
  318. =over 4
  319. =item hosts
  320. The comma-separated list of ZooKeeper server hostnames and ports
  321. as passed to the C<new()> method. Note that by default the
  322. ZooKeeper C client code will reorder this list before attempting
  323. to connect for the first time; see L</Connection Order> for details.
  324. This attribute is B<read-only> and may not be modified.
  325. =item session_timeout
  326. The session timeout value, in milliseconds, as set by the
  327. ZooKeeper server after connection. This value may not be
  328. exactly the same as what was requested in the C<'session_timeout'>
  329. option of the C<new()> method; the server will adjust the
  330. requested timeout value so that it is within a certain range
  331. of the server's C<tickTime> setting. See the ZooKeeper
  332. documentation for details.
  333. Because the actual connection to the ZooKeeper server is
  334. not made during the C<new()> method call but shortly
  335. thereafter by the IO thread, note that this value may not
  336. be initialized to its final value until at least one
  337. other method which requires communication with the server
  338. (such as C<exists()>) has succeeded.
  339. This attribute is B<read-only> and may not be modified.
  340. =item session_id
  341. The client's session ID value as set by the ZooKeeper server
  342. after connection. This is a binary data string which may
  343. be passed to subsequent C<new()> calls as the value of
  344. the C<'session_id'> option, if the user wishes to attempt to
  345. continue a session after a failure. Note that the server
  346. may not honour such an attempt.
  347. Because the actual connection to the ZooKeeper server is
  348. not made during the C<new()> method call but shortly
  349. thereafter by the IO thread, note that this value may not
  350. be initialized to its final value until at least one
  351. other method which requires communication with the server
  352. (such as C<exists()>) has succeeded.
  353. This attribute is B<read-only> and may not be modified.
  354. =item data_read_len
  355. The maximum length of node data that will be returned to
  356. the caller by the C<get()> method. If a node's data exceeds
  357. this length, the returned value will be shorter than the
  358. actual node data as stored in the ZooKeeper cluster.
  359. The default maximum length of the node data returned by
  360. C<get()> is 1023 bytes. This may be changed by setting
  361. the C<data_read_len> attribute to a different value.
  362. Passing a value for the C<'data_read_len'> option when calling
  363. the C<get()> method will temporarily override the per-handle
  364. maximum.
  365. =item path_read_len
  366. The maximum length of a newly created node's path that will
  367. be returned to the caller by the C<create()> method. If the path
  368. of the newly created node exceeds this length, the returned
  369. value will be shorter than the actual path of the node as stored
  370. in the ZooKeeper cluster.
  371. The default maximum length of the node path returned by
  372. C<create()> is 1023 bytes. This may be changed by setting
  373. the C<path_read_len> attribute to a different value.
  374. Passing a value for the C<'path_read_len'> option when calling
  375. the C<create()> method will temporarily override the current
  376. value of this attribute.
  377. =item watch_timeout
  378. The C<timeout> attribute value, in milliseconds, inherited by
  379. all watch objects (of class Net::ZooKeeper::Watch) created by
  380. calls to the C<watch()> method. When a watch object's
  381. C<wait()> method is invoked without a C<'timeout'> option,
  382. it waits for an event notification from the ZooKeeper cluster
  383. for no longer than the timeout period specified by the value of
  384. the watch object's C<timeout> attribute.
  385. The default C<timeout> attribute value for all watch objects
  386. created by the C<watch()> method is 1 minute (60000
  387. milliseconds). This may be changed for a particular handle
  388. object by setting this attribute to a different value; afterwards,
  389. the new value will be inherited by any watch objects created
  390. by the handle object's C<watch()> method. Previously
  391. created watch objects will not be affected.
  392. Passing a value for the C<'timeout'> option when calling
  393. the C<watch()> method will temporarily override the current
  394. value of this attribute and cause the newly created watch object
  395. to inherit a different value.
  396. See also the C<watch()> method, and the C<timeout> attribute
  397. and C<wait()> method of the Net::ZooKeeper::Watch class.
  398. =item pending_watches
  399. The number of internal ZooKeeper watches created for this handle
  400. object that are still awaiting an event notification from the
  401. ZooKeeper cluster.
  402. Note that this number may be different than the number of
  403. extant watch objects created by the handle object's C<watch()>
  404. method, not only because some event notifications may have
  405. occurred, but also if any watch objects have been reassigned
  406. by reusing them in more than one call to any of the C<exists()>,
  407. C<get_children()>, or C<get()> methods.
  408. This attribute is B<read-only> and may not be modified.
  409. =back
  410. =head2 Net::ZooKeeper::Stat
  411. The Net::ZooKeeper::Stat class provides a hash interface to
  412. the individual pieces of information which together compose the
  413. state of a given ZooKeeper node. Net::ZooKeeper::Stat objects
  414. are created by calling the C<stat()> method on a Net::ZooKeeper
  415. handle object, and may then be passed to any methods which accept
  416. a C<'stat'> option value, such as C<exists()>.
  417. Net::ZooKeeper::Stat objects may be reused multiple times.
  418. If the Net::ZooKeeper method to which the stat object is
  419. passed succeeds, then the stat object is updated with the newly
  420. retrieved node state information, and any state information
  421. previously stored in the stat object is overwritten.
  422. All of the attributes of stat objects are B<read-only>.
  423. =over 4
  424. =item ctime
  425. The creation time of the node in milliseconds since the epoch.
  426. =item mtime
  427. The time of the last modification of the node's data in
  428. milliseconds since the epoch.
  429. =item data_len
  430. The length of the node's data in bytes.
  431. =item num_children
  432. The number of child nodes beneath of the current node.
  433. =item ephemeral_owner
  434. If the node was created with the C<ZOO_EPHEMERAL> flag,
  435. this attribute holds the session ID of the ZooKeeper client
  436. which created the node. If the node was not created with
  437. the C<ZOO_EPHEMERAL> flag, this attribute is set to zero.
  438. =item version
  439. The number of revisions of the node's data. The ZooKeeper
  440. cluster will increment this version number whenever the
  441. node's data is changed. When the node is first created this
  442. version number is initialized to zero.
  443. =item acl_version
  444. The number of revisions of the node's ACL. The ZooKeeper
  445. cluster will increment this version number whenever the
  446. node's ACL is changed. When the node is first created this
  447. version number is initialized to zero.
  448. =item children_version
  449. The number of revisions of the node's list of child nodes.
  450. The ZooKeeper cluster will increment this version number
  451. whenever the list of child nodes is changed. When the node
  452. is first created this version number is initialized to zero.
  453. =item czxid
  454. The ZooKeeper transaction ID (ZXID) of the transaction which
  455. created the node.
  456. =item mzxid
  457. The ZooKeeper transaction ID (ZXID) of the transaction which
  458. last modified the node's data. This is initially set to
  459. the same transaction ID as the C<czxid> attribute by the
  460. C<create()> method.
  461. =item children_zxid
  462. The ZooKeeper transaction ID (ZXID) of the transaction which
  463. last modified the node's list of child nodes. This is
  464. initially set to the same transaction ID as the C<czxid>
  465. attribute by the C<create()> method.
  466. =back
  467. =head2 Net::ZooKeeper::Watch
  468. The Net::ZooKeeper::Watch class provides a hash interface
  469. to the data returned by event notifications from the ZooKeeper
  470. cluster. Net::ZooKeeper::Watch objects are created by calling
  471. the C<watch()> method on a Net::ZooKeeper handle object, and
  472. may then be passed to any methods which accept a C<'watch'>
  473. option value, such as C<exists()>.
  474. Net::ZooKeeper::Watch objects may be reused multiple times.
  475. Regardless of whether the Net::ZooKeeper method to which the
  476. watch object is passed succeeds, the watch object will be
  477. updated to receive an event notification exclusively for the
  478. node referenced in that method call. In the case of an error,
  479. however, the watch object may never receive any event
  480. notification.
  481. =over 4
  482. =item timeout
  483. The default timeout value, in milliseconds, for all
  484. invocations of the C<wait()> method made on the watch object.
  485. When the C<wait()> method is invoked without a
  486. C<'timeout'> option value, it waits for an
  487. event notification from the ZooKeeper cluster for no longer
  488. than the timeout period specified by this attribute.
  489. This default timeout period may be altered by setting this
  490. attribute to a different value.
  491. Passing a value for the C<'timeout'> option when calling
  492. the C<wait()> method will temporarily override the current
  493. value of this attribute and cause the C<wait()> method to
  494. use a different timeout period.
  495. When a Net::ZooKeeper handle object's C<watch()> method is
  496. invoked without a C<'timeout'> option, it returns a newly
  497. created watch object whose C<timeout> attribute value
  498. is initialized to the current value of the handle object's
  499. C<watch_timeout> attribute. When the C<watch()> method is invoked
  500. with a C<'timeout'> option, the new watch object's C<timeout>
  501. attribute value is initialized to the value specified by
  502. the C<'timeout'> option.
  503. See also the C<wait()> method, and the C<watch_timeout> attribute
  504. and C<watch()> method of the Net::ZooKeeper class.
  505. =item event
  506. The type of event which triggered the notification, such
  507. as C<ZOO_CHANGED_EVENT> if the node's data was changed.
  508. See C<:events> for a list of the possible event types.
  509. If zero, no event notification has occurred yet.
  510. Note that the events which will trigger a notification
  511. will depend on the Net::ZooKeeper method to which
  512. the watch object was passed. Watches set through the
  513. C<exists()> and C<get()> methods will report events relating
  514. to the node's data, while watches set through the
  515. C<get_children()> method will report events relating to the
  516. creation or deletion of child nodes of the watched node.
  517. This attribute is B<read-only> and may not be modified.
  518. =item state
  519. The state of the Net::ZooKeeper connection at the time of
  520. the event notification. See C<:states> for a list of
  521. the possible connection states. If zero, no event
  522. notification has occurred yet.
  523. This attribute is B<read-only> and may not be modified.
  524. =back
  525. =head1 METHODS
  526. =head2 Net::ZooKeeper
  527. The following methods are defined for the Net::ZooKeeper class.
  528. =over 4
  529. =item new()
  530. $zkh = Net::ZooKeeper->new('host1:7000,host2:7000');
  531. $zkh = Net::ZooKeeper->new('host1:7000,host2:7000',
  532. 'session_timeout' => $session_timeout,
  533. 'session_id' => $session_id,
  534. 'sasl_options' => $sasl_options);
  535. Creates a new Net::ZooKeeper handle object and attempts to
  536. connect to the one of the servers of the given ZooKeeper
  537. cluster. As described in the L</Internal POSIX Threads> and
  538. L</Connection Order> sections, the ZooKeeper client code will
  539. create an IO thread which maintains the connection with a
  540. regular "heartbeat" request. In the event of a connection error
  541. the IO thread will also attempt to reconnect to another one of
  542. the servers using the same session ID. In general, these actions
  543. should be invisible to the user, although Net::ZooKeeper methods
  544. may return transient errors while the IO thread
  545. reconnects with another server.
  546. To disconnect, undefine the Net::ZooKeeper handle object
  547. or call the C<DESTROY()> method. (After calling C<DESTROY()>
  548. the handle object can not be reused.)
  549. The ZooKeeper client code will send a "heartbeat" message
  550. if a third of the session timeout period has elapsed without
  551. any communication with the ZooKeeper server. A specific
  552. session timeout period may be requested when creating a
  553. Net::ZooKeeper handle object by supplying a value, in
  554. milliseconds, for the C<'session_timeout'> option. The
  555. ZooKeeper server adjust the requested timeout value so that
  556. it is within a certain range of the server's C<tickTime> setting;
  557. the actual session timeout value will be available as the
  558. value of the handle's C<session_timeout> attribute after at
  559. least one method call has succeeded. See the C<session_timeout>
  560. attribute for more information.
  561. If no C<'session_timeout'> option is provided, the default
  562. value of 10 seconds (10000 milliseconds) will be used in the
  563. initial connection request; again, the actual timeout period to
  564. which the server agrees will be available subsequently as the
  565. value of the C<session_timeout> attribute.
  566. If a C<'sasl_options'> option is provided, it is used to automatically
  567. SASL-authenticate with the server during connections (including
  568. reconnects). Here is a brief description of the recognized keys;
  569. please refer to the C client documentation for details:
  570. =over 5
  571. =item service => VALUE
  572. =item host => VALUE
  573. =item mechlist => VALUE
  574. These map to the corresponding fields of C<zoo_sasl_params_t> from the
  575. library.
  576. =item user => VALUE
  577. =item realm => VALUE
  578. =item password_file => VALUE
  579. These map to the corresponding parameters of
  580. C<zoo_sasl_make_basic_callbacks> from the library.
  581. =back
  582. Upon successful connection (i.e., after the success of a method
  583. which requires communication with the server), the C<session_id>
  584. attribute will hold a short binary string which represents the
  585. client's session ID as set by the server. All ephemeral nodes
  586. created by the session are identified by this ID in the
  587. C<ephemeral_owner> attribute of any Net::ZooKeeper::Stat objects
  588. used to query their state.
  589. The ZooKeeper client code will use this session ID internally
  590. whenever it tries to reconnect to another server in the ZooKeeper
  591. cluster after detecting a failed connection. If it successfully
  592. reconnects with the same session ID, the session will continue
  593. and ephemeral nodes belonging to it will not be deleted.
  594. However, if the server determines that the session has timed
  595. out (for example because no "heartbeat" requests have been
  596. received within the agreed-upon session timeout period), the
  597. session will be terminated by the cluster and all ephemeral nodes
  598. owned by the current session automatically deleted.
  599. On occasion the ZooKeeper client code may not be able to quickly
  600. reconnect to a live server and the caller may want to destroy
  601. the existing Net::ZooKeeper handle object and attempt a
  602. fresh connection using the same session ID as before with a
  603. new Net::ZooKeeper object. To do so, save the C<session_id>
  604. attribute value before undefining the old handle object
  605. and then pass that binary string as the value of the
  606. C<'session_id'> option to the C<new()> method when creating the
  607. next handle object. After the successful completion of a
  608. method which requires communication with the server, if the
  609. new handle object's C<session_id> attribute value matches the
  610. old session ID then the session has been successfully maintained;
  611. otherwise, the old session was expired by the cluster.
  612. =item get_error()
  613. $code = $zkh->get_error();
  614. Returns the ZooKeeper error code, if any, from the most
  615. recent Net::ZooKeeper method invocation. The returned value
  616. will be zero (equivalent to C<ZOK>) if no error occurred,
  617. otherwise non-zero. Non-zero values may be compared to
  618. the error code names exported by the C<:errors> tagset.
  619. See L</Error Handling> for more details.
  620. =item add_auth()
  621. $zkh->add_auth('digest', "$username:$password");
  622. The C<add_auth()> method may be used to add authentication
  623. credentials to a session. Once a credential has been added for
  624. the current session, there is no way to disable it.
  625. When using the digest authentication scheme, note that the
  626. username and password are transmitted in cleartext
  627. to the ZooKeeper cluster.
  628. See L</Access Control> for additional details.
  629. =item create()
  630. $path = $zkh->create($req_path, $data);
  631. $path = $zkh->create($req_path, $data,
  632. 'flags' => (ZOO_EPHEMERAL | ZOO_SEQUENCE),
  633. 'acl' => ZOO_OPEN_ACL_UNSAFE,
  634. 'path_read_len' => 100);
  635. Requests that a node be created in the ZooKeeper cluster's
  636. hierarchy with the given path and data. Upon success,
  637. the returns the node's path, otherwise undef.
  638. The path returned by a successful C<create()> method call
  639. may not be the new node's full path as it appears in the
  640. ZooKeeper hierarchy, depending on the length of the actual
  641. path and the value of the handle object's C<path_read_len>
  642. attribute. If the length of the actual path exceeds the
  643. current value of the C<path_read_len> attribute, the path
  644. returned by the C<create()> method will be truncated; note
  645. that the node's path in the ZooKeeper hierarchy is not
  646. affected by this truncation.
  647. Specifying a value for the C<'path_read_len'> option will
  648. temporarily override the value of the C<path_read_len>
  649. attribute for the duration of the C<create()> method.
  650. The flag values available for use with the C<'flags'> option
  651. are C<ZOO_EPHEMERAL> and C<ZOO_SEQUENCE>; both are
  652. included in the C<:flags> tagset. The flags should be
  653. combined with the bitwise OR operator if more than one
  654. is required.
  655. The C<ZOO_EPHEMERAL> flag causes the node to be marked as
  656. ephemeral, meaning it will be automatically deleted if it
  657. still exists when the client's session ends. The
  658. C<ZOO_SEQUENCE> flag causes a unique integer to be appended
  659. to the node's final path component. See the ZooKeeper
  660. documentation for additional advice on how to use these flags.
  661. When creating a node it may be important to define an ACL
  662. for it; to do this, pass a reference to an ACL array (as
  663. described in L</Access Control>) using the C<'acl'> option.
  664. See also the C<:acl_perms> and C<:acls> tagsets for lists
  665. of the available ACL permission flags and pre-defined ACLs.
  666. =item delete()
  667. $ret = $zkh->delete($path);
  668. $ret = $zkh->delete($path, 'version' => $version);
  669. Requests that a node be deleted from the ZooKeeper hierarchy.
  670. Returns true upon success, false otherwise.
  671. If a value for the C<'version'> option is supplied, the node
  672. will only be deleted if its version number matches the given
  673. value. See the C<version> attribute of the Net::ZooKeeper::Stat
  674. class for details on node version numbering.
  675. =item exists()
  676. $ret = $zkh->exists($path);
  677. $ret = $zkh->exists($path, 'stat' => $stat, 'watch' => $watch);
  678. Tests whether a given node exists. Returns true if the node
  679. exists, otherwise false. When the C<exists()> method is successful
  680. but the node does not exist, it returns false, and C<get_error()>
  681. will return C<ZNONODE> until another method is called on the
  682. handle object.
  683. The C<'stat'> option may be used to request that a
  684. Net::ZooKeeper::Stat object be updated with the node's
  685. current state information. The stat object will only be
  686. updated if the node exists and the C<exists()> method
  687. succeeds. The stat object must first have been created
  688. using the C<stat()> method.
  689. The C<'watch'> option may be used to request that a
  690. Net::ZooKeeper::Watch object be assigned to receive
  691. notification of an event which alters the node's data.
  692. The watch object must first have been created using the
  693. C<watch()> method. If the watch object was previously
  694. assigned to receive notifications for another node, it
  695. will be reassigned even if the C<exists()> method fails.
  696. =item get_children()
  697. @child_names = $zkh->get_children($path);
  698. $num_children = $zkh->get_children($path, 'watch' => $watch);
  699. Queries the names or number of the child nodes stored beneath
  700. a given node in the ZooKeeper hierarchy. In a list context,
  701. returns a list of the child nodes' names upon success, otherwise
  702. an empty list. When the C<get_children()> method is successful
  703. but there are no child nodes, it returns an empty list, and
  704. C<get_error()> will return C<ZOK> until another method is called
  705. on the handle object.
  706. In a scalar context, C<get_children()> returns the number
  707. of child nodes upon success, otherwise undef.
  708. The names of the child nodes are simply the final component
  709. of the nodes' paths, i.e., the portion of their path which
  710. follows the path of the given parent node, excluding the
  711. "/" delimiter.
  712. The C<'watch'> option may be used to request that a
  713. Net::ZooKeeper::Watch object be assigned to receive
  714. notification of an event which alters the node's list of
  715. child nodes. The watch object must first have been created
  716. using the C<watch()> method. If the watch object was
  717. previously assigned to receive notifications for another node,
  718. it will be reassigned even if the C<get_children()> method fails.
  719. =item get()
  720. $data = $zkh->get($path);
  721. $data = $zkh->get($path, 'data_read_len' => 100,
  722. 'stat' => $stat, 'watch' => $watch);
  723. Queries the data stored in a given node. Returns the
  724. data as a string upon success, otherwise undef. Note
  725. that the data may contain nulls if the node's data is
  726. not a text string.
  727. If the length of the node's data exceeds the current value
  728. of the handle object's C<data_read_len> attribute, the
  729. string returned by the C<get()> method will be truncated;
  730. note that the node's data in the ZooKeeper cluster is not
  731. affected by this truncation.
  732. Specifying a value for the C<'data_read_len'> option will
  733. temporarily override the value of the C<data_read_len>
  734. attribute for the duration of the C<get()> method.
  735. The C<'stat'> option may be used to request that a
  736. Net::ZooKeeper::Stat object be updated with the node's
  737. current state information. The stat object will only be
  738. updated if the C<get()> method succeeds. The stat object
  739. must first have been created using the C<stat()> method.
  740. The C<'watch'> option may be used to request that a
  741. Net::ZooKeeper::Watch object be assigned to receive
  742. notification of an event which alters the node's data.
  743. The watch object must first have been created using the
  744. C<watch()> method. If the watch object was previously
  745. assigned to receive notifications for another node, it
  746. will be reassigned even if the C<get()> method fails.
  747. =item set()
  748. $ret = $zkh->set($path, $data);
  749. $ret = $zkh->set($path, $data, 'version' => $version,
  750. 'stat' => $stat);
  751. Requests that a node's data be updated in the ZooKeeper
  752. hierarchy. Returns true upon success, false otherwise.
  753. If a value for the C<'version'> option is supplied, the node's
  754. data will only be updated if its version number matches the
  755. given value. See the C<version> attribute of the
  756. Net::ZooKeeper::Stat class for details on node version numbering.
  757. The C<'stat'> option may be used to request that a
  758. Net::ZooKeeper::Stat object be updated with the node's
  759. current state information. The stat object will only be
  760. updated if the C<set()> method succeeds. The stat object
  761. must first have been created using the C<stat()> method.
  762. =item get_acl()
  763. @acl = $zkh->get_acl($path);
  764. $num_acl_entries = $zkh->get_acl($path, 'stat' => $stat);
  765. Queries the ACL associated with a node in the ZooKeeper
  766. hierarchy, if any. In a list context, returns an array with
  767. the node's ACL entries upon success, otherwise
  768. an empty list. When the C<get_acl()> method is successful
  769. but there are no ACL entries, it returns an empty list, and
  770. C<get_error()> will return C<ZOK> until another method is called
  771. on the handle object.
  772. The elements of the returned array are hashes, each of which
  773. represents one ACL entry. Each hash contains C<perms>,
  774. C<scheme>, and C<id> elements. See the L</Access Control>
  775. section for additional details, and the
  776. C<:acl_perms> and C<:acls> tagsets for lists of the
  777. available ACL permission flags and pre-defined ACLs.
  778. In a scalar context, C<get_acl()> returns the number
  779. of ACL entries upon success, otherwise undef.
  780. The C<'stat'> option may be used to request that a
  781. Net::ZooKeeper::Stat object be updated with the node's
  782. current state information. The stat object will only be
  783. updated if the C<get_acl()> method succeeds. The stat object
  784. must first have been created using the C<stat()> method.
  785. =item set_acl()
  786. $acl = [{
  787. 'perms' => (ZOO_PERM_READ | ZOO_PERM_WRITE),
  788. 'scheme' => 'digest',
  789. 'id' => "$username:$digest"
  790. }];
  791. $ret = $zkh->set_acl($path, $acl);
  792. $ret = $zkh->set_acl($path, ZOO_OPEN_ACL_UNSAFE,
  793. 'version' => $version);
  794. Requests that a node's ACL be updated in the ZooKeeper
  795. hierarchy. Returns true upon success, false otherwise.
  796. The ACL should be passed as a reference to an array of
  797. hashes, where each hash represents one ACL entry. Each
  798. hash should contain C<perms>, C<scheme>, and C<id> elements
  799. as described in the L</Access Control> section.
  800. See also the C<:acl_perms> and C<:acls> tagsets for lists
  801. of the available ACL permission flags and pre-defined ACLs.
  802. If a value for the C<'version'> option is supplied, the node's
  803. ACL will only be updated if its version number matches the
  804. given value. See the C<version> attribute of the
  805. Net::ZooKeeper::Stat class for details on node version numbering.
  806. =item stat()
  807. $stat = $zkh->stat();
  808. Creates a new Net::ZooKeeper::Stat object which may be used
  809. with the C<'stat'> option of the C<exists()>, C<get()>,
  810. C<set()>, and C<get_acl()> methods. When the stat object
  811. is passed to any of these methods, upon success its attribute
  812. values are updated to reflect the current state of the
  813. node specified in the method call. The stat object is not
  814. updated if the method call does not succeed.
  815. =item watch()
  816. $watch = $zkh->watch();
  817. $watch = $zkh->watch('timeout' => $timeout);
  818. Creates a new Net::ZooKeeper::Watch object which may be
  819. used to wait for event notifications from the ZooKeeper
  820. cluster. Each time the watch object is passed to any
  821. of the C<exists()>, C<get_children()>, or C<get()> methods,
  822. its attribute values are immediately reset to zero, and will
  823. later be updated upon receipt of an appropriate event
  824. notification for the node specified in the method call.
  825. The specific types of events which cause notifications to be
  826. sent by the ZooKeeper cluster depend on the method call used.
  827. After use with the C<exists()> and C<get()> methods, the
  828. watch object will be set to receive an event notification
  829. caused by a modification of the node's data or the node itself
  830. (e.g., deletion of the node). After use with the
  831. C<get_children()> method, the watch object will be set to
  832. receive an event notification caused by a modification
  833. of the node's list of child nodes.
  834. Watch objects receive at most one event notification after
  835. their assignment to a node by one of the C<exists()>,
  836. C<get_children()>, or C<get()> methods. Note that in the
  837. case of an error, the watch object may never receive any
  838. event notification. However, when the parent Net::ZooKeeper
  839. handle object experiences a connection error, the ZooKeeper
  840. client code will notify all pending watches with an event of
  841. type C<ZOO_SESSION_EVENT>. See C<wait()> for more information
  842. regarding the watch object's attribute values after a
  843. connection error.
  844. A watch object may be reused with another C<exists()>,
  845. C<get_children()>, or C<get()> method call at any time,
  846. in which case the watch object's attribute values
  847. are reset to zero and the watch object will no longer be updated
  848. by any event notification relevant to the previous method call.
  849. When the C<watch()> method is invoked without a C<'timeout'>
  850. option, it returns a newly created watch object whose C<timeout>
  851. attribute value is initialized to the current value of the
  852. Net::ZooKeeper handle object's C<watch_timeout> attribute.
  853. Otherwise, when the C<watch()> method is invoked with a
  854. C<'timeout'> option, the new watch object's C<timeout> attribute
  855. value is initialized to the value specified by the
  856. C<'timeout'> option.
  857. See also the C<watch_timeout> attribute, and the C<timeout>
  858. attribute and C<wait()> method of the Net::ZooKeeper::Watch
  859. class.
  860. =back
  861. =head2 Net::ZooKeeper::Stat
  862. No methods are defined for the Net::ZooKeeper::Stat class.
  863. =head2 Net::ZooKeeper::Watch
  864. Only one method is defined for the Net::ZooKeeper::Watch class.
  865. =over 4
  866. =item wait()
  867. $ret = $watch->wait();
  868. $ret = $watch->wait('timeout' => $timeout);
  869. Waits for an event notification from the ZooKeeper cluster
  870. for the node most recently associated with the watch object.
  871. Nodes are associated with a watch object by passing the
  872. watch object as the value of a C<'watch'> option to a
  873. Net::ZooKeeper method; methods which accept a C<'watch'> option
  874. are C<exists()>, C<get_children()>, and C<get()>.
  875. When the C<wait()> method is invoked with a C<'timeout'>
  876. option, it waits for no more than the number of milliseconds
  877. specified by the C<'timeout'> option.
  878. Otherwise, when the C<wait()> method is invoked without a
  879. C<'timeout'> option, it waits for no more than the timeout
  880. period specified by the value of the watch object's C<timeout>
  881. attribute.
  882. The C<wait()> method returns true if an event notification
  883. was received, otherwise false. When C<wait()> returns true,
  884. the C<event> and C<state> attributes of the watch object
  885. will be updated with the event's type and the current
  886. connection state.
  887. When the parent Net::ZooKeeper handle object experiences a
  888. connection error, the ZooKeeper client code will notify all
  889. pending watches with an event of type C<ZOO_SESSION_EVENT>.
  890. In this case, the C<state> attribute will report the current
  891. state of the connection to the ZooKeeper cluster.
  892. See also the C<timeout> attribute, and the C<watch()> method
  893. and C<watch_timeout> attribute of the Net::ZooKeeper class.
  894. =back
  895. =head1 FUNCTIONS
  896. The following functions have global scope and affect all
  897. Net::ZooKeeper handle objects.
  898. =over 4
  899. =item set_log_level()
  900. Net::ZooKeeper::set_log_level($level);
  901. The C<Net::ZooKeeper::set_log_level()> function may be called to
  902. alter the number and type of messages written to the current log
  903. file handle (if any). The default value is C<ZOO_LOG_LEVEL_OFF>
  904. which disables all logging.
  905. See the L</Logging> section for more details and C<:log_levels>
  906. for a list of the available log levels.
  907. =item set_deterministic_conn_order()
  908. Net::ZooKeeper::set_deterministic_conn_order(1);
  909. The C<Net::ZooKeeper::set_deterministic_conn_order()> function
  910. may be called to indicate whether or not the list of ZooKeeper
  911. servers passed to the C<new()> method should be randomly permuted.
  912. If set to a true value, the list of servers will not be altered.
  913. The default false value indicates the list of servers will
  914. be randomly reordered prior to connection.
  915. See the L</Connection Order> section for more details.
  916. =back
  917. =head1 EXPORTS
  918. Nothing is exported by default. Various tagsets exist which
  919. group the tags available for export into different categories:
  920. =over 4
  921. =item :errors
  922. ZooKeeper error codes. These may be compared to the values
  923. returned by the C<get_error()> method.
  924. =item :node_flags
  925. The ZooKeeper node flags C<ZOO_EPHEMERAL> and C<ZOO_SEQUENCE>,
  926. which may be passed in the C<'flags'> option to the C<create()>
  927. method. When more than node flag is required they
  928. should be combined using the bitwise OR operator.
  929. =item :acl_perms
  930. The ZooKeeper ACL permission flags which may be used in
  931. the value of the C<perms> attribute of an ACL entry hash.
  932. When more than one ACL permission flag is required they
  933. should be combined using the bitwise OR operator.
  934. The available ACL permission flags are C<ZOO_PERM_READ>,
  935. C<ZOO_PERM_WRITE>, C<ZOO_PERM_CREATE>, C<ZOO_PERM_DELETE>,
  936. and C<ZOO_PERM_ADMIN>. For convenience, C<ZOO_PERM_ALL> is
  937. defined as the bitwise OR of all of these flags.
  938. =item :acls
  939. Common ZooKeeper ACLs which may be useful. C<ZOO_OPEN_ACL_UNSAFE>
  940. specifies a node which is entirely open to all users with no
  941. restrictions at all. C<ZOO_READ_ACL_UNSAFE> specifies
  942. a node which is readable by all users; permissions for other actions
  943. are not defined in this ACL. C<ZOO_CREATOR_ALL_ACL> specifies a node
  944. for which all actions require the same authentication credentials as
  945. held by the session which created the node; this implies that a
  946. session should authenticate with an appropriate scheme before
  947. creating a node with this ACL.
  948. =item :events
  949. The ZooKeeper event types which are returned in value of
  950. the C<event> attribute a Net::ZooKeeper::Watch object after
  951. an event occurs on a watched node.
  952. =item :states
  953. The ZooKeeper connection states which are returned in value of
  954. the C<state> attribute of a Net::ZooKeeper::Watch object after
  955. an event occurs on a watched node.
  956. =item :log_levels
  957. The ZooKeeper log levels which may be passed to the
  958. C<Net::ZooKeeper::set_log_level()> function. The available
  959. log levels are, from least to most verbose, C<ZOO_LOG_LEVEL_OFF>
  960. (the default), C<ZOO_LOG_LEVEL_ERROR>, C<ZOO_LOG_LEVEL_WARN>,
  961. C<ZOO_LOG_LEVEL_INFO>, and C<ZOO_LOG_LEVEL_DEBUG>.
  962. =item :all
  963. Everything from all of the above tagsets.
  964. =back
  965. =head1 SEE ALSO
  966. The Apache ZooKeeper project's home page at
  967. L<http://zookeeper.apache.org/> provides a wealth of detail
  968. on how to develop applications using ZooKeeper.
  969. =head1 AUTHOR
  970. Chris Darroch, E<lt>chrisd@apache.orgE<gt>
  971. =head1 COPYRIGHT AND LICENSE
  972. Licensed to the Apache Software Foundation (ASF) under one
  973. or more contributor license agreements. See the NOTICE file
  974. distributed with this work for additional information
  975. regarding copyright ownership. The ASF licenses this file
  976. to you under the Apache License, Version 2.0 (the
  977. "License"); you may not use this file except in compliance
  978. with the License. You may obtain a copy of the License at
  979. http://www.apache.org/licenses/LICENSE-2.0
  980. Unless required by applicable law or agreed to in writing, software
  981. distributed under the License is distributed on an "AS IS" BASIS,
  982. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  983. See the License for the specific language governing permissions and
  984. limitations under the License.
  985. =cut