+
+*You should only have to read this section if you are upgrading from a previous version of ZooKeeper to version 3.0.0, otw skip down to [changes](#changes)*
+
+A small number of changes in this release have resulted in non-backward compatible Zookeeper client user code and server instance data. The following instructions provide details on how to migrate code and date from version 2.2.1 to version 3.0.0.
+
+Note: ZooKeeper increments the major version number (major.minor.fix) when backward incompatible changes are made to the source base. As part of the migration from SourceForge we changed the package structure (com.yahoo.zookeeper.* to org.apache.zookeeper.*) and felt it was a good time to incorporate some changes that we had been withholding. As a result the following will be required when migrating from 2.2.1 to 3.0.0 version of ZooKeeper.
+
+* [Migrating Client Code](#migration_code)
+* [Migrating Server Data](#migration_data)
+* [Migrating Server Configuration](#migration_config)
+
+
+### Migrating Client Code
+
+The underlying client-server protocol has changed in version 3.0.0
+of ZooKeeper. As a result clients must be upgraded along with
+serving clusters to ensure proper operation of the system (old
+pre-3.0.0 clients are not guaranteed to operate against upgraded
+3.0.0 servers and vice-versa).
+
+
+#### Watch Management
+
+In previous releases of ZooKeeper any watches registered by clients were lost if the client lost a connection to a ZooKeeper server.
+This meant that developers had to track watches they were interested in and reregister them if a session disconnect event was received.
+In this release the client library tracks watches that a client has registered and reregisters the watches when a connection is made to a new server.
+Applications that still manually reregister interest should continue working properly as long as they are able to handle unsolicited watches.
+For example, an old application may register a watch for /foo and /goo, lose the connection, and reregister only /goo.
+As long as the application is able to receive a notification for /foo, (probably ignoring it) it does not need to be changed.
+One caveat to the watch management: it is possible to miss an event for the creation and deletion of a znode if watching for creation and both the create and delete happens while the client is disconnected from ZooKeeper.
+
+This release also allows clients to specify call specific watch functions.
+This gives the developer the ability to modularize logic in different watch functions rather than cramming everything in the watch function attached to the ZooKeeper handle.
+Call specific watch functions receive all session events for as long as they are active, but will only receive the watch callbacks for which they are registered.
+
+
+#### Java API
+
+1. The java package structure has changed from **com.yahoo.zookeeper*** to **org.apache.zookeeper***. This will probably affect all of your java code which makes use of ZooKeeper APIs (typically import statements)
+1. A number of constants used in the client ZooKeeper API were re-specified using enums (rather than ints). See [ZOOKEEPER-7](https://issues.apache.org/jira/browse/ZOOKEEPER-7), [ZOOKEEPER-132](https://issues.apache.org/jira/browse/ZOOKEEPER-132) and [ZOOKEEPER-139](https://issues.apache.org/jira/browse/ZOOKEEPER-139) for full details
+1. [ZOOKEEPER-18](https://issues.apache.org/jira/browse/ZOOKEEPER-18) removed KeeperStateChanged, use KeeperStateDisconnected instead
+
+Also see [the current Java API](http://zookeeper.apache.org/docs/current/apidocs/zookeeper-server/index.html)
+
+
+#### C API
+
+1. A number of constants used in the client ZooKeeper API were renamed in order to reduce namespace collision, see [ZOOKEEPER-6](https://issues.apache.org/jira/browse/ZOOKEEPER-6) for full details
+
+
+### Migrating Server Data
+The following issues resulted in changes to the on-disk data format (the snapshot and transaction log files contained within the ZK data directory) and require a migration utility to be run.
+
+* [ZOOKEEPER-27 Unique DB identifiers for servers and clients](https://issues.apache.org/jira/browse/ZOOKEEPER-27)
+* [ZOOKEEPER-32 CRCs for ZooKeeper data](https://issues.apache.org/jira/browse/ZOOKEEPER-32)
+* [ZOOKEEPER-33 Better ACL management](https://issues.apache.org/jira/browse/ZOOKEEPER-33)
+* [ZOOKEEPER-38 headers (version+) in log/snap files](https://issues.apache.org/jira/browse/ZOOKEEPER-38)
+
+**The following must be run once, and only once, when upgrading the ZooKeeper server instances to version 3.0.0.**
+
+###### Note
+> The and directories referenced below are specified by the *dataLogDir*
+ and *dataDir* specification in your ZooKeeper config file respectively. *dataLogDir* defaults to
+ the value of *dataDir* if not specified explicitly in the ZooKeeper server config file (in which
+ case provide the same directory for both parameters to the upgrade utility).
+
+1. Shutdown the ZooKeeper server cluster.
+1. Backup your and directories
+1. Run upgrade using
+ * `bin/zkServer.sh upgrade `
+
+ or
+
+ * `java -classpath pathtolog4j:pathtozookeeper.jar UpgradeMain `
+
+ where is the directory where all transaction logs (log.*) are stored. is the directory where all the snapshots (snapshot.*) are stored.
+1. Restart the cluster.
+
+If you have any failure during the upgrade procedure keep reading to sanitize your database.
+
+This is how upgrade works in ZooKeeper. This will help you troubleshoot in case you have problems while upgrading
+
+1. Upgrade moves files from `` and `` to `/version-1/` and `/version-1` respectively (version-1 sub-directory is created by the upgrade utility).
+1. Upgrade creates a new version sub-directory `/version-2` and `/version-2`
+1. Upgrade reads the old database from `/version-1` and `/version-1` into the memory and creates a new upgraded snapshot.
+1. Upgrade writes the new database in `/version-2`.
+
+Troubleshooting.
+
+
+1. In case you start ZooKeeper 3.0 without upgrading from 2.0 on a 2.0 database - the servers will start up with an empty database.
+ This is because the servers assume that `/version-2` and `/version-2` will have the database to start with. Since this will be empty
+ in case of no upgrade, the servers will start with an empty database. In such a case, shutdown the ZooKeeper servers, remove the version-2 directory (remember
+ this will lead to loss of updates after you started 3.0.)
+ and then start the upgrade procedure.
+1. If the upgrade fails while trying to rename files into the version-1 directory, you should try and move all the files under `/version-1`
+ and `/version-1` to `` and `` respectively. Then try upgrade again.
+1. If you do not wish to run with ZooKeeper 3.0 and prefer to run with ZooKeeper 2.0 and have already upgraded - you can run ZooKeeper 2 with
+ the `` and `` directories changed to `/version-1` and `/version-1`. Remember that you will lose all the updates that you made after the upgrade.
+
+
+### Migrating Server Configuration
+
+There is a significant change to the ZooKeeper server configuration file.
+
+The default election algorithm, specified by the *electionAlg* configuration attribute, has
+changed from a default of *0* to a default of *3*. See
+[Cluster Options](zookeeperAdmin.html#sc_clusterOptions) section of the administrators guide, specifically
+the *electionAlg* and *server.X* properties.
+
+You will either need to explicitly set *electionAlg* to its previous default value
+of *0* or change your *server.X* options to include the leader election port.
+
+
+
+## Changes Since ZooKeeper 2.2.1
+
+Version 2.2.1 code, documentation, binaries, etc... are still accessible on [SourceForge](http://sourceforge.net/projects/zookeeper)
+
+| Issue | Notes |
+|-------|-------|
+|[ZOOKEEPER-43](https://issues.apache.org/jira/browse/ZOOKEEPER-43)|Server side of auto reset watches.|
+|[ZOOKEEPER-132](https://issues.apache.org/jira/browse/ZOOKEEPER-132)|Create Enum to replace CreateFlag in ZooKepper.create method|
+|[ZOOKEEPER-139](https://issues.apache.org/jira/browse/ZOOKEEPER-139)|Create Enums for WatcherEvent's KeeperState and EventType|
+|[ZOOKEEPER-18](https://issues.apache.org/jira/browse/ZOOKEEPER-18)|keeper state inconsistency|
+|[ZOOKEEPER-38](https://issues.apache.org/jira/browse/ZOOKEEPER-38)|headers in log/snap files|
+|[ZOOKEEPER-8](https://issues.apache.org/jira/browse/ZOOKEEPER-8)|Stat enchaned to include num of children and size|
+|[ZOOKEEPER-6](https://issues.apache.org/jira/browse/ZOOKEEPER-6)|List of problem identifiers in zookeeper.h|
+|[ZOOKEEPER-7](https://issues.apache.org/jira/browse/ZOOKEEPER-7)|Use enums rather than ints for types and state|
+|[ZOOKEEPER-27](https://issues.apache.org/jira/browse/ZOOKEEPER-27)|Unique DB identifiers for servers and clients|
+|[ZOOKEEPER-32](https://issues.apache.org/jira/browse/ZOOKEEPER-32)|CRCs for ZooKeeper data|
+|[ZOOKEEPER-33](https://issues.apache.org/jira/browse/ZOOKEEPER-33)|Better ACL management|
+|[ZOOKEEPER-203](https://issues.apache.org/jira/browse/ZOOKEEPER-203)|fix datadir typo in releasenotes|
+|[ZOOKEEPER-145](https://issues.apache.org/jira/browse/ZOOKEEPER-145)|write detailed release notes for users migrating from 2.x to 3.0|
+|[ZOOKEEPER-23](https://issues.apache.org/jira/browse/ZOOKEEPER-23)|Auto reset of watches on reconnect|
+|[ZOOKEEPER-191](https://issues.apache.org/jira/browse/ZOOKEEPER-191)|forrest docs for upgrade.|
+|[ZOOKEEPER-201](https://issues.apache.org/jira/browse/ZOOKEEPER-201)|validate magic number when reading snapshot and transaction logs|
+|[ZOOKEEPER-200](https://issues.apache.org/jira/browse/ZOOKEEPER-200)|the magic number for snapshot and log must be different|
+|[ZOOKEEPER-199](https://issues.apache.org/jira/browse/ZOOKEEPER-199)|fix log messages in persistence code|
+|[ZOOKEEPER-197](https://issues.apache.org/jira/browse/ZOOKEEPER-197)|create checksums for snapshots|
+|[ZOOKEEPER-198](https://issues.apache.org/jira/browse/ZOOKEEPER-198)|apache license header missing from FollowerSyncRequest.java|
+|[ZOOKEEPER-5](https://issues.apache.org/jira/browse/ZOOKEEPER-5)|Upgrade Feature in Zookeeper server.|
+|[ZOOKEEPER-194](https://issues.apache.org/jira/browse/ZOOKEEPER-194)|Fix terminology in zookeeperAdmin.xml|
+|[ZOOKEEPER-151](https://issues.apache.org/jira/browse/ZOOKEEPER-151)|Document change to server configuration|
+|[ZOOKEEPER-193](https://issues.apache.org/jira/browse/ZOOKEEPER-193)|update java example doc to compile with latest zookeeper|
+|[ZOOKEEPER-187](https://issues.apache.org/jira/browse/ZOOKEEPER-187)|CreateMode api docs missing|
+|[ZOOKEEPER-186](https://issues.apache.org/jira/browse/ZOOKEEPER-186)|add new "releasenotes.xml" to forrest documentation|
+|[ZOOKEEPER-190](https://issues.apache.org/jira/browse/ZOOKEEPER-190)|Reorg links to docs and navs to docs into related sections|
+|[ZOOKEEPER-189](https://issues.apache.org/jira/browse/ZOOKEEPER-189)|forrest build not validated xml of input documents|
+|[ZOOKEEPER-188](https://issues.apache.org/jira/browse/ZOOKEEPER-188)|Check that election port is present for all servers|
+|[ZOOKEEPER-185](https://issues.apache.org/jira/browse/ZOOKEEPER-185)|Improved version of FLETest|
+|[ZOOKEEPER-184](https://issues.apache.org/jira/browse/ZOOKEEPER-184)|tests: An explicit include directive is needed for the usage of memcpy functions|
+|[ZOOKEEPER-183](https://issues.apache.org/jira/browse/ZOOKEEPER-183)|Array subscript is above array bounds in od_completion, src/cli.c.|
+|[ZOOKEEPER-182](https://issues.apache.org/jira/browse/ZOOKEEPER-182)|zookeeper_init accepts empty host-port string and returns valid pointer to zhandle_t.|
+|[ZOOKEEPER-17](https://issues.apache.org/jira/browse/ZOOKEEPER-17)|zookeeper_init doc needs clarification|
+|[ZOOKEEPER-181](https://issues.apache.org/jira/browse/ZOOKEEPER-181)|Some Source Forge Documents did not get moved over: javaExample, zookeeperTutorial, zookeeperInternals|
+|[ZOOKEEPER-180](https://issues.apache.org/jira/browse/ZOOKEEPER-180)|Placeholder sections needed in document for new topics that the umbrella jira discusses|
+|[ZOOKEEPER-179](https://issues.apache.org/jira/browse/ZOOKEEPER-179)|Programmer's Guide "Basic Operations" section is missing content|
+|[ZOOKEEPER-178](https://issues.apache.org/jira/browse/ZOOKEEPER-178)|FLE test.|
+|[ZOOKEEPER-159](https://issues.apache.org/jira/browse/ZOOKEEPER-159)|Cover two corner cases of leader election|
+|[ZOOKEEPER-156](https://issues.apache.org/jira/browse/ZOOKEEPER-156)|update programmer guide with acl details from old wiki page|
+|[ZOOKEEPER-154](https://issues.apache.org/jira/browse/ZOOKEEPER-154)|reliability graph diagram in overview doc needs context|
+|[ZOOKEEPER-157](https://issues.apache.org/jira/browse/ZOOKEEPER-157)|Peer can't find existing leader|
+|[ZOOKEEPER-155](https://issues.apache.org/jira/browse/ZOOKEEPER-155)|improve "the zookeeper project" section of overview doc|
+|[ZOOKEEPER-140](https://issues.apache.org/jira/browse/ZOOKEEPER-140)|Deadlock in QuorumCnxManager|
+|[ZOOKEEPER-147](https://issues.apache.org/jira/browse/ZOOKEEPER-147)|This is version of the documents with most of the [tbd...] scrubbed out|
+|[ZOOKEEPER-150](https://issues.apache.org/jira/browse/ZOOKEEPER-150)|zookeeper build broken|
+|[ZOOKEEPER-136](https://issues.apache.org/jira/browse/ZOOKEEPER-136)|sync causes hang in all followers of quorum.|
+|[ZOOKEEPER-134](https://issues.apache.org/jira/browse/ZOOKEEPER-134)|findbugs cleanup|
+|[ZOOKEEPER-133](https://issues.apache.org/jira/browse/ZOOKEEPER-133)|hudson tests failing intermittently|
+|[ZOOKEEPER-144](https://issues.apache.org/jira/browse/ZOOKEEPER-144)|add tostring support for watcher event, and enums for event type/state|
+|[ZOOKEEPER-21](https://issues.apache.org/jira/browse/ZOOKEEPER-21)|Improve zk ctor/watcher|
+|[ZOOKEEPER-142](https://issues.apache.org/jira/browse/ZOOKEEPER-142)|Provide Javadoc as to the maximum size of the data byte array that may be stored within a znode|
+|[ZOOKEEPER-93](https://issues.apache.org/jira/browse/ZOOKEEPER-93)|Create Documentation for Zookeeper|
+|[ZOOKEEPER-117](https://issues.apache.org/jira/browse/ZOOKEEPER-117)|threading issues in Leader election|
+|[ZOOKEEPER-137](https://issues.apache.org/jira/browse/ZOOKEEPER-137)|client watcher objects can lose events|
+|[ZOOKEEPER-131](https://issues.apache.org/jira/browse/ZOOKEEPER-131)|Old leader election can elect a dead leader over and over again|
+|[ZOOKEEPER-130](https://issues.apache.org/jira/browse/ZOOKEEPER-130)|update build.xml to support apache release process|
+|[ZOOKEEPER-118](https://issues.apache.org/jira/browse/ZOOKEEPER-118)|findbugs flagged switch statement in followerrequestprocessor.run|
+|[ZOOKEEPER-115](https://issues.apache.org/jira/browse/ZOOKEEPER-115)|Potential NPE in QuorumCnxManager|
+|[ZOOKEEPER-114](https://issues.apache.org/jira/browse/ZOOKEEPER-114)|cleanup ugly event messages in zookeeper client|
+|[ZOOKEEPER-112](https://issues.apache.org/jira/browse/ZOOKEEPER-112)|src/java/main ZooKeeper.java has test code embedded into it.|
+|[ZOOKEEPER-39](https://issues.apache.org/jira/browse/ZOOKEEPER-39)|Use Watcher objects rather than boolean on read operations.|
+|[ZOOKEEPER-97](https://issues.apache.org/jira/browse/ZOOKEEPER-97)|supports optional output directory in code generator.|
+|[ZOOKEEPER-101](https://issues.apache.org/jira/browse/ZOOKEEPER-101)|Integrate ZooKeeper with "violations" feature on hudson|
+|[ZOOKEEPER-105](https://issues.apache.org/jira/browse/ZOOKEEPER-105)|Catch Zookeeper exceptions and print on the stderr.|
+|[ZOOKEEPER-42](https://issues.apache.org/jira/browse/ZOOKEEPER-42)|Change Leader Election to fast tcp.|
+|[ZOOKEEPER-48](https://issues.apache.org/jira/browse/ZOOKEEPER-48)|auth_id now handled correctly when no auth ids present|
+|[ZOOKEEPER-44](https://issues.apache.org/jira/browse/ZOOKEEPER-44)|Create sequence flag children with prefixes of 0's so that they can be lexicographically sorted.|
+|[ZOOKEEPER-108](https://issues.apache.org/jira/browse/ZOOKEEPER-108)|Fix sync operation reordering on a Quorum.|
+|[ZOOKEEPER-25](https://issues.apache.org/jira/browse/ZOOKEEPER-25)|Fuse module for Zookeeper.|
+|[ZOOKEEPER-58](https://issues.apache.org/jira/browse/ZOOKEEPER-58)|Race condition on ClientCnxn.java|
+|[ZOOKEEPER-56](https://issues.apache.org/jira/browse/ZOOKEEPER-56)|Add clover support to build.xml.|
+|[ZOOKEEPER-75](https://issues.apache.org/jira/browse/ZOOKEEPER-75)|register the ZooKeeper mailing lists with nabble.com|
+|[ZOOKEEPER-54](https://issues.apache.org/jira/browse/ZOOKEEPER-54)|remove sleeps in the tests.|
+|[ZOOKEEPER-55](https://issues.apache.org/jira/browse/ZOOKEEPER-55)|build.xml fails to retrieve a release number from SVN and the ant target "dist" fails|
+|[ZOOKEEPER-89](https://issues.apache.org/jira/browse/ZOOKEEPER-89)|invoke WhenOwnerListener.whenNotOwner when the ZK connection fails|
+|[ZOOKEEPER-90](https://issues.apache.org/jira/browse/ZOOKEEPER-90)|invoke WhenOwnerListener.whenNotOwner when the ZK session expires and the znode is the leader|
+|[ZOOKEEPER-82](https://issues.apache.org/jira/browse/ZOOKEEPER-82)|Make the ZooKeeperServer more DI friendly.|
+|[ZOOKEEPER-110](https://issues.apache.org/jira/browse/ZOOKEEPER-110)|Build script relies on svnant, which is not compatible with subversion 1.5 working copies|
+|[ZOOKEEPER-111](https://issues.apache.org/jira/browse/ZOOKEEPER-111)|Significant cleanup of existing tests.|
+|[ZOOKEEPER-122](https://issues.apache.org/jira/browse/ZOOKEEPER-122)|Fix NPE in jute's Utils.toCSVString.|
+|[ZOOKEEPER-123](https://issues.apache.org/jira/browse/ZOOKEEPER-123)|Fix the wrong class is specified for the logger.|
+|[ZOOKEEPER-2](https://issues.apache.org/jira/browse/ZOOKEEPER-2)|Fix synchronization issues in QuorumPeer and FastLeader election.|
+|[ZOOKEEPER-125](https://issues.apache.org/jira/browse/ZOOKEEPER-125)|Remove unwanted class declaration in FastLeaderElection.|
+|[ZOOKEEPER-61](https://issues.apache.org/jira/browse/ZOOKEEPER-61)|Address in client/server test cases.|
+|[ZOOKEEPER-75](https://issues.apache.org/jira/browse/ZOOKEEPER-75)|cleanup the library directory|
+|[ZOOKEEPER-109](https://issues.apache.org/jira/browse/ZOOKEEPER-109)|cleanup of NPE and Resource issue nits found by static analysis|
+|[ZOOKEEPER-76](https://issues.apache.org/jira/browse/ZOOKEEPER-76)|Commit 677109 removed the cobertura library, but not the build targets.|
+|[ZOOKEEPER-63](https://issues.apache.org/jira/browse/ZOOKEEPER-63)|Race condition in client close|
+|[ZOOKEEPER-70](https://issues.apache.org/jira/browse/ZOOKEEPER-70)|Add skeleton forrest doc structure for ZooKeeper|
+|[ZOOKEEPER-79](https://issues.apache.org/jira/browse/ZOOKEEPER-79)|Document jacob's leader election on the wiki recipes page|
+|[ZOOKEEPER-73](https://issues.apache.org/jira/browse/ZOOKEEPER-73)|Move ZK wiki from SourceForge to Apache|
+|[ZOOKEEPER-72](https://issues.apache.org/jira/browse/ZOOKEEPER-72)|Initial creation/setup of ZooKeeper ASF site.|
+|[ZOOKEEPER-71](https://issues.apache.org/jira/browse/ZOOKEEPER-71)|Determine what to do re ZooKeeper Changelog|
+|[ZOOKEEPER-68](https://issues.apache.org/jira/browse/ZOOKEEPER-68)|parseACLs in ZooKeeper.java fails to parse elements of ACL, should be lastIndexOf rather than IndexOf|
+|[ZOOKEEPER-130](https://issues.apache.org/jira/browse/ZOOKEEPER-130)|update build.xml to support apache release process.|
+|[ZOOKEEPER-131](https://issues.apache.org/jira/browse/ZOOKEEPER-131)|Fix Old leader election can elect a dead leader over and over again.|
+|[ZOOKEEPER-137](https://issues.apache.org/jira/browse/ZOOKEEPER-137)|client watcher objects can lose events|
+|[ZOOKEEPER-117](https://issues.apache.org/jira/browse/ZOOKEEPER-117)|threading issues in Leader election|
+|[ZOOKEEPER-128](https://issues.apache.org/jira/browse/ZOOKEEPER-128)|test coverage on async client operations needs to be improved|
+|[ZOOKEEPER-127](https://issues.apache.org/jira/browse/ZOOKEEPER-127)|Use of non-standard election ports in config breaks services|
+|[ZOOKEEPER-53](https://issues.apache.org/jira/browse/ZOOKEEPER-53)|tests failing on solaris.|
+|[ZOOKEEPER-172](https://issues.apache.org/jira/browse/ZOOKEEPER-172)|FLE Test|
+|[ZOOKEEPER-41](https://issues.apache.org/jira/browse/ZOOKEEPER-41)|Sample startup script|
+|[ZOOKEEPER-33](https://issues.apache.org/jira/browse/ZOOKEEPER-33)|Better ACL management|
+|[ZOOKEEPER-49](https://issues.apache.org/jira/browse/ZOOKEEPER-49)|SetACL does not work|
+|[ZOOKEEPER-20](https://issues.apache.org/jira/browse/ZOOKEEPER-20)|Child watches are not triggered when the node is deleted|
+|[ZOOKEEPER-15](https://issues.apache.org/jira/browse/ZOOKEEPER-15)|handle failure better in build.xml:test|
+|[ZOOKEEPER-11](https://issues.apache.org/jira/browse/ZOOKEEPER-11)|ArrayList is used instead of List|
+|[ZOOKEEPER-45](https://issues.apache.org/jira/browse/ZOOKEEPER-45)|Restructure the SVN repository after initial import |
+|[ZOOKEEPER-1](https://issues.apache.org/jira/browse/ZOOKEEPER-1)|Initial ZooKeeper code contribution from Yahoo!|
diff --git a/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/basic.css b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/basic.css
new file mode 100644
index 0000000000000000000000000000000000000000..01c383da891a8c2102732a2db4758fd00badaff4
--- /dev/null
+++ b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/basic.css
@@ -0,0 +1,167 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+/**
+ * General
+ */
+
+img { border: 0; }
+
+#content table {
+ border: 0;
+ width: 100%;
+}
+/*Hack to get IE to render the table at 100%*/
+* html #content table { margin-left: -3px; }
+
+#content th,
+#content td {
+ margin: 0;
+ padding: 0;
+ vertical-align: top;
+}
+
+.clearboth {
+ clear: both;
+}
+
+.note, .warning, .fixme {
+ clear:right;
+ border: solid black 1px;
+ margin: 1em 3em;
+}
+
+.note .label {
+ background: #369;
+ color: white;
+ font-weight: bold;
+ padding: 5px 10px;
+}
+.note .content {
+ background: #F0F0FF;
+ color: black;
+ line-height: 120%;
+ font-size: 90%;
+ padding: 5px 10px;
+}
+.warning .label {
+ background: #C00;
+ color: white;
+ font-weight: bold;
+ padding: 5px 10px;
+}
+.warning .content {
+ background: #FFF0F0;
+ color: black;
+ line-height: 120%;
+ font-size: 90%;
+ padding: 5px 10px;
+}
+.fixme .label {
+ background: #C6C600;
+ color: black;
+ font-weight: bold;
+ padding: 5px 10px;
+}
+.fixme .content {
+ padding: 5px 10px;
+}
+
+/**
+ * Typography
+ */
+
+body {
+ font-family: verdana, "Trebuchet MS", arial, helvetica, sans-serif;
+ font-size: 100%;
+}
+
+#content {
+ font-family: Georgia, Palatino, Times, serif;
+ font-size: 95%;
+}
+#tabs {
+ font-size: 70%;
+}
+#menu {
+ font-size: 80%;
+}
+#footer {
+ font-size: 70%;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ font-family: "Trebuchet MS", verdana, arial, helvetica, sans-serif;
+ font-weight: bold;
+ margin-top: 1em;
+ margin-bottom: .5em;
+}
+
+h1 {
+ margin-top: 0;
+ margin-bottom: 1em;
+ font-size: 1.4em;
+}
+#content h1 {
+ font-size: 160%;
+ margin-bottom: .5em;
+}
+#menu h1 {
+ margin: 0;
+ padding: 10px;
+ background: #336699;
+ color: white;
+}
+h2 { font-size: 120%; }
+h3 { font-size: 100%; }
+h4 { font-size: 90%; }
+h5 { font-size: 80%; }
+h6 { font-size: 75%; }
+
+p {
+ line-height: 120%;
+ text-align: left;
+ margin-top: .5em;
+ margin-bottom: 1em;
+}
+
+#content li,
+#content th,
+#content td,
+#content li ul,
+#content li ol{
+ margin-top: .5em;
+ margin-bottom: .5em;
+}
+
+
+#content li li,
+#minitoc-area li{
+ margin-top: 0em;
+ margin-bottom: 0em;
+}
+
+#content .attribution {
+ text-align: right;
+ font-style: italic;
+ font-size: 85%;
+ margin-top: 1em;
+}
+
+.codefrag {
+ font-family: "Courier New", Courier, monospace;
+ font-size: 110%;
+}
\ No newline at end of file
diff --git a/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/getBlank.js b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/getBlank.js
new file mode 100644
index 0000000000000000000000000000000000000000..d9978c0b3e6d6f184928133a1cf6e4340f35c930
--- /dev/null
+++ b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/getBlank.js
@@ -0,0 +1,40 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+/**
+ * getBlank script - when included in a html file and called from a form text field, will set the value of this field to ""
+ * if the text value is still the standard value.
+ * getPrompt script - when included in a html file and called from a form text field, will set the value of this field to the prompt
+ * if the text value is empty.
+ *
+ * Typical usage:
+ *
+ *
+ */
+
diff --git a/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/print.css b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/print.css
new file mode 100644
index 0000000000000000000000000000000000000000..aaa99319acdf30b5b6ce2ec9b6967c6ad704a27b
--- /dev/null
+++ b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/print.css
@@ -0,0 +1,54 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+body {
+ font-family: Georgia, Palatino, serif;
+ font-size: 12pt;
+ background: white;
+}
+
+#tabs,
+#menu,
+#content .toc {
+ display: none;
+}
+
+#content {
+ width: auto;
+ padding: 0;
+ float: none !important;
+ color: black;
+ background: inherit;
+}
+
+a:link, a:visited {
+ color: #336699;
+ background: inherit;
+ text-decoration: underline;
+}
+
+#top .logo {
+ padding: 0;
+ margin: 0 0 2em 0;
+}
+
+#footer {
+ margin-top: 4em;
+}
+
+acronym {
+ border: 0;
+}
\ No newline at end of file
diff --git a/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/profile.css b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/profile.css
new file mode 100644
index 0000000000000000000000000000000000000000..190e74f32ac81c2e71fb7ac7dfae8b352f70e816
--- /dev/null
+++ b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/profile.css
@@ -0,0 +1,159 @@
+
+
+/* ==================== aural ============================ */
+
+@media aural {
+ h1, h2, h3, h4, h5, h6 { voice-family: paul, male; stress: 20; richness: 90 }
+ h1 { pitch: x-low; pitch-range: 90 }
+ h2 { pitch: x-low; pitch-range: 80 }
+ h3 { pitch: low; pitch-range: 70 }
+ h4 { pitch: medium; pitch-range: 60 }
+ h5 { pitch: medium; pitch-range: 50 }
+ h6 { pitch: medium; pitch-range: 40 }
+ li, dt, dd { pitch: medium; richness: 60 }
+ dt { stress: 80 }
+ pre, code, tt { pitch: medium; pitch-range: 0; stress: 0; richness: 80 }
+ em { pitch: medium; pitch-range: 60; stress: 60; richness: 50 }
+ strong { pitch: medium; pitch-range: 60; stress: 90; richness: 90 }
+ dfn { pitch: high; pitch-range: 60; stress: 60 }
+ s, strike { richness: 0 }
+ i { pitch: medium; pitch-range: 60; stress: 60; richness: 50 }
+ b { pitch: medium; pitch-range: 60; stress: 90; richness: 90 }
+ u { richness: 0 }
+
+ :link { voice-family: harry, male }
+ :visited { voice-family: betty, female }
+ :active { voice-family: betty, female; pitch-range: 80; pitch: x-high }
+}
+
+#top { background-color: #FFFFFF;}
+
+#top .header .current { background-color: #4C6C8F;}
+#top .header .current a:link { color: #ffffff; }
+#top .header .current a:visited { color: #ffffff; }
+#top .header .current a:hover { color: #ffffff; }
+
+#tabs li { background-color: #E5E4D9 ;}
+#tabs li a:link { color: #000000; }
+#tabs li a:visited { color: #000000; }
+#tabs li a:hover { color: #000000; }
+
+#level2tabs a.selected { background-color: #4C6C8F ;}
+#level2tabs a:link { color: #ffffff; }
+#level2tabs a:visited { color: #ffffff; }
+#level2tabs a:hover { color: #ffffff; }
+
+#level2tabs { background-color: #E5E4D9;}
+#level2tabs a.unselected:link { color: #000000; }
+#level2tabs a.unselected:visited { color: #000000; }
+#level2tabs a.unselected:hover { color: #000000; }
+
+.heading { background-color: #E5E4D9;}
+
+.boxed { background-color: #E5E4D9;}
+.underlined_5 {border-bottom: solid 5px #E5E4D9;}
+.underlined_10 {border-bottom: solid 10px #E5E4D9;}
+table caption {
+background-color: #E5E4D9;
+color: #000000;
+}
+
+#feedback {
+color: #FFFFFF;
+background: #4C6C8F;
+text-align: center;
+}
+#feedback #feedbackto {
+color: #FFFFFF;
+}
+
+#publishedStrip {
+color: #FFFFFF;
+background: #4C6C8F;
+}
+
+#publishedStrip {
+color: #000000;
+background: #E5E4D9;
+}
+
+#menu a.selected { background-color: #CFDCED;
+ border-color: #999999;
+ color: #000000;}
+#menu a.selected:visited { color: #000000;}
+
+#menu { border-color: #999999;}
+#menu .menupageitemgroup { border-color: #999999;}
+
+#menu { background-color: #4C6C8F;}
+#menu { color: #ffffff;}
+#menu a:link { color: #ffffff;}
+#menu a:visited { color: #ffffff;}
+#menu a:hover {
+background-color: #4C6C8F;
+color: #ffffff;}
+
+#menu h1 {
+color: #000000;
+background-color: #cfdced;
+}
+
+#top .searchbox {
+background-color: #E5E4D9 ;
+color: #000000;
+}
+
+#menu .menupageitemgroup {
+background-color: #E5E4D9;
+}
+#menu .menupageitem {
+color: #000000;
+}
+#menu .menupageitem a:link { color: #000000;}
+#menu .menupageitem a:visited { color: #000000;}
+#menu .menupageitem a:hover {
+background-color: #E5E4D9;
+color: #000000;
+}
+
+body{
+background-color: #ffffff;
+color: #000000;
+}
+a:link { color:#0000ff}
+a:visited { color:#009999}
+a:hover { color:#6587ff}
+
+
+.ForrestTable { background-color: #ccc;}
+
+.ForrestTable td { background-color: #ffffff;}
+
+.highlight { background-color: #ffff00;}
+
+.fixme { border-color: #c60;}
+
+.note { border-color: #069;}
+
+.warning { border-color: #900;}
+
+#footer { background-color: #E5E4D9;}
+/* extra-css */
+
+ p.quote {
+ margin-left: 2em;
+ padding: .5em;
+ background-color: #f0f0f0;
+ font-family: monospace;
+ }
+
+ pre {
+ margin-left: 0em;
+ padding: 0.5em;
+ background-color: #f0f0f0;
+ font-family: monospace;
+ }
+
+
+
+
\ No newline at end of file
diff --git a/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/prototype.js b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/prototype.js
new file mode 100644
index 0000000000000000000000000000000000000000..cc89dafcd6ae69cf81adfea016a0f1a8d8341c58
--- /dev/null
+++ b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/skin/prototype.js
@@ -0,0 +1,7588 @@
+/* Prototype JavaScript framework, version 1.7.3
+ * (c) 2005-2010 Sam Stephenson
+ *
+ * Prototype is freely distributable under the terms of an MIT-style license.
+ * For details, see the Prototype web site: http://www.prototypejs.org/
+ *
+ *--------------------------------------------------------------------------*/
+
+var Prototype = {
+
+ Version: '1.7.3',
+
+ Browser: (function(){
+ var ua = navigator.userAgent;
+ var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
+ return {
+ IE: !!window.attachEvent && !isOpera,
+ Opera: isOpera,
+ WebKit: ua.indexOf('AppleWebKit/') > -1,
+ Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
+ MobileSafari: /Apple.*Mobile/.test(ua)
+ }
+ })(),
+
+ BrowserFeatures: {
+ XPath: !!document.evaluate,
+
+ SelectorsAPI: !!document.querySelector,
+
+ ElementExtensions: (function() {
+ var constructor = window.Element || window.HTMLElement;
+ return !!(constructor && constructor.prototype);
+ })(),
+ SpecificElementExtensions: (function() {
+ if (typeof window.HTMLDivElement !== 'undefined')
+ return true;
+
+ var div = document.createElement('div'),
+ form = document.createElement('form'),
+ isSupported = false;
+
+ if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) {
+ isSupported = true;
+ }
+
+ div = form = null;
+
+ return isSupported;
+ })()
+ },
+
+ ScriptFragment: '
+
+
+
+
+
+
+
+
diff --git a/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/images/state_dia.dia b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/images/state_dia.dia
new file mode 100644
index 0000000000000000000000000000000000000000..4a58a00854e382b4096a87e1c7d18137cf009898
Binary files /dev/null and b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/images/state_dia.dia differ
diff --git a/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/javaExample.md b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/javaExample.md
new file mode 100644
index 0000000000000000000000000000000000000000..a94b083d241d155135054c26085c9c1ea5071ef5
--- /dev/null
+++ b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/javaExample.md
@@ -0,0 +1,628 @@
+
+
+# ZooKeeper Java Example
+
+* [A Simple Watch Client](#ch_Introduction)
+ * [Requirements](#sc_requirements)
+ * [Program Design](#sc_design)
+* [The Executor Class](#sc_executor)
+* [The DataMonitor Class](#sc_DataMonitor)
+* [Complete Source Listings](#sc_completeSourceCode)
+
+
+
+## A Simple Watch Client
+
+To introduce you to the ZooKeeper Java API, we develop here a very simple
+watch client. This ZooKeeper client watches a znode for changes
+and responds to by starting or stopping a program.
+
+
+
+### Requirements
+
+The client has four requirements:
+
+* It takes as parameters:
+ * the address of the ZooKeeper service
+ * the name of a znode - the one to be watched
+ * the name of a file to write the output to
+ * an executable with arguments.
+* It fetches the data associated with the znode and starts the executable.
+* If the znode changes, the client re-fetches the contents and restarts the executable.
+* If the znode disappears, the client kills the executable.
+
+
+
+### Program Design
+
+Conventionally, ZooKeeper applications are broken into two units, one which maintains the connection,
+and the other which monitors data. In this application, the class called the **Executor**
+maintains the ZooKeeper connection, and the class called the **DataMonitor** monitors the data
+in the ZooKeeper tree. Also, Executor contains the main thread and contains the execution logic.
+It is responsible for what little user interaction there is, as well as interaction with the executable program you
+pass in as an argument and which the sample (per the requirements) shuts down and restarts, according to the
+state of the znode.
+
+
+
+## The Executor Class
+
+The Executor object is the primary container of the sample application. It contains
+both the **ZooKeeper** object, **DataMonitor**, as described above in
+[Program Design](#sc_design).
+
+
+ // from the Executor class...
+
+ public static void main(String[] args) {
+ if (args.length < 4) {
+ System.err
+ .println("USAGE: Executor hostPort znode filename program [args ...]");
+ System.exit(2);
+ }
+ String hostPort = args[0];
+ String znode = args[1];
+ String filename = args[2];
+ String exec[] = new String[args.length - 3];
+ System.arraycopy(args, 3, exec, 0, exec.length);
+ try {
+ new Executor(hostPort, znode, filename, exec).run();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Executor(String hostPort, String znode, String filename,
+ String exec[]) throws KeeperException, IOException {
+ this.filename = filename;
+ this.exec = exec;
+ zk = new ZooKeeper(hostPort, 3000, this);
+ dm = new DataMonitor(zk, znode, null, this);
+ }
+
+ public void run() {
+ try {
+ synchronized (this) {
+ while (!dm.dead) {
+ wait();
+ }
+ }
+ } catch (InterruptedException e) {
+ }
+ }
+
+
+Recall that the Executor's job is to start and stop the executable whose name you pass in on the command line.
+It does this in response to events fired by the ZooKeeper object. As you can see in the code above, the Executor passes
+a reference to itself as the Watcher argument in the ZooKeeper constructor. It also passes a reference to itself
+as DataMonitorListener argument to the DataMonitor constructor. Per the Executor's definition, it implements both these
+interfaces:
+
+ public class Executor implements Watcher, Runnable, DataMonitor.DataMonitorListener {
+ ...
+
+
+The **Watcher** interface is defined by the ZooKeeper Java API.
+ZooKeeper uses it to communicate back to its container. It supports only one method, `process()`,
+and ZooKeeper uses it to communicates generic events that the main thread would be interested in,
+such as the state of the ZooKeeper connection or the ZooKeeper session. The Executor in this example simply
+forwards those events down to the DataMonitor to decide what to do with them. It does this simply to illustrate
+the point that, by convention, the Executor or some Executor-like object "owns" the ZooKeeper connection, but it is
+free to delegate the events to other events to other objects. It also uses this as the default channel on which
+to fire watch events. (More on this later.)
+
+
+ public void process(WatchedEvent event) {
+ dm.process(event);
+ }
+
+
+The **DataMonitorListener**
+interface, on the other hand, is not part of the ZooKeeper API. It is a completely custom interface,
+designed for this sample application. The DataMonitor object uses it to communicate back to its container, which
+is also the Executor object. The DataMonitorListener interface looks like this:
+
+
+ public interface DataMonitorListener {
+ /**
+ * The existence status of the node has changed.
+ */
+ void exists(byte data[]);
+
+ /**
+ * The ZooKeeper session is no longer valid.
+ *
+ * @param rc
+ * the ZooKeeper reason code
+ */
+ void closing(int rc);
+ }
+
+
+This interface is defined in the DataMonitor class and implemented in the Executor class.
+When `Executor.exists()` is invoked, the Executor decides whether to start up or shut down per the requirements.
+Recall that the requires say to kill the executable when the znode ceases to _exist_.
+
+When `Executor.closing()` is invoked, the Executor decides whether or not to shut itself down
+in response to the ZooKeeper connection permanently disappearing.
+
+As you might have guessed, DataMonitor is the object that invokes
+these methods, in response to changes in ZooKeeper's state.
+
+Here are Executor's implementation of
+`DataMonitorListener.exists()` and `DataMonitorListener.closing`:
+
+
+ public void exists( byte[] data ) {
+ if (data == null) {
+ if (child != null) {
+ System.out.println("Killing process");
+ child.destroy();
+ try {
+ child.waitFor();
+ } catch (InterruptedException e) {
+ }
+ }
+ child = null;
+ } else {
+ if (child != null) {
+ System.out.println("Stopping child");
+ child.destroy();
+ try {
+ child.waitFor();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ try {
+ FileOutputStream fos = new FileOutputStream(filename);
+ fos.write(data);
+ fos.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ try {
+ System.out.println("Starting child");
+ child = Runtime.getRuntime().exec(exec);
+ new StreamWriter(child.getInputStream(), System.out);
+ new StreamWriter(child.getErrorStream(), System.err);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void closing(int rc) {
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+
+
+
+
+## The DataMonitor Class
+
+The DataMonitor class has the meat of the ZooKeeper logic. It is mostly
+asynchronous and event driven. DataMonitor kicks things off in the constructor with:
+
+
+ public DataMonitor(ZooKeeper zk, String znode, Watcher chainedWatcher,
+ DataMonitorListener listener) {
+ this.zk = zk;
+ this.znode = znode;
+ this.chainedWatcher = chainedWatcher;
+ this.listener = listener;
+
+ // Get things started by checking if the node exists. We are going
+ // to be completely event driven
+
+
+The call to `ZooKeeper.exists()` checks for the existence of the znode,
+sets a watch, and passes a reference to itself (`this`)
+as the completion callback object. In this sense, it kicks things off, since the
+real processing happens when the watch is triggered.
+
+###### Note
+
+>Don't confuse the completion callback with the watch callback. The `ZooKeeper.exists()`
+completion callback, which happens to be the method `StatCallback.processResult()` implemented
+in the DataMonitor object, is invoked when the asynchronous _setting of the watch_ operation
+(by `ZooKeeper.exists()`) completes on the server.
+
+>The triggering of the watch, on the other hand, sends an event to the _Executor_ object, since
+the Executor registered as the Watcher of the ZooKeeper object.
+
+>As an aside, you might note that the DataMonitor could also register itself as the Watcher
+for this particular watch event. This is new to ZooKeeper 3.0.0 (the support of multiple Watchers). In this
+example, however, DataMonitor does not register as the Watcher.
+
+When the `ZooKeeper.exists()` operation completes on the server, the ZooKeeper API invokes this completion callback on
+the client:
+
+
+ public void processResult(int rc, String path, Object ctx, Stat stat) {
+ boolean exists;
+ switch (rc) {
+ case Code.Ok:
+ exists = true;
+ break;
+ case Code.NoNode:
+ exists = false;
+ break;
+ case Code.SessionExpired:
+ case Code.NoAuth:
+ dead = true;
+ listener.closing(rc);
+ return;
+ default:
+ // Retry errors
+ zk.exists(znode, true, this, null);
+ return;
+ }
+
+ byte b[] = null;
+ if (exists) {
+ try {
+ b = zk.getData(znode, false, null);
+ } catch (KeeperException e) {
+ // We don't need to worry about recovering now. The watch
+ // callbacks will kick off any exception handling
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ return;
+ }
+ }
+ if ((b == null && b != prevData)
+ || (b != null && !Arrays.equals(prevData, b))) {
+ listener.exists(b);
+ prevData = b;
+ }
+ }
+
+
+The code first checks the error codes for znode existence, fatal errors, and
+recoverable errors. If the file (or znode) exists, it gets the data from the znode, and
+then invoke the exists() callback of Executor if the state has changed. Note,
+it doesn't have to do any Exception processing for the getData call because it
+has watches pending for anything that could cause an error: if the node is deleted
+before it calls `ZooKeeper.getData()`, the watch event set by
+the `ZooKeeper.exists()` triggers a callback;
+if there is a communication error, a connection watch event fires when
+the connection comes back up.
+
+Finally, notice how DataMonitor processes watch events:
+
+
+ public void process(WatchedEvent event) {
+ String path = event.getPath();
+ if (event.getType() == Event.EventType.None) {
+ // We are are being told that the state of the
+ // connection has changed
+ switch (event.getState()) {
+ case SyncConnected:
+ // In this particular example we don't need to do anything
+ // here - watches are automatically re-registered with
+ // server and any watches triggered while the client was
+ // disconnected will be delivered (in order of course)
+ break;
+ case Expired:
+ // It's all over
+ dead = true;
+ listener.closing(KeeperException.Code.SessionExpired);
+ break;
+ }
+ } else {
+ if (path != null && path.equals(znode)) {
+ // Something has changed on the node, let's find out
+ zk.exists(znode, true, this, null);
+ }
+ }
+ if (chainedWatcher != null) {
+ chainedWatcher.process(event);
+ }
+ }
+
+
+If the client-side ZooKeeper libraries can re-establish the
+communication channel (SyncConnected event) to ZooKeeper before
+session expiration (Expired event) all of the session's watches will
+automatically be re-established with the server (auto-reset of watches
+is new in ZooKeeper 3.0.0). See [ZooKeeper Watches](zookeeperProgrammers.html#ch_zkWatches)
+in the programmer guide for more on this. A bit lower down in this
+function, when DataMonitor gets an event for a znode, it calls`ZooKeeper.exists()` to find out what has changed.
+
+
+
+## Complete Source Listings
+
+### Executor.java
+
+
+ /**
+ * A simple example program to use DataMonitor to start and
+ * stop executables based on a znode. The program watches the
+ * specified znode and saves the data that corresponds to the
+ * znode in the filesystem. It also starts the specified program
+ * with the specified arguments when the znode exists and kills
+ * the program if the znode goes away.
+ */
+ import java.io.FileOutputStream;
+ import java.io.IOException;
+ import java.io.InputStream;
+ import java.io.OutputStream;
+
+ import org.apache.zookeeper.KeeperException;
+ import org.apache.zookeeper.WatchedEvent;
+ import org.apache.zookeeper.Watcher;
+ import org.apache.zookeeper.ZooKeeper;
+
+ public class Executor
+ implements Watcher, Runnable, DataMonitor.DataMonitorListener
+ {
+ String znode;
+ DataMonitor dm;
+ ZooKeeper zk;
+ String filename;
+ String exec[];
+ Process child;
+
+ public Executor(String hostPort, String znode, String filename,
+ String exec[]) throws KeeperException, IOException {
+ this.filename = filename;
+ this.exec = exec;
+ zk = new ZooKeeper(hostPort, 3000, this);
+ dm = new DataMonitor(zk, znode, null, this);
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ if (args.length < 4) {
+ System.err
+ .println("USAGE: Executor hostPort znode filename program [args ...]");
+ System.exit(2);
+ }
+ String hostPort = args[0];
+ String znode = args[1];
+ String filename = args[2];
+ String exec[] = new String[args.length - 3];
+ System.arraycopy(args, 3, exec, 0, exec.length);
+ try {
+ new Executor(hostPort, znode, filename, exec).run();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /***************************************************************************
+ * We do process any events ourselves, we just need to forward them on.
+ *
+ * @see org.apache.zookeeper.Watcher#process(org.apache.zookeeper.proto.WatcherEvent)
+ */
+ public void process(WatchedEvent event) {
+ dm.process(event);
+ }
+
+ public void run() {
+ try {
+ synchronized (this) {
+ while (!dm.dead) {
+ wait();
+ }
+ }
+ } catch (InterruptedException e) {
+ }
+ }
+
+ public void closing(int rc) {
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+
+ static class StreamWriter extends Thread {
+ OutputStream os;
+
+ InputStream is;
+
+ StreamWriter(InputStream is, OutputStream os) {
+ this.is = is;
+ this.os = os;
+ start();
+ }
+
+ public void run() {
+ byte b[] = new byte[80];
+ int rc;
+ try {
+ while ((rc = is.read(b)) > 0) {
+ os.write(b, 0, rc);
+ }
+ } catch (IOException e) {
+ }
+
+ }
+ }
+
+ public void exists(byte[] data) {
+ if (data == null) {
+ if (child != null) {
+ System.out.println("Killing process");
+ child.destroy();
+ try {
+ child.waitFor();
+ } catch (InterruptedException e) {
+ }
+ }
+ child = null;
+ } else {
+ if (child != null) {
+ System.out.println("Stopping child");
+ child.destroy();
+ try {
+ child.waitFor();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ try {
+ FileOutputStream fos = new FileOutputStream(filename);
+ fos.write(data);
+ fos.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ try {
+ System.out.println("Starting child");
+ child = Runtime.getRuntime().exec(exec);
+ new StreamWriter(child.getInputStream(), System.out);
+ new StreamWriter(child.getErrorStream(), System.err);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+
+### DataMonitor.java
+
+
+ /**
+ * A simple class that monitors the data and existence of a ZooKeeper
+ * node. It uses asynchronous ZooKeeper APIs.
+ */
+ import java.util.Arrays;
+
+ import org.apache.zookeeper.KeeperException;
+ import org.apache.zookeeper.WatchedEvent;
+ import org.apache.zookeeper.Watcher;
+ import org.apache.zookeeper.ZooKeeper;
+ import org.apache.zookeeper.AsyncCallback.StatCallback;
+ import org.apache.zookeeper.KeeperException.Code;
+ import org.apache.zookeeper.data.Stat;
+
+ public class DataMonitor implements Watcher, StatCallback {
+
+ ZooKeeper zk;
+ String znode;
+ Watcher chainedWatcher;
+ boolean dead;
+ DataMonitorListener listener;
+ byte prevData[];
+
+ public DataMonitor(ZooKeeper zk, String znode, Watcher chainedWatcher,
+ DataMonitorListener listener) {
+ this.zk = zk;
+ this.znode = znode;
+ this.chainedWatcher = chainedWatcher;
+ this.listener = listener;
+ // Get things started by checking if the node exists. We are going
+ // to be completely event driven
+ zk.exists(znode, true, this, null);
+ }
+
+ /**
+ * Other classes use the DataMonitor by implementing this method
+ */
+ public interface DataMonitorListener {
+ /**
+ * The existence status of the node has changed.
+ */
+ void exists(byte data[]);
+
+ /**
+ * The ZooKeeper session is no longer valid.
+ *
+ * @param rc
+ * the ZooKeeper reason code
+ */
+ void closing(int rc);
+ }
+
+ public void process(WatchedEvent event) {
+ String path = event.getPath();
+ if (event.getType() == Event.EventType.None) {
+ // We are are being told that the state of the
+ // connection has changed
+ switch (event.getState()) {
+ case SyncConnected:
+ // In this particular example we don't need to do anything
+ // here - watches are automatically re-registered with
+ // server and any watches triggered while the client was
+ // disconnected will be delivered (in order of course)
+ break;
+ case Expired:
+ // It's all over
+ dead = true;
+ listener.closing(KeeperException.Code.SessionExpired);
+ break;
+ }
+ } else {
+ if (path != null && path.equals(znode)) {
+ // Something has changed on the node, let's find out
+ zk.exists(znode, true, this, null);
+ }
+ }
+ if (chainedWatcher != null) {
+ chainedWatcher.process(event);
+ }
+ }
+
+ public void processResult(int rc, String path, Object ctx, Stat stat) {
+ boolean exists;
+ switch (rc) {
+ case Code.Ok:
+ exists = true;
+ break;
+ case Code.NoNode:
+ exists = false;
+ break;
+ case Code.SessionExpired:
+ case Code.NoAuth:
+ dead = true;
+ listener.closing(rc);
+ return;
+ default:
+ // Retry errors
+ zk.exists(znode, true, this, null);
+ return;
+ }
+
+ byte b[] = null;
+ if (exists) {
+ try {
+ b = zk.getData(znode, false, null);
+ } catch (KeeperException e) {
+ // We don't need to worry about recovering now. The watch
+ // callbacks will kick off any exception handling
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ return;
+ }
+ }
+ if ((b == null && b != prevData)
+ || (b != null && !Arrays.equals(prevData, b))) {
+ listener.exists(b);
+ prevData = b;
+ }
+ }
+ }
+
diff --git a/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/releasenotes.md b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/releasenotes.md
new file mode 100644
index 0000000000000000000000000000000000000000..a27b6ffdd12640e449ede8d2c90417e96eef28a8
--- /dev/null
+++ b/local-test-zookeeper-delta-01/afc-zookeeper/zookeeper-docs/src/main/resources/markdown/releasenotes.md
@@ -0,0 +1,267 @@
+
+
+# ZooKeeper 3.0.0 Release Notes
+
+* [Migration Instructions when Upgrading to 3.0.0](#migration)
+ * [Migrating Client Code](#migration_code)
+ * [Watch Management](#Watch+Management)
+ * [Java API](#Java+API)
+ * [C API](#C+API)
+ * [Migrating Server Data](#migration_data)
+ * [Migrating Server Configuration](#migration_config)
+* [Changes Since ZooKeeper 2.2.1](#changes)
+
+These release notes include new developer and user facing incompatibilities, features, and major improvements.
+
+* [Migration Instructions](#migration)
+* [Changes](#changes)
+
+
+## Migration Instructions when Upgrading to 3.0.0
+
