zookeeperProgrammers.html 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <meta content="Apache Forrest" name="Generator">
  6. <meta name="Forrest-version" content="0.8">
  7. <meta name="Forrest-skin-name" content="pelt">
  8. <title>ZooKeeper Programmer's Guide</title>
  9. <link type="text/css" href="skin/basic.css" rel="stylesheet">
  10. <link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
  11. <link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
  12. <link type="text/css" href="skin/profile.css" rel="stylesheet">
  13. <script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
  14. <link rel="shortcut icon" href="images/favicon.ico">
  15. </head>
  16. <body onload="init()">
  17. <script type="text/javascript">ndeSetTextSize();</script>
  18. <div id="top">
  19. <!--+
  20. |breadtrail
  21. +-->
  22. <div class="breadtrail">
  23. <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://hadoop.apache.org/">Hadoop</a> &gt; <a href="http://hadoop.apache.org/zookeeper/">ZooKeeper</a><script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
  24. </div>
  25. <!--+
  26. |header
  27. +-->
  28. <div class="header">
  29. <!--+
  30. |start group logo
  31. +-->
  32. <div class="grouplogo">
  33. <a href="http://hadoop.apache.org/"><img class="logoImage" alt="Hadoop" src="images/hadoop-logo.jpg" title="Apache Hadoop"></a>
  34. </div>
  35. <!--+
  36. |end group logo
  37. +-->
  38. <!--+
  39. |start Project Logo
  40. +-->
  41. <div class="projectlogo">
  42. <a href="http://hadoop.apache.org/zookeeper/"><img class="logoImage" alt="ZooKeeper" src="images/zookeeper_small.gif" title="ZooKeeper: distributed coordination"></a>
  43. </div>
  44. <!--+
  45. |end Project Logo
  46. +-->
  47. <!--+
  48. |start Search
  49. +-->
  50. <div class="searchbox">
  51. <form action="http://www.google.com/search" method="get" class="roundtopsmall">
  52. <input value="hadoop.apache.org" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google">&nbsp;
  53. <input name="Search" value="Search" type="submit">
  54. </form>
  55. </div>
  56. <!--+
  57. |end search
  58. +-->
  59. <!--+
  60. |start Tabs
  61. +-->
  62. <ul id="tabs">
  63. <li>
  64. <a class="unselected" href="http://hadoop.apache.org/zookeeper/">Project</a>
  65. </li>
  66. <li>
  67. <a class="unselected" href="http://wiki.apache.org/hadoop/ZooKeeper">Wiki</a>
  68. </li>
  69. <li class="current">
  70. <a class="selected" href="index.html">ZooKeeper 3.2 Documentation</a>
  71. </li>
  72. </ul>
  73. <!--+
  74. |end Tabs
  75. +-->
  76. </div>
  77. </div>
  78. <div id="main">
  79. <div id="publishedStrip">
  80. <!--+
  81. |start Subtabs
  82. +-->
  83. <div id="level2tabs"></div>
  84. <!--+
  85. |end Endtabs
  86. +-->
  87. <script type="text/javascript"><!--
  88. document.write("Last Published: " + document.lastModified);
  89. // --></script>
  90. </div>
  91. <!--+
  92. |breadtrail
  93. +-->
  94. <div class="breadtrail">
  95. &nbsp;
  96. </div>
  97. <!--+
  98. |start Menu, mainarea
  99. +-->
  100. <!--+
  101. |start Menu
  102. +-->
  103. <div id="menu">
  104. <div onclick="SwitchMenu('menu_1.1', 'skin/')" id="menu_1.1Title" class="menutitle">Overview</div>
  105. <div id="menu_1.1" class="menuitemgroup">
  106. <div class="menuitem">
  107. <a href="index.html">Welcome</a>
  108. </div>
  109. <div class="menuitem">
  110. <a href="zookeeperOver.html">Overview</a>
  111. </div>
  112. <div class="menuitem">
  113. <a href="zookeeperStarted.html">Getting Started</a>
  114. </div>
  115. <div class="menuitem">
  116. <a href="releasenotes.html">Release Notes</a>
  117. </div>
  118. </div>
  119. <div onclick="SwitchMenu('menu_selected_1.2', 'skin/')" id="menu_selected_1.2Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Developer</div>
  120. <div id="menu_selected_1.2" class="selectedmenuitemgroup" style="display: block;">
  121. <div class="menuitem">
  122. <a href="api/index.html">API Docs</a>
  123. </div>
  124. <div class="menupage">
  125. <div class="menupagetitle">Programmer's Guide</div>
  126. </div>
  127. <div class="menuitem">
  128. <a href="javaExample.html">Java Example</a>
  129. </div>
  130. <div class="menuitem">
  131. <a href="zookeeperTutorial.html">Barrier and Queue Tutorial</a>
  132. </div>
  133. <div class="menuitem">
  134. <a href="recipes.html">Recipes</a>
  135. </div>
  136. </div>
  137. <div onclick="SwitchMenu('menu_1.3', 'skin/')" id="menu_1.3Title" class="menutitle">Admin &amp; Ops</div>
  138. <div id="menu_1.3" class="menuitemgroup">
  139. <div class="menuitem">
  140. <a href="zookeeperAdmin.html">Administrator's Guide</a>
  141. </div>
  142. <div class="menuitem">
  143. <a href="zookeeperQuotas.html">Quota Guide</a>
  144. </div>
  145. <div class="menuitem">
  146. <a href="zookeeperJMX.html">JMX</a>
  147. </div>
  148. </div>
  149. <div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle">Contributor</div>
  150. <div id="menu_1.4" class="menuitemgroup">
  151. <div class="menuitem">
  152. <a href="zookeeperInternals.html">ZooKeeper Internals</a>
  153. </div>
  154. </div>
  155. <div onclick="SwitchMenu('menu_1.5', 'skin/')" id="menu_1.5Title" class="menutitle">Miscellaneous</div>
  156. <div id="menu_1.5" class="menuitemgroup">
  157. <div class="menuitem">
  158. <a href="http://wiki.apache.org/hadoop/ZooKeeper">Wiki</a>
  159. </div>
  160. <div class="menuitem">
  161. <a href="http://wiki.apache.org/hadoop/ZooKeeper/FAQ">FAQ</a>
  162. </div>
  163. <div class="menuitem">
  164. <a href="http://hadoop.apache.org/zookeeper/mailing_lists.html">Mailing Lists</a>
  165. </div>
  166. </div>
  167. <div id="credit"></div>
  168. <div id="roundbottom">
  169. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  170. <!--+
  171. |alternative credits
  172. +-->
  173. <div id="credit2"></div>
  174. </div>
  175. <!--+
  176. |end Menu
  177. +-->
  178. <!--+
  179. |start content
  180. +-->
  181. <div id="content">
  182. <div title="Portable Document Format" class="pdflink">
  183. <a class="dida" href="zookeeperProgrammers.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  184. PDF</a>
  185. </div>
  186. <h1>ZooKeeper Programmer's Guide</h1>
  187. <h3>Developing Distributed Applications that use ZooKeeper</h3>
  188. <div id="minitoc-area">
  189. <ul class="minitoc">
  190. <li>
  191. <a href="#_introduction">Introduction</a>
  192. </li>
  193. <li>
  194. <a href="#ch_zkDataModel">The ZooKeeper Data Model</a>
  195. <ul class="minitoc">
  196. <li>
  197. <a href="#sc_zkDataModel_znodes">ZNodes</a>
  198. <ul class="minitoc">
  199. <li>
  200. <a href="#sc_zkDataMode_watches">Watches</a>
  201. </li>
  202. <li>
  203. <a href="#Data+Access">Data Access</a>
  204. </li>
  205. <li>
  206. <a href="#Ephemeral+Nodes">Ephemeral Nodes</a>
  207. </li>
  208. <li>
  209. <a href="#Sequence+Nodes+--+Unique+Naming">Sequence Nodes -- Unique Naming</a>
  210. </li>
  211. </ul>
  212. </li>
  213. <li>
  214. <a href="#sc_timeInZk">Time in ZooKeeper</a>
  215. </li>
  216. <li>
  217. <a href="#sc_zkStatStructure">ZooKeeper Stat Structure</a>
  218. </li>
  219. </ul>
  220. </li>
  221. <li>
  222. <a href="#ch_zkSessions">ZooKeeper Sessions</a>
  223. </li>
  224. <li>
  225. <a href="#ch_zkWatches">ZooKeeper Watches</a>
  226. <ul class="minitoc">
  227. <li>
  228. <a href="#sc_WatchGuarantees">What ZooKeeper Guarantees about Watches</a>
  229. </li>
  230. <li>
  231. <a href="#sc_WatchRememberThese">Things to Remember about Watches</a>
  232. </li>
  233. </ul>
  234. </li>
  235. <li>
  236. <a href="#sc_ZooKeeperAccessControl">ZooKeeper access control using ACLs</a>
  237. <ul class="minitoc">
  238. <li>
  239. <a href="#sc_ACLPermissions">ACL Permissions</a>
  240. <ul class="minitoc">
  241. <li>
  242. <a href="#sc_BuiltinACLSchemes">Builtin ACL Schemes</a>
  243. </li>
  244. <li>
  245. <a href="#ZooKeeper+C+client+API">ZooKeeper C client API</a>
  246. </li>
  247. </ul>
  248. </li>
  249. </ul>
  250. </li>
  251. <li>
  252. <a href="#ch_zkGuarantees">Consistency Guarantees</a>
  253. </li>
  254. <li>
  255. <a href="#ch_bindings">Bindings</a>
  256. <ul class="minitoc">
  257. <li>
  258. <a href="#Java+Binding">Java Binding</a>
  259. </li>
  260. <li>
  261. <a href="#C+Binding">C Binding</a>
  262. <ul class="minitoc">
  263. <li>
  264. <a href="#Installation">Installation</a>
  265. </li>
  266. <li>
  267. <a href="#Using+the+C+Client">Using the C Client</a>
  268. </li>
  269. </ul>
  270. </li>
  271. </ul>
  272. </li>
  273. <li>
  274. <a href="#ch_guideToZkOperations">Building Blocks: A Guide to ZooKeeper Operations</a>
  275. <ul class="minitoc">
  276. <li>
  277. <a href="#sc_errorsZk">Handling Errors</a>
  278. </li>
  279. <li>
  280. <a href="#sc_connectingToZk">Connecting to ZooKeeper</a>
  281. </li>
  282. <li>
  283. <a href="#sc_readOps">Read Operations</a>
  284. </li>
  285. <li>
  286. <a href="#sc_writeOps">Write Operations</a>
  287. </li>
  288. <li>
  289. <a href="#sc_handlingWatches">Handling Watches</a>
  290. </li>
  291. <li>
  292. <a href="#sc_miscOps">Miscelleaneous ZooKeeper Operations</a>
  293. </li>
  294. </ul>
  295. </li>
  296. <li>
  297. <a href="#ch_programStructureWithExample">Program Structure, with Simple Example</a>
  298. </li>
  299. <li>
  300. <a href="#ch_gotchas">Gotchas: Common Problems and Troubleshooting</a>
  301. </li>
  302. </ul>
  303. </div>
  304. <a name="N1000B"></a><a name="_introduction"></a>
  305. <h2 class="h3">Introduction</h2>
  306. <div class="section">
  307. <p>This document is a guide for developers wishing to create
  308. distributed applications that take advantage of ZooKeeper's coordination
  309. services. It contains conceptual and practical information.</p>
  310. <p>The first four sections of this guide present higher level
  311. discussions of various ZooKeeper concepts. These are necessary both for an
  312. understanding of how ZooKeeper works as well how to work with it. It does
  313. not contain source code, but it does assume a familiarity with the
  314. problems associated with distributed computing. The sections in this first
  315. group are:</p>
  316. <ul>
  317. <li>
  318. <p>
  319. <a href="#ch_zkDataModel">The ZooKeeper Data Model</a>
  320. </p>
  321. </li>
  322. <li>
  323. <p>
  324. <a href="#ch_zkSessions">ZooKeeper Sessions</a>
  325. </p>
  326. </li>
  327. <li>
  328. <p>
  329. <a href="#ch_zkWatches">ZooKeeper Watches</a>
  330. </p>
  331. </li>
  332. <li>
  333. <p>
  334. <a href="#ch_zkGuarantees">Consistency Guarantees</a>
  335. </p>
  336. </li>
  337. </ul>
  338. <p>The next four sections of this provided practical programming
  339. information. These are:</p>
  340. <ul>
  341. <li>
  342. <p>
  343. <a href="#ch_guideToZkOperations">Building Blocks: A Guide to ZooKeeper Operations</a>
  344. </p>
  345. </li>
  346. <li>
  347. <p>
  348. <a href="#ch_bindings">Bindings</a>
  349. </p>
  350. </li>
  351. <li>
  352. <p>
  353. <a href="#ch_programStructureWithExample">Program Structure, with Simple Example</a>
  354. <em>[tbd]</em>
  355. </p>
  356. </li>
  357. <li>
  358. <p>
  359. <a href="#ch_gotchas">Gotchas: Common Problems and Troubleshooting</a>
  360. </p>
  361. </li>
  362. </ul>
  363. <p>The book concludes with an <a href="#apx_linksToOtherInfo">appendix</a> containing links to other
  364. useful, ZooKeeper-related information.</p>
  365. <p>Most of information in this document is written to be accessible as
  366. stand-alone reference material. However, before starting your first
  367. ZooKeeper application, you should probably at least read the chaptes on
  368. the <a href="#ch_zkDataModel">ZooKeeper Data Model</a> and <a href="#ch_guideToZkOperations">ZooKeeper Basic Operations</a>. Also,
  369. the <a href="#ch_programStructureWithExample">Simple Programmming
  370. Example</a> <em>[tbd]</em> is helpful for understand the basic
  371. structure of a ZooKeeper client application.</p>
  372. </div>
  373. <a name="N1007D"></a><a name="ch_zkDataModel"></a>
  374. <h2 class="h3">The ZooKeeper Data Model</h2>
  375. <div class="section">
  376. <p>ZooKeeper has a hierarchal name space, much like a distributed file
  377. system. The only difference is that each node in the namespace can have
  378. data associated with it as well as children. It is like having a file
  379. system that allows a file to also be a directory. Paths to nodes are
  380. always expressed as canonical, absolute, slash-separated paths; there are
  381. no relative reference. Any unicode character can be used in a path subject
  382. to the following constraints:</p>
  383. <ul>
  384. <li>
  385. <p>The null character (\u0000) cannot be part of a path name. (This
  386. causes problems with the C binding.)</p>
  387. </li>
  388. <li>
  389. <p>The following characters can't be used because they don't
  390. display well, or render in confusing ways: \u0001 - \u0019 and \u007F
  391. - \u009F.</p>
  392. </li>
  393. <li>
  394. <p>The following characters are not allowed: \ud800 -uF8FFF,
  395. \uFFF0-uFFFF, \uXFFFE - \uXFFFF (where X is a digit 1 - E), \uF0000 -
  396. \uFFFFF.</p>
  397. </li>
  398. <li>
  399. <p>The "." character can be used as part of another name, but "."
  400. and ".." cannot alone be used to indicate a node along a path,
  401. because ZooKeeper doesn't use relative paths. The following would be
  402. invalid: "/a/b/./c" or "/a/b/../c".</p>
  403. </li>
  404. <li>
  405. <p>The token "zookeeper" is reserved.</p>
  406. </li>
  407. </ul>
  408. <a name="N100A7"></a><a name="sc_zkDataModel_znodes"></a>
  409. <h3 class="h4">ZNodes</h3>
  410. <p>Every node in a ZooKeeper tree is refered to as a
  411. <em>znode</em>. Znodes maintain a stat structure that
  412. includes version numbers for data changes, acl changes. The stat
  413. structure also has timestamps. The version number, together with the
  414. timestamp allow ZooKeeper to validate the cache and to coordinate
  415. updates. Each time a znode's data changes, the version number increases.
  416. For instance, whenever a client retrieves data, it also receives the
  417. version of the data. And when a client performs an update or a delete,
  418. it must supply the version of the data of the znode it is changing. If
  419. the version it supplies doesn't match the actual version of the data,
  420. the update will fail. (This behavior can be overridden. For more
  421. information see... )<em>[tbd...]</em>
  422. </p>
  423. <div class="note">
  424. <div class="label">Note</div>
  425. <div class="content">
  426. <p>In distributed application engineering, the word
  427. <em>node</em> can refer to a generic host machine, a
  428. server, a member of an ensemble, a client process, etc. In the ZooKeeper
  429. documentatin, <em>znodes</em> refer to the data nodes.
  430. <em>Servers</em> to refer to machines that make up the
  431. ZooKeeper service; <em>quorum peers</em> refer to the
  432. servers that make up an ensemble; client refers to any host or process
  433. which uses a ZooKeeper service.</p>
  434. </div>
  435. </div>
  436. <p>Znodes are the main enitity that a programmer access. They have
  437. several characteristics that are worth mentioning here.</p>
  438. <a name="N100CA"></a><a name="sc_zkDataMode_watches"></a>
  439. <h4>Watches</h4>
  440. <p>Clients can set watches on znodes. Changes to that znode trigger
  441. the watch and then clear the watch. When a watch triggers, ZooKeeper
  442. sends the client a notification. More information about watches can be
  443. found in the section
  444. <a href="#ch_zkWatches">ZooKeeper Watches</a>.</p>
  445. <a name="N100D8"></a><a name="Data+Access"></a>
  446. <h4>Data Access</h4>
  447. <p>The data stored at each znode in a namespace is read and written
  448. atomically. Reads get all the data bytes associated with a znode and a
  449. write replaces all the data. Each node has an Access Control List
  450. (ACL) that restricts who can do what.</p>
  451. <a name="N100E2"></a><a name="Ephemeral+Nodes"></a>
  452. <h4>Ephemeral Nodes</h4>
  453. <p>ZooKeeper also has the notion of ephemeral nodes. These znodes
  454. exists as long as the session that created the znode is active. When
  455. the session ends the znode is deleted. Because of this behavior
  456. ephemeral znodes are not allowed to have children.</p>
  457. <a name="N100EC"></a><a name="Sequence+Nodes+--+Unique+Naming"></a>
  458. <h4>Sequence Nodes -- Unique Naming</h4>
  459. <p>When creating a znode you can also request that
  460. ZooKeeper append a monotonicly increasing counter to the end
  461. of path. This counter is unique to the parent znode. The
  462. counter has a format of %010d -- that is 10 digits with 0
  463. (zero) padding (the counter is formatted in this way to
  464. simplify sorting), i.e. "&lt;path&gt;0000000001". See
  465. <a href="recipes.html#sc_recipes_Queues">Queue
  466. Recipe</a> for an example use of this feature. Note: the
  467. counter used to store the next sequence number is a signed int
  468. (4bytes) maintained by the parent node, the counter will
  469. overflow when incremented beyond 2147483647 (resulting in a
  470. name "&lt;path&gt;-2147483647").</p>
  471. <a name="N100FB"></a><a name="sc_timeInZk"></a>
  472. <h3 class="h4">Time in ZooKeeper</h3>
  473. <p>ZooKeeper tracks time multiple ways:</p>
  474. <ul>
  475. <li>
  476. <p>
  477. <strong>Zxid</strong>
  478. </p>
  479. <p>Every change to the ZooKeeper state receives a stamp in the
  480. form of a <em>zxid</em> (ZooKeeper Transaction Id).
  481. This exposes the total ordering of all changes to ZooKeeper. Each
  482. change will have a unique zxid and if zxid1 is smaller than zxid2
  483. then zxid1 happened before zxid2.</p>
  484. </li>
  485. <li>
  486. <p>
  487. <strong>Version numbers</strong>
  488. </p>
  489. <p>Every change to a a node will cause an increase to one of the
  490. version numbers of that node. The three version numbers are version
  491. (number of changes to the data of a znode), cversion (number of
  492. changes to the children of a znode), and aversion (number of changes
  493. to the ACL of a znode).</p>
  494. </li>
  495. <li>
  496. <p>
  497. <strong>Ticks</strong>
  498. </p>
  499. <p>When using multi-server ZooKeeper, servers use ticks to define
  500. timing of events such as status uploads, session timeouts,
  501. connection timeouts between peers, etc. The tick time is only
  502. indirectly exposed through the minimum session timeout (2 times the
  503. tick time); if a client requests a session timeout less than the
  504. minimum session timeout, the server will tell the client that the
  505. session timeout is actually the minimum session timeout.</p>
  506. </li>
  507. <li>
  508. <p>
  509. <strong>Real time</strong>
  510. </p>
  511. <p>ZooKeeper doesn't use real time, or clock time, at all except
  512. to put timestamps into the stat structure on znode creation and
  513. znode modification.</p>
  514. </li>
  515. </ul>
  516. <a name="N10133"></a><a name="sc_zkStatStructure"></a>
  517. <h3 class="h4">ZooKeeper Stat Structure</h3>
  518. <p>The Stat structure for each znode in ZooKeeper is made up of the
  519. following fields:</p>
  520. <ul>
  521. <li>
  522. <p>
  523. <strong>czxid</strong>
  524. </p>
  525. <p>The zxid of the change that caused this znode to be
  526. created.</p>
  527. </li>
  528. <li>
  529. <p>
  530. <strong>mzxid</strong>
  531. </p>
  532. <p>The zxid of the change that last modified this znode.</p>
  533. </li>
  534. <li>
  535. <p>
  536. <strong>ctime</strong>
  537. </p>
  538. <p>The time in milliseconds from epoch when this znode was
  539. created.</p>
  540. </li>
  541. <li>
  542. <p>
  543. <strong>mtime</strong>
  544. </p>
  545. <p>The time in milliseconds from epoch when this znode was last
  546. modified.</p>
  547. </li>
  548. <li>
  549. <p>
  550. <strong>version</strong>
  551. </p>
  552. <p>The number of changes to the data of this znode.</p>
  553. </li>
  554. <li>
  555. <p>
  556. <strong>cversion</strong>
  557. </p>
  558. <p>The number of changes to the children of this znode.</p>
  559. </li>
  560. <li>
  561. <p>
  562. <strong>aversion</strong>
  563. </p>
  564. <p>The number of changes to the ACL of this znode.</p>
  565. </li>
  566. <li>
  567. <p>
  568. <strong>ephemeralOwner</strong>
  569. </p>
  570. <p>The session id of the owner of this znode if the znode is an
  571. ephemeral node. If it is not an ephemeral node, it will be
  572. zero.</p>
  573. </li>
  574. <li>
  575. <p>
  576. <strong>dataLength</strong>
  577. </p>
  578. <p>The length of the data field of this znode.</p>
  579. </li>
  580. <li>
  581. <p>
  582. <strong>numChildren</strong>
  583. </p>
  584. <p>The number of children of this znode.</p>
  585. </li>
  586. </ul>
  587. </div>
  588. <a name="N101A5"></a><a name="ch_zkSessions"></a>
  589. <h2 class="h3">ZooKeeper Sessions</h2>
  590. <div class="section">
  591. <p>To create a client session the application code must provide
  592. a string containing a comma separated list of host:port pairs,
  593. each corresponding to a ZooKeeper server (e.g. "127.0.0.1:4545" or
  594. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002"). The ZooKeeper
  595. client library will pick an arbitrary server and try to connect to
  596. it. If this connection fails, or if the client becomes
  597. disconnected from the server for any reason, the client will
  598. automatically try the next server in the list, until a connection
  599. is (re-)established.</p>
  600. <p>When a client gets a handle to the ZooKeeper service,
  601. ZooKeeper creates a ZooKeeper session, represented as a 64-bit
  602. number, that it assigns to the client. If the client connects to a
  603. different ZooKeeper server, it will send the session id as a part
  604. of the connection handshake. As a security measure, the server
  605. creates a password for the session id that any ZooKeeper server
  606. can validate.The password is sent to the client with the session
  607. id when the client establishes the session. The client sends this
  608. password with the session id whenever it reestablishes the session
  609. with a new server.</p>
  610. <p>One of the parameters to the ZooKeeper client library call
  611. to create a ZooKeeper session is the session timeout in
  612. milliseconds. The client sends a requested timeout, the server
  613. responds with the timeout that it can give the client. The current
  614. implementation requires that the timeout be a minimum of 2 times
  615. the tickTime (as set in the server configuration) and a maximum of
  616. 20 times the tickTime.</p>
  617. <p>Another parameter to the ZooKeeper session establishment
  618. call is the default watcher. Watchers are notified when any state
  619. change occurs in the client. For example if the client loses
  620. connectivity to the server the client will be notified, or if the
  621. client's session expires, etc... This watcher should consider the
  622. initial state to be disconnected (i.e. before any state changes
  623. events are sent to the watcher by the client lib). In the case of
  624. a new connection, the first event sent to the watcher is typically
  625. the session connection event.</p>
  626. <p>The session is kept alive by requests sent by the client. If
  627. the session is idle for a period of time that would timeout the
  628. session, the client will send a PING request to keep the session
  629. alive. This PING request not only allows the ZooKeeper server to
  630. know that the client is still active, but it also allows the
  631. client to verify that its connection to the ZooKeeper server is
  632. still active. The timing of the PING is conservative enough to
  633. ensure reasonable time to detect a dead connection and reconnect
  634. to a new server.</p>
  635. <p>
  636. Once a connection to the server is successfully established
  637. (connected) there are basically two cases where the client lib generates
  638. connectionloss (the result code in c binding, exception in Java -- see
  639. the API documentation for binding specific details) when either a synchronous or
  640. asynchronous operation is performed and one of the following holds:
  641. </p>
  642. <ol>
  643. <li>
  644. <p>The application calls an operation on a session that is no
  645. longer alive/valid</p>
  646. </li>
  647. <li>
  648. <p>The ZooKeeper client disconnects from a server when there
  649. are pending operations to that server, i.e., there is a pending asynchronous call.
  650. </p>
  651. </li>
  652. </ol>
  653. </div>
  654. <a name="N101C9"></a><a name="ch_zkWatches"></a>
  655. <h2 class="h3">ZooKeeper Watches</h2>
  656. <div class="section">
  657. <p>All of the read operations in ZooKeeper - <strong>getData()</strong>, <strong>getChildren()</strong>, and <strong>exists()</strong> - have the option of setting a watch as a
  658. side effect. Here is ZooKeeper's definition of a watch: a watch event is
  659. one-time trigger, sent to the client that set the watch, which occurs when
  660. the data for which the watch was set changes. There are three key points
  661. to consider in this definition of a watch:</p>
  662. <ul>
  663. <li>
  664. <p>
  665. <strong>One-time trigger</strong>
  666. </p>
  667. <p>One watch event will be sent to the client the data has changed.
  668. For example, if a client does a getData("/znode1", true) and later the
  669. data for /znode1 is changed or deleted, the client will get a watch
  670. event for /znode1. If /znode1 changes again, no watch event will be
  671. sent unless the client has done another read that sets a new
  672. watch.</p>
  673. </li>
  674. <li>
  675. <p>
  676. <strong>Sent to the client</strong>
  677. </p>
  678. <p>This implies that an event is on the way to the client, but may
  679. not reach the client before the successful return code to the change
  680. operation reaches the client that initiated the change. Watches are
  681. sent asynchronously to watchers. ZooKeeper provides an ordering
  682. guarantee: a client will never see a change for which it has set a
  683. watch until it first sees the watch event. Network delays or other
  684. factors may cause different clients to see watches and return codes
  685. from updates at different times. The key point is that everything seen
  686. by the different clients will have a consistent order.</p>
  687. </li>
  688. <li>
  689. <p>
  690. <strong>The data for which the watch was
  691. set</strong>
  692. </p>
  693. <p>This refers to the different ways a node can change. It
  694. helps to think of ZooKeeper as maintaining two lists of
  695. watches: data watches and child watches. getData() and
  696. exists() set data watches. getChildren() sets child
  697. watches. Alternatively, it may help to think of watches being
  698. set according to the kind of data returned. getData() and
  699. exists() return information about the data of the node,
  700. whereas getChildren() returns a list of children. Thus,
  701. setData() will trigger data watches for the znode being set
  702. (assuming the set is successful). A successful create() will
  703. trigger a data watch for the znode being created and a child
  704. watch for the parent znode. A successful delete() will trigger
  705. both a data watch and a child watch (since there can be no
  706. more children) for a znode being deleted as well as a child
  707. watch for the parent znode.</p>
  708. </li>
  709. </ul>
  710. <p>Watches are maintained locally at the ZooKeeper server to which the
  711. client is connected. This allows watches to be light weight to set,
  712. maintain, and dispatch. When a client connects to a new server, the watch
  713. will be triggered for any session events. Watches will not be received
  714. while disconnected from a server. When a client reconnects, any previously
  715. registered watches will be reregistered and triggered if needed. In
  716. general this all occurs transparently. There is one case where a watch
  717. may be missed: a watch for the existance of a znode not yet created will
  718. be missed if the znode is created and deleted while disconnected.</p>
  719. <a name="N101FF"></a><a name="sc_WatchGuarantees"></a>
  720. <h3 class="h4">What ZooKeeper Guarantees about Watches</h3>
  721. <p>With regard to watches, ZooKeeper maintains these
  722. guarantees:</p>
  723. <ul>
  724. <li>
  725. <p>Watches are ordered with respect to other events, other
  726. watches, and asynchronous replies. The ZooKeeper client libraries
  727. ensures that everything is dispatched in order.</p>
  728. </li>
  729. </ul>
  730. <ul>
  731. <li>
  732. <p>A client will see a watch event for a znode it is watching
  733. before seeing the new data that corresponds to that znode.</p>
  734. </li>
  735. </ul>
  736. <ul>
  737. <li>
  738. <p>The order of watch events from ZooKeeper corresponds to the
  739. order of the updates as seen by the ZooKeeper service.</p>
  740. </li>
  741. </ul>
  742. <a name="N10224"></a><a name="sc_WatchRememberThese"></a>
  743. <h3 class="h4">Things to Remember about Watches</h3>
  744. <ul>
  745. <li>
  746. <p>Watches are one time triggers; if you get a watch event and
  747. you want to get notified of future changes, you must set another
  748. watch.</p>
  749. </li>
  750. </ul>
  751. <ul>
  752. <li>
  753. <p>Because watches are one time triggers and there is latency
  754. between getting the event and sending a new request to get a watch
  755. you cannot reliably see every change that happens to a node in
  756. ZooKeeper. Be prepared to handle the case where the znode changes
  757. multiple times between getting the event and setting the watch
  758. again. (You may not care, but at least realize it may
  759. happen.)</p>
  760. </li>
  761. </ul>
  762. <ul>
  763. <li>
  764. <p>A watch object, or function/context pair, will only be
  765. triggered once for a given notification. For example, if the same
  766. watch object is registered for an exists and a getData call for the
  767. same file and that file is then deleted, the watch object would
  768. only be invoked once with the deletion notification for the file.
  769. </p>
  770. </li>
  771. </ul>
  772. <ul>
  773. <li>
  774. <p>When you disconnect from a server (for example, when the
  775. server fails), you will not get any watches until the connection
  776. is reestablished. For this reason session events are sent to all
  777. outstanding watch handlers. Use session events to go into a safe
  778. mode: you will not be receiving events while disconnected, so your
  779. process should act conservatively in that mode.</p>
  780. </li>
  781. </ul>
  782. </div>
  783. <a name="N10250"></a><a name="sc_ZooKeeperAccessControl"></a>
  784. <h2 class="h3">ZooKeeper access control using ACLs</h2>
  785. <div class="section">
  786. <p>ZooKeeper uses ACLs to control access to its znodes (the
  787. data nodes of a ZooKeeper data tree). The ACL implementation is
  788. quite similar to UNIX file access permissions: it employs
  789. permission bits to allow/disallow various operations against a
  790. node and the scope to which the bits apply. Unlike standard UNIX
  791. permissions, a ZooKeeper node is not limited by the three standard
  792. scopes for user (owner of the file), group, and world
  793. (other). ZooKeeper does not have a notion of an owner of a
  794. znode. Instead, an ACL specifies sets of ids and permissions that
  795. are associated with those ids.</p>
  796. <p>ZooKeeper supports pluggable authentication schemes. Ids are
  797. specified using the form <em>scheme:id</em>,
  798. where <em>scheme</em> is a the authentication scheme
  799. that the id corresponds to. For
  800. example, <em>host:host1.corp.com</em> is an id for a
  801. host named <em>host1.corp.com</em>.</p>
  802. <p>When a client connects to ZooKeeper and authenticates
  803. itself, ZooKeeper associates all the ids that correspond to a
  804. client with the clients connection. These ids are checked against
  805. the ACLs of znodes when a clients tries to access a node. ACLs are
  806. made up of pairs of <em>(scheme:expression,
  807. perms)</em>. The format of
  808. the <em>expression</em> is specific to the scheme. For
  809. example, the pair <em>(ip:19.22.0.0/16, READ)</em>
  810. gives the <em>READ</em> permission to any clients with
  811. an IP address that starts with 19.22.</p>
  812. <a name="N10277"></a><a name="sc_ACLPermissions"></a>
  813. <h3 class="h4">ACL Permissions</h3>
  814. <p>ZooKeeper supports the following permissions:</p>
  815. <ul>
  816. <li>
  817. <p>
  818. <strong>CREATE</strong>: you can create a child node</p>
  819. </li>
  820. <li>
  821. <p>
  822. <strong>READ</strong>: you can get data from a node and list its children.</p>
  823. </li>
  824. <li>
  825. <p>
  826. <strong>WRITE</strong>: you can set data for a node</p>
  827. </li>
  828. <li>
  829. <p>
  830. <strong>DELETE</strong>: you can delete a child node</p>
  831. </li>
  832. <li>
  833. <p>
  834. <strong>ADMIN</strong>: you can set permissions</p>
  835. </li>
  836. </ul>
  837. <p>The <em>CREATE</em>
  838. and <em>DELETE</em> permissions have been broken out
  839. of the <em>WRITE</em> permission for finer grained
  840. access controls. The cases for <em>CREATE</em>
  841. and <em>DELETE</em> are the following:</p>
  842. <p>You want A to be able to do a set on a ZooKeeper node, but
  843. not be able to <em>CREATE</em>
  844. or <em>DELETE</em> children.</p>
  845. <p>
  846. <em>CREATE</em>
  847. without <em>DELETE</em>: clients create requests by
  848. creating ZooKeeper nodes in a parent directory. You want all
  849. clients to be able to add, but only request processor can
  850. delete. (This is kind of like the APPEND permission for
  851. files.)</p>
  852. <p>Also, the <em>ADMIN</em> permission is there
  853. since ZooKeeper doesn&rsquo;t have a notion of file owner. In some
  854. sense the <em>ADMIN</em> permission designates the
  855. entity as the owner. ZooKeeper doesn&rsquo;t support the LOOKUP
  856. permission (execute permission bit on directories to allow you
  857. to LOOKUP even though you can't list the directory). Everyone
  858. implicitly has LOOKUP permission. This allows you to stat a
  859. node, but nothing more. (The problem is, if you want to call
  860. zoo_exists() on a node that doesn't exist, there is no
  861. permission to check.)</p>
  862. <a name="N102CD"></a><a name="sc_BuiltinACLSchemes"></a>
  863. <h4>Builtin ACL Schemes</h4>
  864. <p>ZooKeeeper has the following built in schemes:</p>
  865. <ul>
  866. <li>
  867. <p>
  868. <strong>world</strong> has a
  869. single id, <em>anyone</em>, that represents
  870. anyone.</p>
  871. </li>
  872. <li>
  873. <p>
  874. <strong>auth</strong> doesn't
  875. use any id, represents any authenticated
  876. user.</p>
  877. </li>
  878. <li>
  879. <p>
  880. <strong>digest</strong> uses
  881. a <em>username:password</em> string to generate
  882. MD5 hash which is then used as an ACL ID
  883. identity. Authentication is done by sending
  884. the <em>username:password</em> in clear text. When
  885. used in the ACL the expression will be
  886. the <em>username:base64</em>
  887. encoded <em>SHA1</em>
  888. password <em>digest</em>.</p>
  889. </li>
  890. <li>
  891. <p>
  892. <strong>host</strong> uses the
  893. client host name as an ACL ID identity. The ACL expression is
  894. a hostname suffix. For example, the ACL
  895. expression <em>host:corp.com</em> matches the
  896. ids <em>host:host1.corp.com</em>
  897. and <em>host:host2.corp.com</em>, but
  898. not <em>host:host1.store.com</em>.</p>
  899. </li>
  900. <li>
  901. <p>
  902. <strong>ip</strong> uses the
  903. client host IP as an ACL ID identity. The ACL expression is of
  904. the form <em>addr/bits</em> where the most
  905. significant <em>bits</em>
  906. of <em>addr</em> are matched against the most
  907. significant <em>bits</em> of the client host
  908. IP.</p>
  909. </li>
  910. </ul>
  911. <a name="N10323"></a><a name="ZooKeeper+C+client+API"></a>
  912. <h4>ZooKeeper C client API</h4>
  913. <p>The following constants are provided by the ZooKeeper C
  914. library:</p>
  915. <ul>
  916. <li>
  917. <p>
  918. <em>const</em> <em>int</em> ZOO_PERM_READ; //can read node&rsquo;s value and list its children</p>
  919. </li>
  920. <li>
  921. <p>
  922. <em>const</em> <em>int</em> ZOO_PERM_WRITE;// can set the node&rsquo;s value</p>
  923. </li>
  924. <li>
  925. <p>
  926. <em>const</em> <em>int</em> ZOO_PERM_CREATE; //can create children</p>
  927. </li>
  928. <li>
  929. <p>
  930. <em>const</em> <em>int</em> ZOO_PERM_DELETE;// can delete children</p>
  931. </li>
  932. <li>
  933. <p>
  934. <em>const</em> <em>int</em> ZOO_PERM_ADMIN; //can execute set_acl()</p>
  935. </li>
  936. <li>
  937. <p>
  938. <em>const</em> <em>int</em> ZOO_PERM_ALL;// all of the above flags OR&rsquo;d together</p>
  939. </li>
  940. </ul>
  941. <p>The following are the standard ACL IDs:</p>
  942. <ul>
  943. <li>
  944. <p>
  945. <em>struct</em> Id ZOO_ANYONE_ID_UNSAFE; //(&lsquo;world&rsquo;,&rsquo;anyone&rsquo;)</p>
  946. </li>
  947. <li>
  948. <p>
  949. <em>struct</em> Id ZOO_AUTH_IDS;// (&lsquo;auth&rsquo;,&rsquo;&rsquo;)</p>
  950. </li>
  951. </ul>
  952. <p>ZOO_AUTH_IDS empty identity string should be interpreted as &ldquo;the identity of the creator&rdquo;.</p>
  953. <p>ZooKeeper client comes with three standard ACLs:</p>
  954. <ul>
  955. <li>
  956. <p>
  957. <em>struct</em> ACL_vector ZOO_OPEN_ACL_UNSAFE; //(ZOO_PERM_ALL,ZOO_ANYONE_ID_UNSAFE)</p>
  958. </li>
  959. <li>
  960. <p>
  961. <em>struct</em> ACL_vector ZOO_READ_ACL_UNSAFE;// (ZOO_PERM_READ, ZOO_ANYONE_ID_UNSAFE)</p>
  962. </li>
  963. <li>
  964. <p>
  965. <em>struct</em> ACL_vector ZOO_CREATOR_ALL_ACL; //(ZOO_PERM_ALL,ZOO_AUTH_IDS)</p>
  966. </li>
  967. </ul>
  968. <p>The ZOO_OPEN_ACL_UNSAFE is completely open free for all
  969. ACL: any application can execute any operation on the node and
  970. can create, list and delete its children. The
  971. ZOO_READ_ACL_UNSAFE is read-only access for any
  972. application. CREATE_ALL_ACL grants all permissions to the
  973. creator of the node. The creator must have been authenticated by
  974. the server (for example, using &ldquo;<em>digest</em>&rdquo;
  975. scheme) before it can create nodes with this ACL.</p>
  976. <p>The following ZooKeeper operations deal with ACLs:</p>
  977. <ul>
  978. <li>
  979. <p>
  980. <em>int</em> <em>zoo_add_auth</em>
  981. (zhandle_t *zh,<em>const</em> <em>char</em>*
  982. scheme,<em>const</em> <em>char</em>*
  983. cert, <em>int</em> certLen, void_completion_t
  984. completion, <em>const</em> <em>void</em>
  985. *data);</p>
  986. </li>
  987. </ul>
  988. <p>The application uses the zoo_add_auth function to
  989. authenticate itself to the server. The function can be called
  990. multiple times if the application wants to authenticate using
  991. different schemes and/or identities.</p>
  992. <ul>
  993. <li>
  994. <p>
  995. <em>int</em> <em>zoo_create</em>
  996. (zhandle_t *zh, <em>const</em> <em>char</em>
  997. *path, <em>const</em> <em>char</em>
  998. *value,<em>int</em>
  999. valuelen, <em>const</em> <em>struct</em>
  1000. ACL_vector *acl, <em>int</em>
  1001. flags,<em>char</em>
  1002. *realpath, <em>int</em>
  1003. max_realpath_len);</p>
  1004. </li>
  1005. </ul>
  1006. <p>zoo_create(...) operation creates a new node. The acl
  1007. parameter is a list of ACLs associated with the node. The parent
  1008. node must have the CREATE permission bit set.</p>
  1009. <ul>
  1010. <li>
  1011. <p>
  1012. <em>int</em> <em>zoo_get_acl</em>
  1013. (zhandle_t *zh, <em>const</em> <em>char</em>
  1014. *path,<em>struct</em> ACL_vector
  1015. *acl, <em>struct</em> Stat *stat);</p>
  1016. </li>
  1017. </ul>
  1018. <p>This operation returns a node&rsquo;s ACL info.</p>
  1019. <ul>
  1020. <li>
  1021. <p>
  1022. <em>int</em> <em>zoo_set_acl</em>
  1023. (zhandle_t *zh, <em>const</em> <em>char</em>
  1024. *path, <em>int</em>
  1025. version,<em>const</em> <em>struct</em>
  1026. ACL_vector *acl);</p>
  1027. </li>
  1028. </ul>
  1029. <p>This function replaces node&rsquo;s ACL list with a new one. The
  1030. node must have the ADMIN permission set.</p>
  1031. <p>Here is a sample code that makes use of the above APIs to
  1032. authenticate itself using the &ldquo;<em>foo</em>&rdquo; scheme
  1033. and create an ephemeral node &ldquo;/xyz&rdquo; with create-only
  1034. permissions.</p>
  1035. <div class="note">
  1036. <div class="label">Note</div>
  1037. <div class="content">
  1038. <p>This is a very simple example which is intended to show
  1039. how to interact with ZooKeeper ACLs
  1040. specifically. See <span class="codefrag filename">.../trunk/src/c/src/cli.c</span>
  1041. for an example of a proper C client implementation</p>
  1042. </div>
  1043. </div>
  1044. <pre class="code">
  1045. #include &lt;string.h&gt;
  1046. #include &lt;errno.h&gt;
  1047. #include "zookeeper.h"
  1048. static zhandle_t *zh;
  1049. /**
  1050. * In this example this method gets the cert for your
  1051. * environment -- you must provide
  1052. */
  1053. char *foo_get_cert_once(char* id) { return 0; }
  1054. /** Watcher function -- empty for this example, not something you should
  1055. * do in real code */
  1056. void watcher(zhandle_t *zzh, int type, int state, const char *path,
  1057. void *watcherCtx) {}
  1058. int main(int argc, char argv) {
  1059. char buffer[512];
  1060. char p[2048];
  1061. char *cert=0;
  1062. char appId[64];
  1063. strcpy(appId, "example.foo_test");
  1064. cert = foo_get_cert_once(appId);
  1065. if(cert!=0) {
  1066. fprintf(stderr,
  1067. "Certificate for appid [%s] is [%s]\n",appId,cert);
  1068. strncpy(p,cert, sizeof(p)-1);
  1069. free(cert);
  1070. } else {
  1071. fprintf(stderr, "Certificate for appid [%s] not found\n",appId);
  1072. strcpy(p, "dummy");
  1073. }
  1074. zoo_set_debug_level(ZOO_LOG_LEVEL_DEBUG);
  1075. zh = zookeeper_init("localhost:3181", watcher, 10000, 0, 0, 0);
  1076. if (!zh) {
  1077. return errno;
  1078. }
  1079. if(zoo_add_auth(zh,"foo",p,strlen(p),0,0)!=ZOK)
  1080. return 2;
  1081. struct ACL CREATE_ONLY_ACL[] = {{ZOO_PERM_CREATE, ZOO_AUTH_IDS}};
  1082. struct ACL_vector CREATE_ONLY = {1, CREATE_ONLY_ACL};
  1083. int rc = zoo_create(zh,"/xyz","value", 5, &amp;CREATE_ONLY, ZOO_EPHEMERAL,
  1084. buffer, sizeof(buffer)-1);
  1085. /** this operation will fail with a ZNOAUTH error */
  1086. int buflen= sizeof(buffer);
  1087. struct Stat stat;
  1088. rc = zoo_get(zh, "/xyz", 0, buffer, &amp;buflen, &amp;stat);
  1089. if (rc) {
  1090. fprintf(stderr, "Error %d for %s\n", rc, __LINE__);
  1091. }
  1092. zookeeper_close(zh);
  1093. return 0;
  1094. }
  1095. </pre>
  1096. </div>
  1097. <a name="N1043A"></a><a name="ch_zkGuarantees"></a>
  1098. <h2 class="h3">Consistency Guarantees</h2>
  1099. <div class="section">
  1100. <p>ZooKeeper is a high performance, scalable service. Both reads and
  1101. write operations are designed to be fast, though reads are faster than
  1102. writes. The reason for this is that in the case of reads, ZooKeeper can
  1103. serve older data, which in turn is due to ZooKeeper's consistency
  1104. guarantees:</p>
  1105. <dl>
  1106. <dt>
  1107. <term>Sequential Consistency</term>
  1108. </dt>
  1109. <dd>
  1110. <p>Updates from a client will be applied in the order that they
  1111. were sent.</p>
  1112. </dd>
  1113. <dt>
  1114. <term>Atomicity</term>
  1115. </dt>
  1116. <dd>
  1117. <p>Updates either succeed or fail -- there are no partial
  1118. results.</p>
  1119. </dd>
  1120. <dt>
  1121. <term>Single System Image</term>
  1122. </dt>
  1123. <dd>
  1124. <p>A client will see the same view of the service regardless of
  1125. the server that it connects to.</p>
  1126. </dd>
  1127. <dt>
  1128. <term>Reliability</term>
  1129. </dt>
  1130. <dd>
  1131. <p>Once an update has been applied, it will persist from that
  1132. time forward until a client overwrites the update. This guarantee
  1133. has two corollaries:</p>
  1134. <ol>
  1135. <li>
  1136. <p>If a client gets a successful return code, the update will
  1137. have been applied. On some failures (communication errors,
  1138. timeouts, etc) the client will not know if the update has
  1139. applied or not. We take steps to minimize the failures, but the
  1140. only guarantee is only present with successful return codes.
  1141. (This is called the <em>monotonicity condition</em> in Paxos.)</p>
  1142. </li>
  1143. <li>
  1144. <p>Any updates that are seen by the client, through a read
  1145. request or successful update, will never be rolled back when
  1146. recovering from server failures.</p>
  1147. </li>
  1148. </ol>
  1149. </dd>
  1150. <dt>
  1151. <term>Timeliness</term>
  1152. </dt>
  1153. <dd>
  1154. <p>The clients view of the system is guaranteed to be up-to-date
  1155. within a certain time bound. (On the order of tens of seconds.)
  1156. Either system changes will be seen by a client within this bound, or
  1157. the client will detect a service outage.</p>
  1158. </dd>
  1159. </dl>
  1160. <p>Using these consistency guarantees it is easy to build higher level
  1161. functions such as leader election, barriers, queues, and read/write
  1162. revocable locks solely at the ZooKeeper client (no additions needed to
  1163. ZooKeeper). See <a href="recipes.html">Recipes and Solutions</a>
  1164. for more details.</p>
  1165. <div class="note">
  1166. <div class="label">Note</div>
  1167. <div class="content">
  1168. <p>Sometimes developers mistakenly assume one other guarantee that
  1169. ZooKeeper does <em>not</em> in fact make. This is:</p>
  1170. <dl>
  1171. <dt>
  1172. <term>Simultaneously Conistent Cross-Client Views</term>
  1173. </dt>
  1174. <dd>
  1175. <p>ZooKeeper does not guarantee that at every instance in
  1176. time, two different clients will have identical views of
  1177. ZooKeeper data. Due to factors like network delays, one client
  1178. may perform an update before another client gets notified of the
  1179. change. Consider the scenario of two clients, A and B. If client
  1180. A sets the value of a znode /a from 0 to 1, then tells client B
  1181. to read /a, client B may read the old value of 0, depending on
  1182. which server it is connected to. If it
  1183. is important that Client A and Client B read the same value,
  1184. Client B should should call the <strong>sync()</strong> method from the ZooKeeper API
  1185. method before it performs its read.</p>
  1186. <p>So, ZooKeeper by itself doesn't guarantee that changes occur
  1187. synchronously across all servers, but ZooKeeper
  1188. primitives can be used to construct higher level functions that
  1189. provide useful client synchronization. (For more information,
  1190. see the <a href="recipes.html">ZooKeeper Recipes</a>.
  1191. <em>[tbd:..]</em>).</p>
  1192. </dd>
  1193. </dl>
  1194. </div>
  1195. </div>
  1196. </div>
  1197. <a name="N104A1"></a><a name="ch_bindings"></a>
  1198. <h2 class="h3">Bindings</h2>
  1199. <div class="section">
  1200. <p>The ZooKeeper client libraries come in two languages: Java and C.
  1201. The following sections describe these.</p>
  1202. <a name="N104AA"></a><a name="Java+Binding"></a>
  1203. <h3 class="h4">Java Binding</h3>
  1204. <p>There are two packages that make up the ZooKeeper Java binding:
  1205. <strong>org.apache.zookeeper</strong> and <strong>org.apache.zookeeper.data</strong>. The rest of the
  1206. packages that make up ZooKeeper are used internally or are part of the
  1207. server implementation. The <strong>org.apache.zookeeper.data</strong> package is made up of
  1208. generated classes that are used simply as containers.</p>
  1209. <p>The main class used by a ZooKeeper Java client is the <strong>ZooKeeper</strong> class. Its two constructors differ only
  1210. by an optional session id and password. ZooKeeper supports session
  1211. recovery accross instances of a process. A Java program may save its
  1212. session id and password to stable storage, restart, and recover the
  1213. session that was used by the earlier instance of the program.</p>
  1214. <p>When a ZooKeeper object is created, two threads are created as
  1215. well: an IO thread and an event thread. All IO happens on the IO thread
  1216. (using Java NIO). All event callbacks happen on the event thread.
  1217. Session maintenance such as reconnecting to ZooKeeper servers and
  1218. maintaining heartbeat is done on the IO thread. Responses for
  1219. synchronous methods are also processed in the IO thread. All responses
  1220. to asynchronous methods and watch events are processed on the event
  1221. thread. There are a few things to notice that result from this
  1222. design:</p>
  1223. <ul>
  1224. <li>
  1225. <p>All completions for asynchronous calls and watcher callbacks
  1226. will be made in order, one at a time. The caller can do any
  1227. processing they wish, but no other callbacks will be processed
  1228. during that time.</p>
  1229. </li>
  1230. <li>
  1231. <p>Callbacks do not block the processing of the IO thread or the
  1232. processing of the synchronous calls.</p>
  1233. </li>
  1234. <li>
  1235. <p>Synchronous calls may not return in the correct order. For
  1236. example, assume a client does the following processing: issues an
  1237. asynchronous read of node <strong>/a</strong> with
  1238. <em>watch</em> set to true, and then in the completion
  1239. callback of the read it does a synchronous read of <strong>/a</strong>. (Maybe not good practice, but not illegal
  1240. either, and it makes for a simple example.)</p>
  1241. <p>Note that if there is a change to <strong>/a</strong> between the asynchronous read and the
  1242. synchronous read, the client library will receive the watch event
  1243. saying <strong>/a</strong> changed before the
  1244. response for the synchronous read, but because the completion
  1245. callback is blocking the event queue, the synchronous read will
  1246. return with the new value of <strong>/a</strong>
  1247. before the watch event is processed.</p>
  1248. </li>
  1249. </ul>
  1250. <p>Finally, the rules associated with shutdown are straightforward:
  1251. once a ZooKeeper object is closed or receives a fatal event
  1252. (SESSION_EXPIRED and AUTH_FAILED), the ZooKeeper object becomes invalid,
  1253. the two threads shut down, and any further ZooKeeper calls throw
  1254. errors.</p>
  1255. <a name="N104F3"></a><a name="C+Binding"></a>
  1256. <h3 class="h4">C Binding</h3>
  1257. <p>The C binding has a single-threaded and multi-threaded library.
  1258. The multi-threaded library is easiest to use and is most similar to the
  1259. Java API. This library will create an IO thread and an event dispatch
  1260. thread for handling connection maintenance and callbacks. The
  1261. single-threaded library allows ZooKeeper to be used in event driven
  1262. applications by exposing the event loop used in the multi-threaded
  1263. library.</p>
  1264. <p>The package includes two shared libraries: zookeeper_st and
  1265. zookeeper_mt. The former only provides the asynchronous APIs and
  1266. callbacks for integrating into the application's event loop. The only
  1267. reason this library exists is to support the platforms were a
  1268. <em>pthread</em> library is not available or is unstable
  1269. (i.e. FreeBSD 4.x). In all other cases, application developers should
  1270. link with zookeeper_mt, as it includes support for both Sync and Async
  1271. API.</p>
  1272. <a name="N10502"></a><a name="Installation"></a>
  1273. <h4>Installation</h4>
  1274. <p>If you're building the client from a check-out from the Apache
  1275. repository, follow the steps outlined below. If you're building from a
  1276. project source package downloaded from apache, skip to step <strong>3</strong>.</p>
  1277. <ol>
  1278. <li>
  1279. <p>Run <span class="codefrag command">ant compile_jute</span> from the ZooKeeper
  1280. top level directory (<span class="codefrag filename">.../trunk</span>).
  1281. This will create a directory named "generated" under
  1282. <span class="codefrag filename">.../trunk/src/c</span>.</p>
  1283. </li>
  1284. <li>
  1285. <p>Change directory to the<span class="codefrag filename">.../trunk/src/c</span>
  1286. and run <span class="codefrag command">autoreconf -if</span> to bootstrap <strong>autoconf</strong>, <strong>automake</strong> and <strong>libtool</strong>. Make sure you have <strong>autoconf version 2.59</strong> or greater installed.
  1287. Skip to step<strong> 4</strong>.</p>
  1288. </li>
  1289. <li>
  1290. <p>If you are building from a project source package,
  1291. unzip/untar the source tarball and cd to the<span class="codefrag filename">
  1292. zookeeper-x.x.x/src/c</span> directory.</p>
  1293. </li>
  1294. <li>
  1295. <p>Run <span class="codefrag command">./configure &lt;your-options&gt;</span> to
  1296. generate the makefile. Here are some of options the <strong>configure</strong> utility supports that can be
  1297. useful in this step:</p>
  1298. <ul>
  1299. <li>
  1300. <p>
  1301. <span class="codefrag command">--enable-debug</span>
  1302. </p>
  1303. <p>Enables optimization and enables debug info compiler
  1304. options. (Disabled by default.)</p>
  1305. </li>
  1306. <li>
  1307. <p>
  1308. <span class="codefrag command">--without-syncapi </span>
  1309. </p>
  1310. <p>Disables Sync API support; zookeeper_mt library won't be
  1311. built. (Enabled by default.)</p>
  1312. </li>
  1313. <li>
  1314. <p>
  1315. <span class="codefrag command">--disable-static </span>
  1316. </p>
  1317. <p>Do not build static libraries. (Enabled by
  1318. default.)</p>
  1319. </li>
  1320. <li>
  1321. <p>
  1322. <span class="codefrag command">--disable-shared</span>
  1323. </p>
  1324. <p>Do not build shared libraries. (Enabled by
  1325. default.)</p>
  1326. </li>
  1327. </ul>
  1328. <div class="note">
  1329. <div class="label">Note</div>
  1330. <div class="content">
  1331. <p>See INSTALL for general information about running
  1332. <strong>configure</strong>.</p>
  1333. </div>
  1334. </div>
  1335. </li>
  1336. <li>
  1337. <p>Run <span class="codefrag command">make</span> or <span class="codefrag command">make
  1338. install</span> to build the libraries and install them.</p>
  1339. </li>
  1340. <li>
  1341. <p>To generate doxygen documentation for the ZooKeeper API, run
  1342. <span class="codefrag command">make doxygen-doc</span>. All documentation will be
  1343. placed in a new subfolder named docs. By default, this command
  1344. only generates HTML. For information on other document formats,
  1345. run <span class="codefrag command">./configure --help</span>
  1346. </p>
  1347. </li>
  1348. </ol>
  1349. <a name="N105AB"></a><a name="Using+the+C+Client"></a>
  1350. <h4>Using the C Client</h4>
  1351. <p>You can test your client by running a ZooKeeper server (see
  1352. instructions on the project wiki page on how to run it) and connecting
  1353. to it using one of the cli applications that were built as part of the
  1354. installation procedure. cli_mt (multithreaded, built against
  1355. zookeeper_mt library) is shown in this example, but you could also use
  1356. cli_st (singlethreaded, built against zookeeper_st library):</p>
  1357. <p>
  1358. <span class="codefrag command">$ cli_mt zookeeper_host:9876</span>
  1359. </p>
  1360. <p>This is a client application that gives you a shell for
  1361. executing simple ZooKeeper commands. Once successfully started
  1362. and connected to the server it displays a shell prompt. You
  1363. can now enter ZooKeeper commands. For example, to create a
  1364. node:</p>
  1365. <p>
  1366. <span class="codefrag command">&gt; create /my_new_node</span>
  1367. </p>
  1368. <p>To verify that the node's been created:</p>
  1369. <p>
  1370. <span class="codefrag command">&gt; ls /</span>
  1371. </p>
  1372. <p>You should see a list of node who are children of the root node
  1373. "/".</p>
  1374. <p>In order to be able to use the ZooKeeper API in your application
  1375. you have to remember to</p>
  1376. <ol>
  1377. <li>
  1378. <p>Include ZooKeeper header: #include
  1379. &lt;zookeeper/zookeeper.h</p>
  1380. </li>
  1381. <li>
  1382. <p>If you are building a multithreaded client, compile with
  1383. -DTHREADED compiler flag to enable the multi-threaded version of
  1384. the library, and then link against against the
  1385. <em>zookeeper_mt</em> library. If you are building a
  1386. single-threaded client, do not compile with -DTHREADED, and be
  1387. sure to link against the<em> zookeeper_st
  1388. </em>library.</p>
  1389. </li>
  1390. </ol>
  1391. <p>Refer to <a href="#ch_programStructureWithExample">Program Structure, with Simple Example</a>
  1392. for examples of usage in Java and C.
  1393. <em>[tbd]</em>
  1394. </p>
  1395. </div>
  1396. <a name="N105F1"></a><a name="ch_guideToZkOperations"></a>
  1397. <h2 class="h3">Building Blocks: A Guide to ZooKeeper Operations</h2>
  1398. <div class="section">
  1399. <p>This section surveys all the operations a developer can perform
  1400. against a ZooKeeper server. It is lower level information than the earlier
  1401. concepts chapters in this manual, but higher level than the ZooKeeper API
  1402. Reference. It covers these topics:</p>
  1403. <ul>
  1404. <li>
  1405. <p>
  1406. <a href="#sc_connectingToZk">Connecting to ZooKeeper</a>
  1407. </p>
  1408. </li>
  1409. </ul>
  1410. <a name="N10605"></a><a name="sc_errorsZk"></a>
  1411. <h3 class="h4">Handling Errors</h3>
  1412. <p>Both the Java and C client bindings may report errors. The Java client binding does so by throwing KeeperException, calling code() on the exception will return the specific error code. The C client binding returns an error code as defined in the enum ZOO_ERRORS. API callbacks indicate result code for both language bindings. See the API documentation (javadoc for Java, doxygen for C) for full details on the possible errors and their meaning.</p>
  1413. <a name="N1060F"></a><a name="sc_connectingToZk"></a>
  1414. <h3 class="h4">Connecting to ZooKeeper</h3>
  1415. <p></p>
  1416. <a name="N10618"></a><a name="sc_readOps"></a>
  1417. <h3 class="h4">Read Operations</h3>
  1418. <p></p>
  1419. <a name="N10621"></a><a name="sc_writeOps"></a>
  1420. <h3 class="h4">Write Operations</h3>
  1421. <p></p>
  1422. <a name="N1062A"></a><a name="sc_handlingWatches"></a>
  1423. <h3 class="h4">Handling Watches</h3>
  1424. <p></p>
  1425. <a name="N10633"></a><a name="sc_miscOps"></a>
  1426. <h3 class="h4">Miscelleaneous ZooKeeper Operations</h3>
  1427. <p></p>
  1428. </div>
  1429. <a name="N1063D"></a><a name="ch_programStructureWithExample"></a>
  1430. <h2 class="h3">Program Structure, with Simple Example</h2>
  1431. <div class="section">
  1432. <p>
  1433. <em>[tbd]</em>
  1434. </p>
  1435. </div>
  1436. <a name="N10648"></a><a name="ch_gotchas"></a>
  1437. <h2 class="h3">Gotchas: Common Problems and Troubleshooting</h2>
  1438. <div class="section">
  1439. <p>So now you know ZooKeeper. It's fast, simple, your application
  1440. works, but wait ... something's wrong. Here are some pitfalls that
  1441. ZooKeeper users fall into:</p>
  1442. <ol>
  1443. <li>
  1444. <p>If you are using watches, you must look for the connected watch
  1445. event. When a ZooKeeper client disconnects from a server, you will
  1446. not receive notification of changes until reconnected. If you are
  1447. watching for a znode to come into existance, you will miss the event
  1448. if the znode is created and deleted while you are disconnected.</p>
  1449. </li>
  1450. <li>
  1451. <p>You must test ZooKeeper server failures. The ZooKeeper service
  1452. can survive failures as long as a majority of servers are active. The
  1453. question to ask is: can your application handle it? In the real world
  1454. a client's connection to ZooKeeper can break. (ZooKeeper server
  1455. failures and network partitions are common reasons for connection
  1456. loss.) The ZooKeeper client library takes care of recovering your
  1457. connection and letting you know what happened, but you must make sure
  1458. that you recover your state and any outstanding requests that failed.
  1459. Find out if you got it right in the test lab, not in production - test
  1460. with a ZooKeeper service made up of a several of servers and subject
  1461. them to reboots.</p>
  1462. </li>
  1463. <li>
  1464. <p>The list of ZooKeeper servers used by the client must match the
  1465. list of ZooKeeper servers that each ZooKeeper server has. Things can
  1466. work, although not optimally, if the client list is a subset of the
  1467. real list of ZooKeeper servers, but not if the client lists ZooKeeper
  1468. servers not in the ZooKeeper cluster.</p>
  1469. </li>
  1470. <li>
  1471. <p>Be careful where you put that transaction log. The most
  1472. performance-critical part of ZooKeeper is the transaction log.
  1473. ZooKeeper must sync transactions to media before it returns a
  1474. response. A dedicated transaction log device is key to consistent good
  1475. performance. Putting the log on a busy device will adversely effect
  1476. performance. If you only have one storage device, put trace files on
  1477. NFS and increase the snapshotCount; it doesn't eliminate the problem,
  1478. but it can mitigate it.</p>
  1479. </li>
  1480. <li>
  1481. <p>Set your Java max heap size correctly. It is very important to
  1482. <em>avoid swapping.</em> Going to disk unnecessarily will
  1483. almost certainly degrade your performance unacceptably. Remember, in
  1484. ZooKeeper, everything is ordered, so if one request hits the disk, all
  1485. other queued requests hit the disk.</p>
  1486. <p>To avoid swapping, try to set the heapsize to the amount of
  1487. physical memory you have, minus the amount needed by the OS and cache.
  1488. The best way to determine an optimal heap size for your configurations
  1489. is to <em>run load tests</em>. If for some reason you
  1490. can't, be conservative in your estimates and choose a number well
  1491. below the limit that would cause your machine to swap. For example, on
  1492. a 4G machine, a 3G heap is a conservative estimate to start
  1493. with.</p>
  1494. </li>
  1495. </ol>
  1496. </div>
  1497. <a name="apx_linksToOtherInfo"></a>
  1498. <appendix id="apx_linksToOtherInfo">
  1499. <title>Links to Other Information</title>
  1500. <p>Outside the formal documentation, there're several other sources of
  1501. information for ZooKeeper developers.</p>
  1502. <dl>
  1503. <dt>
  1504. <term>ZooKeeper Whitepaper <em>[tbd: find url]</em>
  1505. </term>
  1506. </dt>
  1507. <dd>
  1508. <p>The definitive discussion of ZooKeeper design and performance,
  1509. by Yahoo! Research</p>
  1510. </dd>
  1511. <dt>
  1512. <term>API Reference <em>[tbd: find url]</em>
  1513. </term>
  1514. </dt>
  1515. <dd>
  1516. <p>The complete reference to the ZooKeeper API</p>
  1517. </dd>
  1518. <dt>
  1519. <term>
  1520. <a href="http://us.dl1.yimg.com/download.yahoo.com/dl/ydn/zookeeper.m4v">ZooKeeper
  1521. Talk at the Hadoup Summit 2008</a>
  1522. </term>
  1523. </dt>
  1524. <dd>
  1525. <p>A video introduction to ZooKeeper, by Benjamin Reed of Yahoo!
  1526. Research</p>
  1527. </dd>
  1528. <dt>
  1529. <term>
  1530. <a href="http://wiki.apache.org/hadoop/ZooKeeper/Tutorial">Barrier and
  1531. Queue Tutorial</a>
  1532. </term>
  1533. </dt>
  1534. <dd>
  1535. <p>The excellent Java tutorial by Flavio Junqueira, implementing
  1536. simple barriers and producer-consumer queues using ZooKeeper.</p>
  1537. </dd>
  1538. <dt>
  1539. <term>
  1540. <a href="http://wiki.apache.org/hadoop/ZooKeeper/ZooKeeperArticles">ZooKeeper
  1541. - A Reliable, Scalable Distributed Coordination System</a>
  1542. </term>
  1543. </dt>
  1544. <dd>
  1545. <p>An article by Todd Hoff (07/15/2008)</p>
  1546. </dd>
  1547. <dt>
  1548. <term>
  1549. <a href="recipes.html">ZooKeeper Recipes</a>
  1550. </term>
  1551. </dt>
  1552. <dd>
  1553. <p>Pseudo-level discussion of the implementation of various
  1554. synchronization solutions with ZooKeeper: Event Handles, Queues,
  1555. Locks, and Two-phase Commits.</p>
  1556. </dd>
  1557. <dt>
  1558. <term>
  1559. <em>[tbd]</em>
  1560. </term>
  1561. </dt>
  1562. <dd>
  1563. <p>Any other good sources anyone can think of...</p>
  1564. </dd>
  1565. </dl>
  1566. </appendix>
  1567. <p align="right">
  1568. <font size="-2"></font>
  1569. </p>
  1570. </div>
  1571. <!--+
  1572. |end content
  1573. +-->
  1574. <div class="clearboth">&nbsp;</div>
  1575. </div>
  1576. <div id="footer">
  1577. <!--+
  1578. |start bottomstrip
  1579. +-->
  1580. <div class="lastmodified">
  1581. <script type="text/javascript"><!--
  1582. document.write("Last Published: " + document.lastModified);
  1583. // --></script>
  1584. </div>
  1585. <div class="copyright">
  1586. Copyright &copy;
  1587. 2008 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  1588. </div>
  1589. <!--+
  1590. |end bottomstrip
  1591. +-->
  1592. </div>
  1593. </body>
  1594. </html>