zookeeperProgrammers.html 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539
  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></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="The Hadoop database"></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 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_selected_1.1', 'skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Documentation</div>
  105. <div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
  106. <div class="menuitem">
  107. <a href="index.html">Welcome</a>
  108. </div>
  109. <div class="menuitem">
  110. <a href="zookeeperOver.html">Zookeeper Overview</a>
  111. </div>
  112. <div class="menuitem">
  113. <a href="zookeeperStarted.html">Getting Started</a>
  114. </div>
  115. <div class="menupage">
  116. <div class="menupagetitle">Programmer's Guide</div>
  117. </div>
  118. <div class="menuitem">
  119. <a href="recipes.html">Recipes</a>
  120. </div>
  121. <div class="menuitem">
  122. <a href="zookeeperAdmin.html">Administrator's Guide</a>
  123. </div>
  124. <div class="menuitem">
  125. <a href="api/index.html">API Docs</a>
  126. </div>
  127. <div class="menuitem">
  128. <a href="http://wiki.apache.org/hadoop/ZooKeeper">Wiki</a>
  129. </div>
  130. <div class="menuitem">
  131. <a href="http://wiki.apache.org/hadoop/ZooKeeper/FAQ">FAQ</a>
  132. </div>
  133. <div class="menuitem">
  134. <a href="http://hadoop.apache.org/zookeeper/mailing_lists.html">Mailing Lists</a>
  135. </div>
  136. <div class="menuitem">
  137. <a href="zookeeperOtherInfo.html">Other Info</a>
  138. </div>
  139. </div>
  140. <div id="credit"></div>
  141. <div id="roundbottom">
  142. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  143. <!--+
  144. |alternative credits
  145. +-->
  146. <div id="credit2"></div>
  147. </div>
  148. <!--+
  149. |end Menu
  150. +-->
  151. <!--+
  152. |start content
  153. +-->
  154. <div id="content">
  155. <div title="Portable Document Format" class="pdflink">
  156. <a class="dida" href="zookeeperProgrammers.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  157. PDF</a>
  158. </div>
  159. <div id="minitoc-area">
  160. <ul class="minitoc">
  161. <li>
  162. <a href="#The+ZooKeeper+Data+Model">The ZooKeeper Data Model</a>
  163. <ul class="minitoc">
  164. <li>
  165. <a href="#sc_zkDataModel_znodes">ZNodes</a>
  166. <ul class="minitoc">
  167. <li>
  168. <a href="#sc_zkDataMode_watches">Watches</a>
  169. </li>
  170. <li>
  171. <a href="#Data+Access">Data Access</a>
  172. </li>
  173. <li>
  174. <a href="#Ephemeral+Nodes">Ephemeral Nodes</a>
  175. </li>
  176. <li>
  177. <a href="#Unique+Naming">Unique Naming</a>
  178. </li>
  179. </ul>
  180. </li>
  181. <li>
  182. <a href="#sc_timeInZk">Time in ZooKeeper</a>
  183. </li>
  184. <li>
  185. <a href="#sc_zkStatStructure">ZooKeeper Stat Structure</a>
  186. </li>
  187. </ul>
  188. </li>
  189. <li>
  190. <a href="#ZooKeeper+Sessions">ZooKeeper Sessions</a>
  191. </li>
  192. <li>
  193. <a href="#ZooKeeper+Watches">ZooKeeper Watches</a>
  194. <ul class="minitoc">
  195. <li>
  196. <a href="#sc_WatchGuarantees">What ZooKeeper Guarantees about Watches</a>
  197. </li>
  198. <li>
  199. <a href="#sc_WatchRememberThese">Things to Remember about Watches</a>
  200. </li>
  201. </ul>
  202. </li>
  203. <li>
  204. <a href="#Consistency+Guarantees">Consistency Guarantees</a>
  205. </li>
  206. <li>
  207. <a href="#Bindings">Bindings</a>
  208. <ul class="minitoc">
  209. <li>
  210. <a href="#Java+Binding">Java Binding</a>
  211. </li>
  212. <li>
  213. <a href="#C+Binding">C Binding</a>
  214. <ul class="minitoc">
  215. <li>
  216. <a href="#Installation">Installation</a>
  217. </li>
  218. <li>
  219. <a href="#Using+the+Client">Using the Client</a>
  220. </li>
  221. </ul>
  222. </li>
  223. </ul>
  224. </li>
  225. <li>
  226. <a href="#Building+Blocks%3A+A+Guide+to+ZooKeeper+Operations">Building Blocks: A Guide to ZooKeeper Operations</a>
  227. </li>
  228. <li>
  229. <a href="#Program+Structure%2C+with+Simple+Example">Program Structure, with Simple Example</a>
  230. </li>
  231. <li>
  232. <a href="#Gotchas%3A+Common+Problems+and+Troubleshooting">Gotchas: Common Problems and Troubleshooting</a>
  233. </li>
  234. </ul>
  235. </div>
  236. <title>ZooKeeper Programmer's Guide</title>
  237. <subtitle>Developing Distributed Applications that use ZooKeeper</subtitle>
  238. <a name="_introduction"></a>
  239. <preface id="_introduction">
  240. <title>Introduction</title>
  241. <p>This document is a guide for developers wishing to create
  242. distributed applications that take advantage of ZooKeeper's coordination
  243. services. It contains conceptual and practical information.</p>
  244. <p>The first four chapters of this guide present higher level
  245. discussions of various ZooKeeper concepts. These are necessary both for an
  246. understanding of how Zookeeper works as well how to work with it. It does
  247. not contain source code, but it does assume a familiarity with the
  248. problems associated with distributed computing. The chapters in this first
  249. group are:</p>
  250. <ul>
  251. <li>
  252. <p>
  253. <a href="#ch_zkDataModel">The ZooKeeper Data Model</a>
  254. </p>
  255. </li>
  256. <li>
  257. <p>
  258. <a href="#ch_zkSessions">ZooKeeper Sessions</a>
  259. </p>
  260. </li>
  261. <li>
  262. <p>
  263. <a href="#ch_zkWatches">ZooKeeper Watches</a>
  264. </p>
  265. </li>
  266. <li>
  267. <p>
  268. <a href="#ch_zkGuarantees">Consistency Guarantees</a>
  269. </p>
  270. </li>
  271. </ul>
  272. <p>The next four chapters of this provided practical programming
  273. information. These are:</p>
  274. <ul>
  275. <li>
  276. <p>
  277. <a href="#ch_guideToZkOperations">Building Blocks: A Guide to ZooKeeper Operations</a>
  278. </p>
  279. </li>
  280. <li>
  281. <p>
  282. <a href="#ch_bindings">Bindings</a>
  283. </p>
  284. </li>
  285. <li>
  286. <p>
  287. <a href="#ch_programStructureWithExample">Program Structure, with Simple Example</a>
  288. <remark>[tbd]</remark>
  289. </p>
  290. </li>
  291. <li>
  292. <p>
  293. <a href="#ch_gotchas">Gotchas: Common Problems and Troubleshooting</a>
  294. </p>
  295. </li>
  296. </ul>
  297. <p>The book concludes with an <a href="#apx_linksToOtherInfo">appendix</a> containing links to other
  298. useful, ZooKeeper-related information.</p>
  299. <p>Most of information in this document is written to be accessible as
  300. stand-alone reference material. However, before starting your first
  301. ZooKeeper application, you should probably at least read the chaptes on
  302. the <a href="#ch_zkDataModel">ZooKeeper Data Model</a> and <a href="#ch_guideToZkOperations">ZooKeeper Basic Operations</a>. Also,
  303. the <a href="#ch_programStructureWithExample">Simple Programmming
  304. Example</a>
  305. <remark>[tbd]</remark> is helpful for understand the basic
  306. structure of a ZooKeeper client application.</p>
  307. </preface>
  308. <a name="N1007F"></a><a name="The+ZooKeeper+Data+Model"></a>
  309. <h2 class="h3">The ZooKeeper Data Model</h2>
  310. <div class="section">
  311. <p>ZooKeeper has a hierarchal name space, much like a distributed file
  312. system. The only difference is that each node in the namespace can have
  313. data associated with it as well as children. It is like having a file
  314. system that allows a file to also be a directory. Paths to nodes are
  315. always expressed as canonical, absolute, slash-separated paths; there are
  316. no relative reference. Any unicode character can be used in a path subject
  317. to the following constraints:</p>
  318. <ul>
  319. <li>
  320. <p>The null character (\u0000) cannot be part of a path name. (This
  321. causes problems with the C binding.)</p>
  322. </li>
  323. <li>
  324. <p>The following characters can't be used because they don't
  325. display well, or render in confusing ways: \u0001 - \u0019 and \u007F
  326. - \u009F.</p>
  327. </li>
  328. <li>
  329. <p>The following characters are not allowed because <remark>[tbd:
  330. do we need reasons?]</remark> :\ud800 -uF8FFF, \uFFF0-uFFFF, \uXFFFE -
  331. \uXFFFF (where X is an digit 1 - E), \uF0000 - \uFFFFF.</p>
  332. </li>
  333. <li>
  334. <p>The "." character can be used as part of another name, but "."
  335. and ".." cannot alone make up the whole name of a path location,
  336. because ZooKeeper doesn't use relative paths. The following would be
  337. invalid: "/a/b/./c" or "/a/b/../c".</p>
  338. </li>
  339. <li>
  340. <p>The token "zookeeper" is reserved.</p>
  341. </li>
  342. </ul>
  343. <a name="N100AC"></a><a name="sc_zkDataModel_znodes"></a>
  344. <h3 class="h4">ZNodes</h3>
  345. <p>Every node in a ZooKeeper tree is refered to as a
  346. <em>znode</em>. Znodes maintain a stat structure that
  347. includes version numbers for data changes, acl changes. The stat
  348. structure also has timestamps. The version number, together with the
  349. timestamp allow ZooKeeper to validate the cache and to coordinate
  350. updates. Each time a znode's data changes, the version number increases.
  351. For instance, whenever a client retrieves data, it also receives the
  352. version of the data. And when a client performs an update or a delete,
  353. it must supply the version of the data of the znode it is changing. If
  354. the version it supplies doesn't match the actual version of the data,
  355. the update will fail. (This behavior can be overridden. For more
  356. information see... <remark>[tbd... reference here to the section
  357. describing the special version number -1]</remark>
  358. </p>
  359. <div class="note">
  360. <div class="label">Note</div>
  361. <div class="content">
  362. <p>In distributed application engineering, the word
  363. <em>node</em> can refer to a generic host machine, a
  364. server, a member of quorums, a client process, etc. In the ZooKeeper
  365. documentatin, <em>znodes</em> refer to the data nodes.
  366. <em>Servers</em> to refer to machines that make up the
  367. ZooKeeper service; <em>quorum peers</em> refer to the
  368. servers that make up a quorum; client refers to any host or process
  369. which uses a ZooKeeper service.</p>
  370. </div>
  371. </div>
  372. <p>Znodes are the main enitity that a programmer access. They have
  373. several characteristics that are worth mentioning here.</p>
  374. <a name="N100CF"></a><a name="sc_zkDataMode_watches"></a>
  375. <h4>Watches</h4>
  376. <p>Clients can set watches on znodes. Changes to that znode trigger
  377. the watch and then clear the watch. When a watch triggers, ZooKeeper
  378. sends the client a notification. More information about watches can be
  379. found in the section
  380. <a href="#ch_zkWatches">Zookeeper Watches</a>.
  381. <remark>[tbd: fix this link] [tbd: Ben there is note from to emphasize
  382. that "it is queued". What is "it" and is what we have here
  383. sufficient?]</remark>
  384. </p>
  385. <a name="N100DF"></a><a name="Data+Access"></a>
  386. <h4>Data Access</h4>
  387. <p>The data stored at each znode in a namespace is read and written
  388. atomically. Reads get all the data bytes associated with a znode and a
  389. write replaces all the data. Each node has an Access Control List
  390. (ACL) that restricts who can do what.</p>
  391. <a name="N100E9"></a><a name="Ephemeral+Nodes"></a>
  392. <h4>Ephemeral Nodes</h4>
  393. <p>ZooKeeper also has the notion of ephemeral nodes. These znodes
  394. exists as long as the session that created the znode is active. When
  395. the session ends the znode is deleted. Because of this behavior
  396. ephemeral znodes are not allowed to have children.</p>
  397. <a name="N100F3"></a><a name="Unique+Naming"></a>
  398. <h4>Unique Naming</h4>
  399. <p>Finally you create a znode, you can request that ZooKeeper
  400. append a monotonicly increasing counter be appended to the path name
  401. of the znode to be requested. This counter is unique to the parent
  402. znode.</p>
  403. <a name="N100FE"></a><a name="sc_timeInZk"></a>
  404. <h3 class="h4">Time in ZooKeeper</h3>
  405. <p>ZooKeeper tracks time multiple ways:</p>
  406. <ul>
  407. <li>
  408. <p>
  409. <strong>Zxid</strong>
  410. </p>
  411. <p>Every change to the ZooKeeper state receives a stamp in the
  412. form of a <em>zxid</em> (ZooKeeper Transaction Id).
  413. This exposes the total ordering of all changes to ZooKeeper. Each
  414. change will have a unique zxid and if zxid1 is smaller than zxid2
  415. then zxid1 happened before zxid2.</p>
  416. </li>
  417. <li>
  418. <p>
  419. <strong>Version numbers</strong>
  420. </p>
  421. <p>Every change to a a node will cause an increase to one of the
  422. version numbers of that node. The three version numbers are version
  423. (number of changes to the data of a znode), cversion (number of
  424. changes to the children of a znode), and aversion (number of changes
  425. to the ACL of a znode).</p>
  426. </li>
  427. <li>
  428. <p>
  429. <strong>Ticks</strong>
  430. </p>
  431. <p>When using multi-server ZooKeeper, servers use ticks to define
  432. timing of events such as status uploads, session timeouts,
  433. connection timeouts between peers, etc. The tick time is only
  434. indirectly exposed through the minimum session timeout (2 times the
  435. tick time); if a client requests a session timeout less than the
  436. minimum session timeout, the server will tell the client that the
  437. session timeout is actually the minimum session timeout.</p>
  438. </li>
  439. <li>
  440. <p>
  441. <strong>Real time</strong>
  442. </p>
  443. <p>ZooKeeper doesn't use real time, or clock time, at all except
  444. to put timestamps into the stat structure on znode creation and
  445. znode modification.</p>
  446. </li>
  447. </ul>
  448. <a name="N10136"></a><a name="sc_zkStatStructure"></a>
  449. <h3 class="h4">ZooKeeper Stat Structure</h3>
  450. <p>The Stat structure for each znode in ZooKeeper is made up of the
  451. following fields:</p>
  452. <ul>
  453. <li>
  454. <p>
  455. <strong>czxid</strong>
  456. </p>
  457. <p>The zxid of the change that caused this znode to be
  458. created.</p>
  459. </li>
  460. <li>
  461. <p>
  462. <strong>mzxid</strong>
  463. </p>
  464. <p>The zxid of the change that last modified this znode.</p>
  465. </li>
  466. <li>
  467. <p>
  468. <strong>ctime</strong>
  469. </p>
  470. <p>The time in milliseconds from epoch when this znode was
  471. created.</p>
  472. </li>
  473. <li>
  474. <p>
  475. <strong>mtime</strong>
  476. </p>
  477. <p>The time in milliseconds from epoch when this znode was last
  478. modified.</p>
  479. </li>
  480. <li>
  481. <p>
  482. <strong>version</strong>
  483. </p>
  484. <p>The number of changes to the data of this znode.</p>
  485. </li>
  486. <li>
  487. <p>
  488. <strong>cversion</strong>
  489. </p>
  490. <p>The number of changes to the children of this znode.</p>
  491. </li>
  492. <li>
  493. <p>
  494. <strong>aversion</strong>
  495. </p>
  496. <p>The number of changes to the ACL of this znode.</p>
  497. </li>
  498. <li>
  499. <p>
  500. <strong>ephemeralOwner</strong>
  501. </p>
  502. <p>The session id of the owner of this znode if the znode is an
  503. ephemeral node. If it is not an ephemeral node, it will be
  504. zero.</p>
  505. </li>
  506. </ul>
  507. </div>
  508. <a name="N10194"></a><a name="ZooKeeper+Sessions"></a>
  509. <h2 class="h3">ZooKeeper Sessions</h2>
  510. <div class="section">
  511. <p>When a client gets a handle to the ZooKeeper service, ZooKeeper
  512. creates a ZooKeeper session, represented as a 64-bit number, that it
  513. assigns to the client. If the client connects to a different ZooKeeper
  514. server, it will send the session id as a part of the connection handshake.
  515. As a security measure, the server creates a password for the session id
  516. that any ZooKeeper server can validate. <remark>[tbd: note from Ben:
  517. "perhaps capability is a better word." need clarification on that.]
  518. </remark>The password is sent to the client with the session id when the
  519. client establishes the session. The client sends this password with the
  520. session id whenever it reestablishes the session with a new server.</p>
  521. <p>One of the parameters to the ZooKeeper client library call to create
  522. a ZooKeeper session is the session timeout in milliseconds. The client
  523. sends a requested timeout, the server responds with the timeout that it
  524. can give the client. The current implementation requires that the timeout
  525. be between 2 times the tickTime (as set in the server configuration) and
  526. 60 seconds.</p>
  527. <p>The session is kept alive by requests sent by the client. If the
  528. session is idle for a period of time that would timeout the session, the
  529. client will send a PING request to keep the session alive. This PING
  530. request not only allows the ZooKeeper server to know that the client is
  531. still active, but it also allows the client to verify that its connection
  532. to the ZooKeeper server is still active. The timing of the PING is
  533. conservative enough to ensure reasonable time to detect a dead connection
  534. and reconnect to a new server.</p>
  535. </div>
  536. <a name="N101A7"></a><a name="ZooKeeper+Watches"></a>
  537. <h2 class="h3">ZooKeeper Watches</h2>
  538. <div class="section">
  539. <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
  540. side effect. Here is ZooKeeper's definition of a watch: a watch event is
  541. one-time trigger, sent to the client that set the watch, which occurs when
  542. the data for which the watch was set changes. There are three key points
  543. to consider in this definition of a watch:</p>
  544. <ul>
  545. <li>
  546. <p>
  547. <strong>One-time trigger</strong>
  548. </p>
  549. <p>One watch event will be sent to the client the data has changed.
  550. For example, if a client does a getData("/znode1", true) and later the
  551. data for /znode1 is changed or deleted, the client will get a watch
  552. event for /znode1. If /znode1 changes again, no watch event will be
  553. sent unless the client has done another read that sets a new
  554. watch.</p>
  555. </li>
  556. <li>
  557. <p>
  558. <strong>Sent to the client</strong>
  559. </p>
  560. <p>This implies that an event is on the way to the client, but may
  561. not reach the client before the successful return code to the change
  562. operation reaches the client that initiated the change. Watches are
  563. sent asynchronously to watchers. ZooKeeper provides an ordering
  564. guarantee: a client will never see a change for which it has set a
  565. watch until it first sees the watch event. Network delays or other
  566. factors may cause different clients to see watches and return codes
  567. from updates at different times. The key point is that everything seen
  568. by the different clients will have a consistent order.</p>
  569. </li>
  570. <li>
  571. <p>
  572. <strong>The data for which the watch was
  573. set</strong>
  574. </p>
  575. <p>This refers to the different ways a node can change. ZooKeeper
  576. maintains two lists of watches: data watches and child watches.
  577. getData() and exists() set data watches. getChildren() sets child
  578. watches. Thus, setData() will trigger data watches for the znode being
  579. set (assuming the set is successful). A successful create() will
  580. trigger a data watch for the znode being created and a child watch for
  581. the parent znode. A successful delete() will trigger both a data watch
  582. and a child watch (since there can be no more children) for a znode
  583. being deleted as well as a child watch for the parent znode.</p>
  584. </li>
  585. </ul>
  586. <p>Watches are maintained locally at the ZooKeeper server to which the
  587. client is connected. This allows watches to be light weight to set,
  588. maintain, and dispatch. It also means if a client connects to a different
  589. server, the new server is not going to know about its watches. So, when a
  590. client gets a disconnect event, it must consider that an implicit trigger
  591. of all watches. When a client reconnects to a new server, the client
  592. should re-set any watches that it is still interested in.</p>
  593. <a name="N101DD"></a><a name="sc_WatchGuarantees"></a>
  594. <h3 class="h4">What ZooKeeper Guarantees about Watches</h3>
  595. <p>With regard to watches, ZooKeeper maintains these
  596. guarantees:</p>
  597. <ul>
  598. <li>
  599. <p>Watches are ordered with respect to other events, other
  600. watches, and asynchronous replies. The ZooKeeper client libraries
  601. ensures that everything is dispatched in order.</p>
  602. </li>
  603. </ul>
  604. <ul>
  605. <li>
  606. <p>A client will see a watch event for a znode it is watching
  607. before seeing the new data that corresponds to that znode.</p>
  608. </li>
  609. </ul>
  610. <ul>
  611. <li>
  612. <p>The order of watch events from ZooKeeper corresponds to the
  613. order of the updates as seen by the ZooKeeper service.</p>
  614. </li>
  615. </ul>
  616. <a name="N10202"></a><a name="sc_WatchRememberThese"></a>
  617. <h3 class="h4">Things to Remember about Watches</h3>
  618. <ul>
  619. <li>
  620. <p>Watches are one time triggers; if you get a watch event and
  621. you want to get notified of future changes, you must set another
  622. watch.</p>
  623. </li>
  624. </ul>
  625. <ul>
  626. <li>
  627. <p>Because watches are one time triggers and there is latency
  628. between getting the event and sending a new request to get a watch
  629. you cannot reliably see every change that happens to a node in
  630. ZooKeeper. Be prepared to handle the case where the znode changes
  631. multiple times between getting the event and setting the watch
  632. again. (You may not care, but at least realize it may
  633. happen.)</p>
  634. </li>
  635. </ul>
  636. <ul>
  637. <li>
  638. <p>When you disconnect from a server (for example, when the
  639. server fails), all of the watches you have registered are lost, so
  640. you should treat this case as if all your watches were
  641. triggered.</p>
  642. </li>
  643. </ul>
  644. </div>
  645. <a name="N10225"></a><a name="Consistency+Guarantees"></a>
  646. <h2 class="h3">Consistency Guarantees</h2>
  647. <div class="section">
  648. <p>ZooKeeper is a high performance, scalable service. Both reads and
  649. write operations are designed to be fast, though reads are faster than
  650. writes. The reason for this is that in the case of reads, ZooKeeper can
  651. serve older data, which in turn is due to ZooKeeper's consistency
  652. guarantees:</p>
  653. <dl>
  654. <dt>
  655. <term>Sequential Consistency</term>
  656. </dt>
  657. <dd>
  658. <p>Updates from a client will be applied in the order that they
  659. were sent.</p>
  660. </dd>
  661. <dt>
  662. <term>Atomicity</term>
  663. </dt>
  664. <dd>
  665. <p>Updates either succeed or fail -- there are no partial
  666. results.</p>
  667. </dd>
  668. <dt>
  669. <term>Single System Image</term>
  670. </dt>
  671. <dd>
  672. <p>A client will see the same view of the service regardless of
  673. the server that it connects to.</p>
  674. </dd>
  675. <dt>
  676. <term>Reliability</term>
  677. </dt>
  678. <dd>
  679. <p>Once an update has been applied, it will persist from that
  680. time forward until a client overwrites the update. This guarantee
  681. has two corollaries:</p>
  682. <ol>
  683. <li>
  684. <p>If a client gets a successful return code, the update will
  685. have been applied. On some failures (communication errors,
  686. timeouts, etc) the client will not know if the update has
  687. applied or not. We take steps to minimize the failures, but the
  688. only guarantee is only present with successful return codes.
  689. (This is called the _monotonicity condition_ in Paxos.)</p>
  690. </li>
  691. <li>
  692. <p>Any updates that are seen by the client, through a read
  693. request or successful update, will never be rolled back when
  694. recovering from server failures.</p>
  695. </li>
  696. </ol>
  697. </dd>
  698. <dt>
  699. <term>Timeliness</term>
  700. </dt>
  701. <dd>
  702. <p>The clients view of the system is guaranteed to be up-to-date
  703. within a certain time bound. (On the order of tens of seconds.)
  704. Either system changes will be seen by a client within this bound, or
  705. the client will detect a service outage.</p>
  706. </dd>
  707. </dl>
  708. <p>Using these consistency guarantees it is easy to build higher level
  709. functions such as leader election, barriers, queues, and read/write
  710. revocable locks solely at the ZooKeeper client (no additions needed to
  711. ZooKeeper). See <a href="recipes.html">Recipes and Solutions</a>
  712. for more details.</p>
  713. <p>
  714. <div class="note">
  715. <div class="label">Note</div>
  716. <div class="content">
  717. <p>Sometimes developers mistakenly assume one other guarantee that
  718. Zookeeper does <em>not</em> in fact make. This is:</p>
  719. <dl>
  720. <dt>
  721. <term>Simultaneously Conistent Cross-Client Views</term>
  722. </dt>
  723. <dd>
  724. <p>ZooKeeper does not guarantee that at every instance in
  725. time, two different clients will have identical views of
  726. ZooKeeper data. Due to factors like network delays, one client
  727. may perform an update before another client gets notified of the
  728. change. Consider the scenario of two clients, A and B. If client
  729. A sets the value of a znode /a from 0 to 1, then tells client B
  730. to read /a, client B may read the old value of 0, depending on
  731. which server in the ZooKeeper quorum it is connected to. If it
  732. is important that Client A and Client B read the same value,
  733. Client B should should call the <strong>sync()</strong> method from the ZooKeeper API
  734. method before it performs its read.</p>
  735. <p>So, ZooKeeper by itself doesn't guarantee instantaneous,
  736. atomic, synchronization across its quorum, but ZooKeeper
  737. primitives can be used to construct higher level functions that
  738. provide complete client synchronization. (For more information,
  739. see the <a href="recipes.html#sc_recipes_Locks">Locks</a>
  740. <remark>[tbd: fix final link target]</remark> in <a href="recipes.html">Zookeeper Recipes</a>.
  741. <remark>[tbd: fix final link target]</remark>).</p>
  742. </dd>
  743. </dl>
  744. </div>
  745. </div>
  746. </p>
  747. </div>
  748. <a name="N10291"></a><a name="Bindings"></a>
  749. <h2 class="h3">Bindings</h2>
  750. <div class="section">
  751. <p>The ZooKeeper client libraries come in two languages: Java and C.
  752. The following sections describe these.</p>
  753. <a name="N1029A"></a><a name="Java+Binding"></a>
  754. <h3 class="h4">Java Binding</h3>
  755. <p>There are two packages that make up the ZooKeeper Java binding:
  756. <strong>org.apache.zookeeper</strong> and <strong>org.apache.zookeeper.data</strong>. The rest of the
  757. packages that make up ZooKeeper are used internally or are part of the
  758. server implementation. The <strong>org.apache.zookeeper.data</strong> package is made up of
  759. generated classes that are used simply as containers.</p>
  760. <p>The main class used by a ZooKeeper Java client is the <strong>ZooKeeper</strong> class. Its two constructors differ only
  761. by an optional session id and password. ZooKeeper supports session
  762. recovery accross instances of a process. A Java program may save its
  763. session id and password to stable storage, restart, and recover the
  764. session that was used by the earlier instance of the program.</p>
  765. <p>When a ZooKeeper object is created, two threads are created as
  766. well: an IO thread and an event thread. All IO happens on the IO thread
  767. (using Java NIO). All event callbacks happen on the event thread.
  768. Session maintenance such as reconnecting to ZooKeeper servers and
  769. maintaining heartbeat is done on the IO thread. Responses for
  770. synchronous methods are also processed in the IO thread. All responses
  771. to asynchronous methods and watch events are processed on the event
  772. thread. There are a few things to notice that result from this
  773. design:</p>
  774. <ul>
  775. <li>
  776. <p>All completions for asynchronous calls and watcher callbacks
  777. will be made in order, one at a time. The caller can do any
  778. processing they wish, but no other callbacks will be processed
  779. during that time.</p>
  780. </li>
  781. <li>
  782. <p>Callbacks do not block the processing of the IO thread or the
  783. processing of the synchronous calls.</p>
  784. </li>
  785. <li>
  786. <p>Synchronous calls may not return in the correct order. For
  787. example, assume a client does the following processing: issues an
  788. asynchronous read of node <strong>/a</strong> with
  789. <em>watch</em> set to true, and then in the completion
  790. callback of the read it does a synchronous read of <strong>/a</strong>. (Maybe not good practice, but not illegal
  791. either, and it makes for a simple example.)</p>
  792. <p>Note that if there is a change to <strong>/a</strong> between the asynchronous read and the
  793. synchronous read, the client library will receive the watch event
  794. saying <strong>/a</strong> changed before the
  795. response for the synchronous read, but because the completion
  796. callback is blocking the event queue, the synchronous read will
  797. return with the new value of <strong>/a</strong>
  798. before the watch event is processed.</p>
  799. </li>
  800. </ul>
  801. <p>Finally, the rules associated with shutdown are straightforward:
  802. once a ZooKeeper object is closed or receives a fatal event
  803. (SESSION_EXPIRED and AUTH_FAILED), the ZooKeeper object becomes invalid,
  804. the two threads shut down, and any further ZooKeeper calls throw
  805. errors.</p>
  806. <a name="N102E3"></a><a name="C+Binding"></a>
  807. <h3 class="h4">C Binding</h3>
  808. <p>The C binding has a single-threaded and multi-threaded library.
  809. The multi-threaded library is easiest to use and is most similar to the
  810. Java API. This library will create an IO thread and an event dispatch
  811. thread for handling connection maintenance and callbacks. The
  812. single-threaded library allows ZooKeeper to be used in event driven
  813. applications by exposing the event loop used in the multi-threaded
  814. library.</p>
  815. <p>The package includes two shared libraries: zookeeper_st and
  816. zookeeper_mt. The former only provides the asynchronous APIs and
  817. callbacks for integrating into the application's event loop. The only
  818. reason this library exists is to support the platforms were a
  819. <em>pthread</em> library is not available or is unstable
  820. (i.e. FreeBSD 4.x). In all other cases, application developers should
  821. link with zookeeper_mt, as it includes support for both Sync and Async
  822. API.</p>
  823. <a name="N102F2"></a><a name="Installation"></a>
  824. <h4>Installation</h4>
  825. <p>If you're building the client from a check-out from the Apache
  826. repository, follow the steps outlined below. If you're building from a
  827. project source package downloaded from apache, skip to step <strong>3</strong>.</p>
  828. <ol>
  829. <li>
  830. <p>Run <span class="codefrag command">ant compile_just</span> from the zookeeper
  831. top level directory (<span class="codefrag filename">.../trunk/zookeeper</span>).
  832. This will create a directory named "generated" under
  833. <span class="codefrag filename">zookeeper/c</span>.</p>
  834. </li>
  835. <li>
  836. <p>Change directory to the<span class="codefrag filename">zookeeper/c</span> and
  837. run <span class="codefrag command">autoreconf -i</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.
  838. Skip to step<strong> 4</strong>.</p>
  839. </li>
  840. <li>
  841. <p>If you are building from a project source package,
  842. unzip/untar the source tarball and cd to the<span class="codefrag filename">
  843. zookeeper-x.x.x/</span> directory.</p>
  844. </li>
  845. <li>
  846. <p>Run <span class="codefrag command">./configure &lt;your-options&gt;</span> to
  847. generate the makefile. Here are some of options the <strong>configure</strong> utility supports that can be
  848. useful in this step:</p>
  849. <ul>
  850. <li>
  851. <p>
  852. <span class="codefrag command">--enable-debug</span>
  853. </p>
  854. <p>Enables optimization and enables debug info compiler
  855. options. (Disabled by default.)</p>
  856. </li>
  857. <li>
  858. <p>
  859. <span class="codefrag command">--without-syncapi </span>
  860. </p>
  861. <p>Disables Sync API support; zookeeper_mt library won't be
  862. built. (Enabled by default.)</p>
  863. </li>
  864. <li>
  865. <p>
  866. <span class="codefrag command">--disable-static </span>
  867. </p>
  868. <p>Do not build static libraries. (Enabled by
  869. default.)</p>
  870. </li>
  871. <li>
  872. <p>
  873. <span class="codefrag command">--disable-shared</span>
  874. </p>
  875. <p>Do not build shared libraries. (Enabled by
  876. default.)</p>
  877. </li>
  878. </ul>
  879. <div class="note">
  880. <div class="label">Note</div>
  881. <div class="content">
  882. <p>See INSTALL for general information about running
  883. <strong>configure</strong>. <remark>[tbd: what
  884. is INSTALL? a directory? a file?]</remark>
  885. </p>
  886. </div>
  887. </div>
  888. </li>
  889. <li>
  890. <p>Run <span class="codefrag command">make</span> or <span class="codefrag command">make
  891. install</span> to build the libraries and install them.</p>
  892. </li>
  893. <li>
  894. <p>To generate doxygen documentation for the ZooKeeper API, run
  895. <span class="codefrag command">make doxygen-doc</span>. All documentation will be
  896. placed in a new subfolder named docs. By default, this command
  897. only generates HTML. For information on other document formats,
  898. run <span class="codefrag command">./configure --help</span>
  899. </p>
  900. </li>
  901. </ol>
  902. <a name="N1039D"></a><a name="Using+the+Client"></a>
  903. <h4>Using the Client</h4>
  904. <p>You can test your client by running a zookeeper server (see
  905. instructions on the project wiki page on how to run it) and connecting
  906. to it using one of the cli applications that were built as part of the
  907. installation procedure. cli_mt (multithreaded, built against
  908. zookeeper_mt library) is shown in this example, but you could also use
  909. cli_st (singlethreaded, built against zookeeper_st library):</p>
  910. <p>
  911. <pre class="code">$ cli_mt zookeeper_host:9876</pre>This
  912. is a client application that gives you a shell for executing simple
  913. zookeeper commands. Once succesully started and connected to the
  914. server it displays a shell prompt. You can now enter zookeeper
  915. commands. For example, to create a node:</p>
  916. <pre class="code">&gt; create /my_new_node</pre>
  917. <p>To verify that the node's been created:</p>
  918. <p>You should see a list of node who are children of the root node
  919. "/". <remark>[tbd: document all the cli commands (I think this is
  920. Ben's tbd? It's from sourceforge)]</remark>
  921. </p>
  922. <p>In order to be able to use the ZooKeeper API in your application
  923. you have to remember to</p>
  924. <ol>
  925. <li>
  926. <p>Include zookeeper header: #include
  927. &lt;zookeeper/zookeeper.h</p>
  928. </li>
  929. <li>
  930. <p>If you are building a multithreaded client, compile with
  931. -DTHREADED compiler flag to enable the multi-threaded version of
  932. the library, and then link against against the
  933. <span class="codefrag varname">zookeeper_mt</span> library. If you are building a
  934. single-threaded client, do not compile with -DTHREADED, and be
  935. sure to link against the<span class="codefrag varname"> zookeeper_st
  936. </span>library.</p>
  937. </li>
  938. </ol>
  939. <p>Refer to <a href="#ch_programStructureWithExample">Program Structure, with Simple Example</a>for examples of usage in Java and C.
  940. <remark>[tbd: some kind of short tutorial would be helpful, I guess
  941. (ben's tbd?) ][tbd: whatever the case, make sure that link points to something.]</remark>
  942. </p>
  943. </div>
  944. <a name="N103DC"></a><a name="Building+Blocks%3A+A+Guide+to+ZooKeeper+Operations"></a>
  945. <h2 class="h3">Building Blocks: A Guide to ZooKeeper Operations</h2>
  946. <div class="section">
  947. <p>
  948. <remark>[Engineering input needed. This is a new section. The below
  949. is just placeholder, and was actually copied from the overview book. There
  950. should probably be a subsection on each of those operations, with a little
  951. bit of illustrative code for each op.] </remark>
  952. </p>
  953. <p>One of the design goals of ZooKeeper is provide a very simple
  954. programming interface. As a result, it supports only these
  955. operations:</p>
  956. <dl>
  957. <dt>
  958. <term>create</term>
  959. </dt>
  960. <dd>
  961. <p>creates a node at a location in the tree</p>
  962. </dd>
  963. <dt>
  964. <term>delete</term>
  965. </dt>
  966. <dd>
  967. <p>deletes a node</p>
  968. </dd>
  969. <dt>
  970. <term>exists</term>
  971. </dt>
  972. <dd>
  973. <p>tests if a node exists at a location</p>
  974. </dd>
  975. <dt>
  976. <term>get data</term>
  977. </dt>
  978. <dd>
  979. <p>reads the data from a node</p>
  980. </dd>
  981. <dt>
  982. <term>set data</term>
  983. </dt>
  984. <dd>
  985. <p>writes data to a node</p>
  986. </dd>
  987. <dt>
  988. <term>get children</term>
  989. </dt>
  990. <dd>
  991. <p>retrieves a list of children of a node</p>
  992. </dd>
  993. <dt>
  994. <term>sync</term>
  995. </dt>
  996. <dd>
  997. <p>waits for data to be propagated.</p>
  998. </dd>
  999. </dl>
  1000. </div>
  1001. <a name="N1041E"></a><a name="Program+Structure%2C+with+Simple+Example"></a>
  1002. <h2 class="h3">Program Structure, with Simple Example</h2>
  1003. <div class="section">
  1004. <p>
  1005. <remark>[tbd]</remark>
  1006. </p>
  1007. </div>
  1008. <a name="N10429"></a><a name="Gotchas%3A+Common+Problems+and+Troubleshooting"></a>
  1009. <h2 class="h3">Gotchas: Common Problems and Troubleshooting</h2>
  1010. <div class="section">
  1011. <p>So now you know ZooKeeper. It's fast, simple, your application
  1012. works, but wait ... something's wrong. Here are some pitfalls that
  1013. ZooKeeper users fall into:</p>
  1014. <ol>
  1015. <li>
  1016. <p>If you are using watches, you must look for the connected watch
  1017. event. When a ZooKeeper client disconnects from a server, all the
  1018. watches are removed, so a client must treat the disconnect event as an
  1019. implicit trigger of watches. The easiest way to deal with this is to
  1020. act like the connected watch event is a watch trigger for all your
  1021. watches. The connected event makes a better trigger than the
  1022. disconnected event because you can access ZooKeeper and reestablish
  1023. watches when you are connected.</p>
  1024. </li>
  1025. <li>
  1026. <p>You must test ZooKeeper server failures. The ZooKeeper service
  1027. can survive failures as long as a majority of servers are active. The
  1028. question to ask is: can your application handle it? In the real world
  1029. a client's connection to ZooKeeper can break. (ZooKeeper server
  1030. failures and network partitions are common reasons for connection
  1031. loss.) The ZooKeeper client library takes care of recovering your
  1032. connection and letting you know what happened, but you must make sure
  1033. that you recover your state and any outstanding requests that failed.
  1034. Find out if you got it right in the test lab, not in production - test
  1035. with a ZooKeeper service made up of a several of servers and subject
  1036. them to reboots.</p>
  1037. </li>
  1038. <li>
  1039. <p>The list of ZooKeeper servers used by the client must match the
  1040. list of ZooKeeper servers that each ZooKeeper server has. Things can
  1041. work, although not optimally, if the client list is a subset of the
  1042. real list of ZooKeeper servers, but not if the client lists ZooKeeper
  1043. servers not in the ZooKeeper cluster.</p>
  1044. </li>
  1045. <li>
  1046. <p>Be careful where you put that transaction log. The most
  1047. performance-critical part of ZooKeeper is the transaction log.
  1048. ZooKeeper must sync transactions to media before it returns a
  1049. response. A dedicated transaction log device is key to consistent good
  1050. performance. Putting the log on a busy device will adversely effect
  1051. performance. If you only have one storage device, put trace files on
  1052. NFS and increase the snapshotCount; it doesn't eliminate the problem,
  1053. but it can mitigate it.</p>
  1054. </li>
  1055. <li>
  1056. <p>Set your Java max heap size correctly. It is very important to
  1057. <em>avoid swapping.</em> Going to disk unnecessarily will
  1058. almost certainly degrade your performance unacceptably. Remember, in
  1059. ZooKeeper, everything is ordered, so if one request hits the disk, all
  1060. other queued requests hit the disk.</p>
  1061. <p>To avoid swapping, try to set the heapsize to the amount of
  1062. physical memory you have, minus the amount needed by the OS and cache.
  1063. The best way to determine an optimal heap size for your configurations
  1064. is to <em>run load tests</em>. If for some reason you
  1065. can't, be conservative in your estimates and choose a number well
  1066. below the limit that would cause your machine to swap. For example, on
  1067. a 4G machine, a 3G heap is a conservative estimate to start
  1068. with.</p>
  1069. </li>
  1070. </ol>
  1071. </div>
  1072. <a name="apx_linksToOtherInfo"></a>
  1073. <appendix id="apx_linksToOtherInfo">
  1074. <title>Links to Other Information</title>
  1075. <p>Outside the formal documentation, there're several other sources of
  1076. information for ZooKeeper developers.</p>
  1077. <dl>
  1078. <dt>
  1079. <term>ZooKeeper Whitepaper <remark>[tbd: find url]</remark>
  1080. </term>
  1081. </dt>
  1082. <dd>
  1083. <p>The definitive discussion of ZooKeeper design and performance,
  1084. by Yahoo! Research</p>
  1085. </dd>
  1086. <dt>
  1087. <term>API Reference <remark>[tbd: find url]</remark>
  1088. </term>
  1089. </dt>
  1090. <dd>
  1091. <p>The complete reference to the ZooKeeper API</p>
  1092. </dd>
  1093. <dt>
  1094. <term>
  1095. <a href="http://us.dl1.yimg.com/download.yahoo.com/dl/ydn/zookeeper.m4v">Zookeeper
  1096. Talk at the Hadoup Summit 2008</a>
  1097. </term>
  1098. </dt>
  1099. <dd>
  1100. <p>A video introduction to ZooKeeper, by Benjamin Reed of Yahoo!
  1101. Research</p>
  1102. </dd>
  1103. <dt>
  1104. <term>
  1105. <a href="http://wiki.apache.org/hadoop/ZooKeeper/Tutorial">Barrier and
  1106. Queue Tutorial</a>
  1107. </term>
  1108. </dt>
  1109. <dd>
  1110. <p>The excellent Java tutorial by Flavio Junqueira, implementing
  1111. simple barriers and producer-consumer queues using ZooKeeper.</p>
  1112. </dd>
  1113. <dt>
  1114. <term>
  1115. <a href="http://wiki.apache.org/hadoop/ZooKeeper/ZooKeeperArticles">ZooKeeper
  1116. - A Reliable, Scalable Distributed Coordination System</a>
  1117. </term>
  1118. </dt>
  1119. <dd>
  1120. <p>An article by Todd Hoff (07/15/2008)</p>
  1121. </dd>
  1122. <dt>
  1123. <term>
  1124. <a href="recipes.html">Zookeeper Recipes [tbd: fix
  1125. linkend for apache site]</a>
  1126. </term>
  1127. </dt>
  1128. <dd>
  1129. <p>Pseudo-level discussion of the implementation of various
  1130. synchronization solutions with ZooKeeper: Event Handles, Queues,
  1131. Locks, and Two-phase Commits.</p>
  1132. </dd>
  1133. <dt>
  1134. <term>
  1135. <remark>[tbd]</remark>
  1136. </term>
  1137. </dt>
  1138. <dd>
  1139. <p>Whatever good sources anyone can think of...</p>
  1140. </dd>
  1141. </dl>
  1142. </appendix>
  1143. <p align="right">
  1144. <font size="-2"></font>
  1145. </p>
  1146. </div>
  1147. <!--+
  1148. |end content
  1149. +-->
  1150. <div class="clearboth">&nbsp;</div>
  1151. </div>
  1152. <div id="footer">
  1153. <!--+
  1154. |start bottomstrip
  1155. +-->
  1156. <div class="lastmodified">
  1157. <script type="text/javascript"><!--
  1158. document.write("Last Published: " + document.lastModified);
  1159. // --></script>
  1160. </div>
  1161. <div class="copyright">
  1162. Copyright &copy;
  1163. 2008 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  1164. </div>
  1165. <!--+
  1166. |end bottomstrip
  1167. +-->
  1168. </div>
  1169. </body>
  1170. </html>