You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by an...@apache.org on 2018/07/04 11:02:41 UTC
[13/13] zookeeper git commit: ZOOKEEPER-3022: MAVEN MIGRATION -
Iteration 1 - docs, it
ZOOKEEPER-3022: MAVEN MIGRATION - Iteration 1 - docs, it
First iteration of the directory changes in maven migration.
This time, the empty zookeeper-it for future integration tests were created, and the docs source were moved to zookeeper-docs.
Tested with forest v0.9, documents generations were successful with ant.
Author: Norbert Kalmar <nk...@yahoo.com>
Reviewers: Andor Molnar <an...@apache.org>
Closes #550 from nkalmar/ZOOKEEPER-3022-1
Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/4607a3e1
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/4607a3e1
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/4607a3e1
Branch: refs/heads/master
Commit: 4607a3e156f36c52349bfb370e879dbd9e4d0691
Parents: 3465e0c
Author: Norbert Kalmar <nk...@yahoo.com>
Authored: Wed Jul 4 13:02:19 2018 +0200
Committer: Andor Molnar <an...@apache.org>
Committed: Wed Jul 4 13:02:19 2018 +0200
----------------------------------------------------------------------
build.xml | 2 +-
src/docs/forrest.properties | 109 -
src/docs/src/documentation/README.txt | 7 -
src/docs/src/documentation/TODO.txt | 227 --
.../classes/CatalogManager.properties | 37 -
src/docs/src/documentation/conf/cli.xconf | 328 ---
.../src/documentation/content/xdocs/index.xml | 87 -
.../documentation/content/xdocs/javaExample.xml | 664 -----
.../src/documentation/content/xdocs/recipes.xml | 688 -----
.../src/documentation/content/xdocs/site.xml | 97 -
.../src/documentation/content/xdocs/tabs.xml | 36 -
.../content/xdocs/zookeeperAdmin.xml | 2353 ------------------
.../xdocs/zookeeperHierarchicalQuorums.xml | 75 -
.../content/xdocs/zookeeperInternals.xml | 487 ----
.../content/xdocs/zookeeperJMX.xml | 236 --
.../content/xdocs/zookeeperObservers.xml | 145 --
.../content/xdocs/zookeeperOtherInfo.xml | 46 -
.../content/xdocs/zookeeperOver.xml | 464 ----
.../content/xdocs/zookeeperProgrammers.xml | 2008 ---------------
.../content/xdocs/zookeeperQuotas.xml | 71 -
.../content/xdocs/zookeeperReconfig.xml | 878 -------
.../content/xdocs/zookeeperStarted.xml | 419 ----
.../content/xdocs/zookeeperTutorial.xml | 712 ------
.../src/documentation/resources/images/2pc.jpg | Bin 15174 -> 0 bytes
.../resources/images/bk-overview.jpg | Bin 124211 -> 0 bytes
.../documentation/resources/images/favicon.ico | Bin 766 -> 0 bytes
.../resources/images/hadoop-logo.jpg | Bin 9443 -> 0 bytes
.../resources/images/state_dia.dia | Bin 2597 -> 0 bytes
.../resources/images/state_dia.jpg | Bin 51364 -> 0 bytes
.../documentation/resources/images/zkarch.jpg | Bin 24535 -> 0 bytes
.../resources/images/zkcomponents.jpg | Bin 30831 -> 0 bytes
.../resources/images/zknamespace.jpg | Bin 35414 -> 0 bytes
.../resources/images/zkperfRW-3.2.jpg | Bin 41948 -> 0 bytes
.../documentation/resources/images/zkperfRW.jpg | Bin 161542 -> 0 bytes
.../resources/images/zkperfreliability.jpg | Bin 69825 -> 0 bytes
.../resources/images/zkservice.jpg | Bin 86790 -> 0 bytes
.../resources/images/zookeeper_small.gif | Bin 4847 -> 0 bytes
src/docs/src/documentation/skinconf.xml | 360 ---
src/docs/status.xml | 74 -
zookeeper-docs/forrest.properties | 109 +
zookeeper-docs/src/documentation/README.txt | 7 +
zookeeper-docs/src/documentation/TODO.txt | 227 ++
.../classes/CatalogManager.properties | 37 +
zookeeper-docs/src/documentation/conf/cli.xconf | 328 +++
.../src/documentation/content/xdocs/index.xml | 87 +
.../documentation/content/xdocs/javaExample.xml | 664 +++++
.../src/documentation/content/xdocs/recipes.xml | 688 +++++
.../src/documentation/content/xdocs/site.xml | 97 +
.../src/documentation/content/xdocs/tabs.xml | 36 +
.../content/xdocs/zookeeperAdmin.xml | 2353 ++++++++++++++++++
.../xdocs/zookeeperHierarchicalQuorums.xml | 75 +
.../content/xdocs/zookeeperInternals.xml | 487 ++++
.../content/xdocs/zookeeperJMX.xml | 236 ++
.../content/xdocs/zookeeperObservers.xml | 145 ++
.../content/xdocs/zookeeperOtherInfo.xml | 46 +
.../content/xdocs/zookeeperOver.xml | 464 ++++
.../content/xdocs/zookeeperProgrammers.xml | 2008 +++++++++++++++
.../content/xdocs/zookeeperQuotas.xml | 71 +
.../content/xdocs/zookeeperReconfig.xml | 878 +++++++
.../content/xdocs/zookeeperStarted.xml | 419 ++++
.../content/xdocs/zookeeperTutorial.xml | 712 ++++++
.../src/documentation/resources/images/2pc.jpg | Bin 0 -> 15174 bytes
.../resources/images/bk-overview.jpg | Bin 0 -> 124211 bytes
.../documentation/resources/images/favicon.ico | Bin 0 -> 766 bytes
.../resources/images/hadoop-logo.jpg | Bin 0 -> 9443 bytes
.../resources/images/state_dia.dia | Bin 0 -> 2597 bytes
.../resources/images/state_dia.jpg | Bin 0 -> 51364 bytes
.../documentation/resources/images/zkarch.jpg | Bin 0 -> 24535 bytes
.../resources/images/zkcomponents.jpg | Bin 0 -> 30831 bytes
.../resources/images/zknamespace.jpg | Bin 0 -> 35414 bytes
.../resources/images/zkperfRW-3.2.jpg | Bin 0 -> 41948 bytes
.../documentation/resources/images/zkperfRW.jpg | Bin 0 -> 161542 bytes
.../resources/images/zkperfreliability.jpg | Bin 0 -> 69825 bytes
.../resources/images/zkservice.jpg | Bin 0 -> 86790 bytes
.../resources/images/zookeeper_small.gif | Bin 0 -> 4847 bytes
zookeeper-docs/src/documentation/skinconf.xml | 360 +++
zookeeper-docs/status.xml | 74 +
zookeeper-it/.empty | 0
78 files changed, 10609 insertions(+), 10609 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/4607a3e1/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 0e13910..eac3e2b 100644
--- a/build.xml
+++ b/build.xml
@@ -140,7 +140,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle.ant">
<property name="test.quick" value="no" />
<property name="conf.dir" value="${basedir}/conf"/>
<property name="docs.dir" value="${basedir}/docs"/>
- <property name="docs.src" value="${basedir}/src/docs"/>
+ <property name="docs.src" value="${basedir}/zookeeper-docs"/>
<property name="javadoc.link.java"
value="http://docs.oracle.com/javase/6/docs/api/" />
<property name="javadoc.packages" value="org.apache.*" />
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/4607a3e1/src/docs/forrest.properties
----------------------------------------------------------------------
diff --git a/src/docs/forrest.properties b/src/docs/forrest.properties
deleted file mode 100644
index 70cf81d..0000000
--- a/src/docs/forrest.properties
+++ /dev/null
@@ -1,109 +0,0 @@
-# Copyright 2002-2004 The Apache Software Foundation
-#
-# Licensed 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.
-
-##############
-# Properties used by forrest.build.xml for building the website
-# These are the defaults, un-comment them if you need to change them.
-##############
-
-# Prints out a summary of Forrest settings for this project
-#forrest.echo=true
-
-# Project name (used to name .war file)
-#project.name=my-project
-
-# Specifies name of Forrest skin to use
-#project.skin=tigris
-#project.skin=pelt
-
-# comma separated list, file:// is supported
-#forrest.skins.descriptors=http://forrest.apache.org/skins/skins.xml,file:///c:/myskins/skins.xml
-
-##############
-# behavioural properties
-#project.menu-scheme=tab_attributes
-#project.menu-scheme=directories
-
-##############
-# layout properties
-
-# Properties that can be set to override the default locations
-#
-# Parent properties must be set. This usually means uncommenting
-# project.content-dir if any other property using it is uncommented
-
-#project.status=status.xml
-#project.content-dir=src/documentation
-project.configfile=${project.home}/src/documentation/conf/cli.xconf
-#project.raw-content-dir=${project.content-dir}/content
-#project.conf-dir=${project.content-dir}/conf
-#project.sitemap-dir=${project.content-dir}
-#project.xdocs-dir=${project.content-dir}/content/xdocs
-#project.resources-dir=${project.content-dir}/resources
-#project.stylesheets-dir=${project.resources-dir}/stylesheets
-#project.images-dir=${project.resources-dir}/images
-#project.schema-dir=${project.resources-dir}/schema
-#project.skins-dir=${project.content-dir}/skins
-#project.skinconf=${project.content-dir}/skinconf.xml
-#project.lib-dir=${project.content-dir}/lib
-#project.classes-dir=${project.content-dir}/classes
-#project.translations-dir=${project.content-dir}/translations
-
-##############
-# validation properties
-
-# This set of properties determine if validation is performed
-# Values are inherited unless overridden.
-# e.g. if forrest.validate=false then all others are false unless set to true.
-forrest.validate=true
-forrest.validate.xdocs=${forrest.validate}
-forrest.validate.skinconf=${forrest.validate}
-forrest.validate.stylesheets=${forrest.validate}
-forrest.validate.skins=${forrest.validate}
-forrest.validate.skins.stylesheets=${forrest.validate.skins}
-
-# Make Forrest work with JDK6
-forrest.validate.sitemap=false
-
-# *.failonerror=(true|false) - stop when an XML file is invalid
-forrest.validate.failonerror=true
-
-# *.excludes=(pattern) - comma-separated list of path patterns to not validate
-# e.g.
-#forrest.validate.xdocs.excludes=samples/subdir/**, samples/faq.xml
-#forrest.validate.xdocs.excludes=
-
-
-##############
-# General Forrest properties
-
-# The URL to start crawling from
-#project.start-uri=linkmap.html
-# Set logging level for messages printed to the console
-# (DEBUG, INFO, WARN, ERROR, FATAL_ERROR)
-#project.debuglevel=ERROR
-# Max memory to allocate to Java
-#forrest.maxmemory=64m
-# Any other arguments to pass to the JVM. For example, to run on an X-less
-# server, set to -Djava.awt.headless=true
-#forrest.jvmargs=
-# The bugtracking URL - the issue number will be appended
-#project.bugtracking-url=http://issues.apache.org/bugzilla/show_bug.cgi?id=
-#project.bugtracking-url=http://issues.apache.org/jira/browse/
-# The issues list as rss
-#project.issues-rss-url=
-#I18n Property only works for the "forrest run" target.
-#project.i18n=true
-
-project.required.plugins=org.apache.forrest.plugin.output.pdf,org.apache.forrest.plugin.input.simplifiedDocbook
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/4607a3e1/src/docs/src/documentation/README.txt
----------------------------------------------------------------------
diff --git a/src/docs/src/documentation/README.txt b/src/docs/src/documentation/README.txt
deleted file mode 100644
index 9bc261b..0000000
--- a/src/docs/src/documentation/README.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-This is the base documentation directory.
-
-skinconf.xml # This file customizes Forrest for your project. In it, you
- # tell forrest the project name, logo, copyright info, etc
-
-sitemap.xmap # Optional. This sitemap is consulted before all core sitemaps.
- # See http://forrest.apache.org/docs/project-sitemap.html
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/4607a3e1/src/docs/src/documentation/TODO.txt
----------------------------------------------------------------------
diff --git a/src/docs/src/documentation/TODO.txt b/src/docs/src/documentation/TODO.txt
deleted file mode 100644
index 84e7dfa..0000000
--- a/src/docs/src/documentation/TODO.txt
+++ /dev/null
@@ -1,227 +0,0 @@
-This is a running list of todo documentation items. Feel free
-to add to the list or take on an item as you wish (in the form
-of a JIRA patch of course).
--------------------------------------------------------------
-
-recipes.xml:110:
-[maybe an illustration would be nice for each recipe?]
-
-recipes.xml:167:
-"wait for each watch event". [how do you wait?]
-
-recipes.xml:457:
-<remark>[tbd: myabe helpful to indicate which step this refers to?]</remark>
-
-zookeeperAdmin.xml:77:
-because requires a majority <remark>[tbd: why?]</remark>, it is best to use...
-
-zookeeperAdmin.xml:112:
- <screen>$yinst -i jdk-1.6.0.00_3 -br test <remark>[y! prop - replace with open equiv]</remark></screen>
-
-zookeeperAdmin.xml:99:
-- use a maximum heap size of 3GB for a 4GB machine. <remark>[tbd: where would they do this? Environment variable, etc?]</remark>
-
-zookeeperAdmin.xml:120
-<screen>$ yinst install -nostart zookeeper_server <remark>[Y! prop - replace with open eq]</remark></screen>
-
-zookeeperAdmin.xml:171:
-In Java, you can run the following command to execute simple operations:<remark> [tbd: also, maybe give some of those simple operations?]
-
-zookeeperAdmin.xml:194:
-Running either program gives you a shell in which to execute simple file-system-like operations. <remark>[tbd: again, sample
- operations?]
-
-zookeeperAdmin.xml:252:
-If servers use different configuration files,
-care must be taken to ensure that the list of servers in all of the
-standard form, with legal values, etc]</remark>
-
-zookeeperAdmin.xml:408:
-(Note: The system property has no zookeeper
-prefix, and the configuration variable name is different from
-the system property. Yes - it's not consistent, and it's
-annoying.<remark> [tbd: is there any explanation for
-this?]</remark>)
-
-zookeeperAdmin.xml:445: When the election algorithm is
- "0" a UDP port with the same port number as the port listed in
- the <emphasis role="bold">server.num</emphasis> option will be
- used. <remark>[tbd: should that be <emphasis
- role="bold">server.id</emphasis>? Also, why isn't server.id
- documented anywhere?]</remark>
-
-zookeeperAdmin.xml:481: The default to this option is yes, which
- means that a leader will accept client connections.
- <remark>[tbd: how do you specifiy which server is the
- leader?]</remark>
-
-zookeeperAdmin.xml:495 When the server
- starts up, it determines which server it is by looking for the
- file <filename>myid</filename> in the data directory.<remark>
- [tdb: should we mention somewhere about creating this file,
- myid, in the setup procedure?]</remark>
-
-zookeeperAdmin.xml:508: [tbd: is the next sentence explanation an of what the
- election port or is it a description of a special case?]
- </remark>If you want to test multiple servers on a single
- machine, the individual choices of electionPort for each
- server can be defined in each server's config files using the
- line electionPort=xxxx to avoid clashes.
-
-zookeeperAdmin.xml:524: If followers fall too far behind a
- leader, they will be dropped. <remark>[tbd: is this a correct
- rewording: if followers fall beyond this limit, they are
- dropped?]</remark>
-
-zookeeperAdmin.xml:551: ZooKeeper will not require updates
- to be synced to the media. <remark>[tbd: useful because...,
- dangerous because...]</remark>
-
-zookeeperAdmin.xml:580: Skips ACL checks. <remark>[tbd: when? where?]</remark>
-
-zookeeperAdmin.xml:649: <remark>[tbd: Patrick, Ben, et al: I believe the Message Broker
- team does perform routine monitoring of Zookeeper. But I might be
- wrong. To your knowledge, is there any monitoring of a Zookeeper
- deployment that will a Zookeeper sys admin will want to do, outside of
- Yahoo?]</remark>
-
-zookeeperAdmin.xml:755: Also,
- the server lists in each Zookeeper server configuration file
- should be consistent with one another. <remark>[tbd: I'm assuming
- this last part is true. Is it?]</remark>
-
-zookeeperAdmin.xml:812: For best results, take note of the following list of good
- Zookeeper practices. <remark>[tbd: I just threw this section in. Do we
- have list that is is different from the "things to avoid"? If not, I can
- easily remove this section.]</remark>
-
-
-zookeeperOver.xml:162: Ephemeral nodes are useful when you
- want to implement <remark>[tbd]</remark>.
-
-zookeeperOver.xml:174: And if the
- connection between the client and one of the Zoo Keeper servers is
- broken, the client will receive a local notification. These can be used
- to <remark>[tbd]</remark>
-
-zookeeperOver.xml:215: <para>For more information on these (guarantees), and how they can be used, see
- <remark>[tbd]</remark></para>
-
-zookeeperOver.xml:294: <para><xref linkend="fg_zkComponents" /> shows the high-level components
- of the ZooKeeper service. With the exception of the request processor,
- <remark>[tbd: where does the request processor live?]</remark>
-
-zookeeperOver.xml:298: <para><xref linkend="fg_zkComponents" /> shows the high-level components
- of the ZooKeeper service. With the exception of the request processor,
- each of
- the servers that make up the ZooKeeper service replicates its own copy
- of each of components. <remark>[tbd: I changed the wording in this
- sentence from the white paper. Can someone please make sure it is still
- correct?]</remark>
-
-zookeeperOver.xml:342: The programming interface to ZooKeeper is deliberately simple.
- With it, however, you can implement higher order operations, such as
- synchronizations primitives, group membership, ownership, etc. Some
- distributed applications have used it to: <remark>[tbd: add uses from
- white paper and video presentation.]</remark>
-
-
-zookeeperProgrammers.xml:94: <listitem>
- <para><xref linkend="ch_programStructureWithExample" />
- <remark>[tbd]</remark></para>
- </listitem>
-
-zookeeperProgrammers.xml:115: Also,
- the <ulink url="#ch_programStructureWithExample">Simple Programmming
- Example</ulink> <remark>[tbd]</remark> is helpful for understand the basic
- structure of a ZooKeeper client application.
-
-zookeeperProgrammers.xml:142: The following characters are not
- allowed because <remark>[tbd:
- do we need reasons?]</remark>
-
-zookeeperProgrammers.xml:172: If
- the version it supplies doesn't match the actual version of the data,
- the update will fail. (This behavior can be overridden. For more
- information see... )<remark>[tbd... reference here to the section
- describing the special version number -1]</remark>
-
-zookeeperProgrammers.xml:197: More information about watches can be
- found in the section
- <ulink url="recipes.html#sc_recipes_Locks">
- Zookeeper Watches</ulink>.
- <remark>[tbd: fix this link] [tbd: Ben there is note from to emphasize
- that "it is queued". What is "it" and is what we have here
- sufficient?]</remark></para>
-
-zookeeperProgrammers.xml:335: it will send the session id as a part of the connection handshake.
- As a security measure, the server creates a password for the session id
- that any ZooKeeper server can validate. <remark>[tbd: note from Ben:
- "perhaps capability is a better word." need clarification on that.]
- </remark>
-
-zookeeperProgrammers.xml:601: <ulink
- url="recipes.html#sc_recipes_Locks">Locks</ulink>
- <remark>[tbd:...]</remark> in <ulink
- url="recipes.html">Zookeeper Recipes</ulink>.
- <remark>[tbd:..]</remark>).</para>
-
-zookeeperProgrammers.xml:766: <para>See INSTALL for general information about running
- <emphasis role="bold">configure</emphasis>. <remark>[tbd: what
- is INSTALL? a directory? a file?]</remark></para>
-
-
-
-zookeeperProgrammers.xml:813: <para>To verify that the node's been created:</para>
-
- <para>You should see a list of node who are children of the root node
- "/".</para><remark>[tbd: document all the cli commands (I think this is ben's comment)
-
-zookeeperProgrammers.xml:838: <para>Refer to <xref linkend="ch_programStructureWithExample"/>for examples of usage in Java and C.
- <remark>[tbd]</remark></para>
-
-zookeeperProgrammers.xml 847: <remark>[tbd: This is a new section. The below
- is just placeholder. Eventually, a subsection on each of those operations, with a little
- bit of illustrative code for each op.] </remark>
-
-zookeeperProgrammers.xml:915: Program Structure, with Simple Example</title>
-
-zookeeperProgrammers.xml:999: <term>ZooKeeper Whitepaper <remark>[tbd: find url]</remark></term>
-
-zookeeperProgrammers.xml:1008: <term>API Reference <remark>[tbd: find url]</remark></term>
-
-zookeeperProgrammers.xml:1062: [tbd]</remark></term><listitem>
- <para>Any other good sources anyone can think of...</para>
- </listitem>
-
-zookeeperStarted.xml:73: <para>[tbd: should we start w/ a word here about were to get the source,
- exactly what to download, how to unpack it, and where to put it? Also,
- does the user need to be in sudo, or can they be under their regular
- login?]</para>
-
-zookeeperStarted.xml:84: <para>This should generate a JAR file called zookeeper.jar. To start
- Zookeeper, compile and run zookeeper.jar. <emphasis>[tbd, some more
- instruction here. Perhaps a command line? Are these two steps or
- one?]</emphasis></para>
-
-zookeeperStarted.xml:139: <para>ZooKeeper logs messages using log4j -- more detail available in
- the <ulink url="zookeeperProgrammers.html#Logging">Logging</ulink>
- section of the Programmer's Guide.<remark revision="include_tbd">[tbd:
- real reference needed]</remark>
-
-zookeeperStarted.xml:201: The C bindings exist in two variants: single
- threaded and multi-threaded. These differ only in how the messaging loop
- is done. <remark>[tbd: what is the messaging loop? Do we talk about it
- anywyhere? is this too much info for a getting started guide?]</remark>
-
-zookeeperStarted.xml:217: The entry <emphasis
- role="bold">syncLimit</emphasis> limits how far out of date a server can
- be from a leader. [TBD: someone please verify that the previous is
- true.]
-
-zookeeperStarted.xml:232: These are the "electionPort" numbers of the servers (as opposed to
- clientPorts), that is ports for <remark>[tbd: feedback need: what are
- these ports, exactly?]
-
-zookeeperStarted.xml:258: <remark>[tbd: what is the other config param?
- (I believe two are mentioned above.)]</remark>
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/4607a3e1/src/docs/src/documentation/classes/CatalogManager.properties
----------------------------------------------------------------------
diff --git a/src/docs/src/documentation/classes/CatalogManager.properties b/src/docs/src/documentation/classes/CatalogManager.properties
deleted file mode 100644
index ac060b9..0000000
--- a/src/docs/src/documentation/classes/CatalogManager.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright 2002-2004 The Apache Software Foundation
-#
-# Licensed 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.
-
-#=======================================================================
-# CatalogManager.properties
-#
-# This is the default properties file for Apache Forrest.
-# This facilitates local configuration of application-specific catalogs.
-#
-# See the Apache Forrest documentation:
-# http://forrest.apache.org/docs/your-project.html
-# http://forrest.apache.org/docs/validation.html
-
-# verbosity ... level of messages for status/debug
-# See forrest/src/core/context/WEB-INF/cocoon.xconf
-
-# catalogs ... list of additional catalogs to load
-# (Note that Apache Forrest will automatically load its own default catalog
-# from src/core/context/resources/schema/catalog.xcat)
-# use full pathnames
-# pathname separator is always semi-colon (;) regardless of operating system
-# directory separator is always slash (/) regardless of operating system
-#
-#catalogs=/home/me/forrest/my-site/src/documentation/resources/schema/catalog.xcat
-catalogs=
-
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/4607a3e1/src/docs/src/documentation/conf/cli.xconf
----------------------------------------------------------------------
diff --git a/src/docs/src/documentation/conf/cli.xconf b/src/docs/src/documentation/conf/cli.xconf
deleted file mode 100644
index c671340..0000000
--- a/src/docs/src/documentation/conf/cli.xconf
+++ /dev/null
@@ -1,328 +0,0 @@
-<?xml version="1.0"?>
-<!--
- 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.
--->
-<!--+
- | This is the Apache Cocoon command line configuration file.
- | Here you give the command line interface details of where
- | to find various aspects of your Cocoon installation.
- |
- | If you wish, you can also use this file to specify the URIs
- | that you wish to generate.
- |
- | The current configuration information in this file is for
- | building the Cocoon documentation. Therefore, all links here
- | are relative to the build context dir, which, in the build.xml
- | file, is set to ${build.context}
- |
- | Options:
- | verbose: increase amount of information presented
- | to standard output (default: false)
- | follow-links: whether linked pages should also be
- | generated (default: true)
- | precompile-only: precompile sitemaps and XSP pages, but
- | do not generate any pages (default: false)
- | confirm-extensions: check the mime type for the generated page
- | and adjust filename and links extensions
- | to match the mime type
- | (e.g. text/html->.html)
- |
- | Note: Whilst using an xconf file to configure the Cocoon
- | Command Line gives access to more features, the use of
- | command line parameters is more stable, as there are
- | currently plans to improve the xconf format to allow
- | greater flexibility. If you require a stable and
- | consistent method for accessing the CLI, it is recommended
- | that you use the command line parameters to configure
- | the CLI. See documentation at:
- | http://cocoon.apache.org/2.1/userdocs/offline/
- | http://wiki.apache.org/cocoon/CommandLine
- |
- +-->
-
-<cocoon verbose="true"
- follow-links="true"
- precompile-only="false"
- confirm-extensions="false">
-
- <!--+
- | The context directory is usually the webapp directory
- | containing the sitemap.xmap file.
- |
- | The config file is the cocoon.xconf file.
- |
- | The work directory is used by Cocoon to store temporary
- | files and cache files.
- |
- | The destination directory is where generated pages will
- | be written (assuming the 'simple' mapper is used, see
- | below)
- +-->
- <context-dir>.</context-dir>
- <config-file>WEB-INF/cocoon.xconf</config-file>
- <work-dir>../tmp/cocoon-work</work-dir>
- <dest-dir>../site</dest-dir>
-
- <!--+
- | A checksum file can be used to store checksums for pages
- | as they are generated. When the site is next generated,
- | files will not be written if their checksum has not changed.
- | This means that it will be easier to detect which files
- | need to be uploaded to a server, using the timestamp.
- |
- | The default path is relative to the core webapp directory.
- | An asolute path can be used.
- +-->
- <!-- <checksums-uri>build/work/checksums</checksums-uri>-->
-
- <!--+
- | Broken link reporting options:
- | Report into a text file, one link per line:
- | <broken-links type="text" report="filename"/>
- | Report into an XML file:
- | <broken-links type="xml" report="filename"/>
- | Ignore broken links (default):
- | <broken-links type="none"/>
- |
- | Two attributes to this node specify whether a page should
- | be generated when an error has occurred. 'generate' specifies
- | whether a page should be generated (default: true) and
- | extension specifies an extension that should be appended
- | to the generated page's filename (default: none)
- |
- | Using this, a quick scan through the destination directory
- | will show broken links, by their filename extension.
- +-->
- <broken-links type="xml"
- file="../brokenlinks.xml"
- generate="false"
- extension=".error"
- show-referrers="true"/>
-
- <!--+
- | Load classes at startup. This is necessary for generating
- | from sites that use SQL databases and JDBC.
- | The <load-class> element can be repeated if multiple classes
- | are needed.
- +-->
- <!--
- <load-class>org.firebirdsql.jdbc.Driver</load-class>
- -->
-
- <!--+
- | Configures logging.
- | The 'log-kit' parameter specifies the location of the log kit
- | configuration file (usually called logkit.xconf.
- |
- | Logger specifies the logging category (for all logging prior
- | to other Cocoon logging categories taking over)
- |
- | Available log levels are:
- | DEBUG: prints all level of log messages.
- | INFO: prints all level of log messages except DEBUG
- | ones.
- | WARN: prints all level of log messages except DEBUG
- | and INFO ones.
- | ERROR: prints all level of log messages except DEBUG,
- | INFO and WARN ones.
- | FATAL_ERROR: prints only log messages of this level
- +-->
- <!-- <logging log-kit="WEB-INF/logkit.xconf" logger="cli" level="ERROR" /> -->
-
- <!--+
- | Specifies the filename to be appended to URIs that
- | refer to a directory (i.e. end with a forward slash).
- +-->
- <default-filename>index.html</default-filename>
-
- <!--+
- | Specifies a user agent string to the sitemap when
- | generating the site.
- |
- | A generic term for a web browser is "user agent". Any
- | user agent, when connecting to a web server, will provide
- | a string to identify itself (e.g. as Internet Explorer or
- | Mozilla). It is possible to have Cocoon serve different
- | content depending upon the user agent string provided by
- | the browser. If your site does this, then you may want to
- | use this <user-agent> entry to provide a 'fake' user agent
- | to Cocoon, so that it generates the correct version of your
- | site.
- |
- | For most sites, this can be ignored.
- +-->
- <!--
- <user-agent>Cocoon Command Line Environment 2.1</user-agent>
- -->
-
- <!--+
- | Specifies an accept string to the sitemap when generating
- | the site.
- | User agents can specify to an HTTP server what types of content
- | (by mime-type) they are able to receive. E.g. a browser may be
- | able to handle jpegs, but not pngs. The HTTP accept header
- | allows the server to take the browser's capabilities into account,
- | and only send back content that it can handle.
- |
- | For most sites, this can be ignored.
- +-->
-
- <accept>*/*</accept>
-
- <!--+
- | Specifies which URIs should be included or excluded, according
- | to wildcard patterns.
- |
- | These includes/excludes are only relevant when you are following
- | links. A link URI must match an include pattern (if one is given)
- | and not match an exclude pattern, if it is to be followed by
- | Cocoon. It can be useful, for example, where there are links in
- | your site to pages that are not generated by Cocoon, such as
- | references to api-documentation.
- |
- | By default, all URIs are included. If both include and exclude
- | patterns are specified, a URI is first checked against the
- | include patterns, and then against the exclude patterns.
- |
- | Multiple patterns can be given, using muliple include or exclude
- | nodes.
- |
- | The order of the elements is not significant, as only the first
- | successful match of each category is used.
- |
- | Currently, only the complete source URI can be matched (including
- | any URI prefix). Future plans include destination URI matching
- | and regexp matching. If you have requirements for these, contact
- | dev@cocoon.apache.org.
- +-->
-
- <exclude pattern="**/"/>
- <exclude pattern="**apidocs**"/>
- <exclude pattern="api/**"/>
-
- <!-- ZOOKEEPER-2364 - we build our own release notes separately -->
- <exclude pattern="releasenotes.**"/>
-
-<!--
- This is a workaround for FOR-284 "link rewriting broken when
- linking to xml source views which contain site: links".
- See the explanation there and in declare-broken-site-links.xsl
--->
- <exclude pattern="site:**"/>
- <exclude pattern="ext:**"/>
- <exclude pattern="lm:**"/>
- <exclude pattern="**/site:**"/>
- <exclude pattern="**/ext:**"/>
- <exclude pattern="**/lm:**"/>
-
- <!-- Exclude tokens used in URLs to ASF mirrors (interpreted by a CGI) -->
- <exclude pattern="[preferred]/**"/>
- <exclude pattern="[location]"/>
-
- <!-- <include-links extension=".html"/>-->
-
- <!--+
- | <uri> nodes specify the URIs that should be generated, and
- | where required, what should be done with the generated pages.
- | They describe the way the URI of the generated file is created
- | from the source page's URI. There are three ways that a generated
- | file URI can be created: append, replace and insert.
- |
- | The "type" attribute specifies one of (append|replace|insert):
- |
- | append:
- | Append the generated page's URI to the end of the source URI:
- |
- | <uri type="append" src-prefix="documents/" src="index.html"
- | dest="build/dest/"/>
- |
- | This means that
- | (1) the "documents/index.html" page is generated
- | (2) the file will be written to "build/dest/documents/index.html"
- |
- | replace:
- | Completely ignore the generated page's URI - just
- | use the destination URI:
- |
- | <uri type="replace" src-prefix="documents/" src="index.html"
- | dest="build/dest/docs.html"/>
- |
- | This means that
- | (1) the "documents/index.html" page is generated
- | (2) the result is written to "build/dest/docs.html"
- | (3) this works only for "single" pages - and not when links
- | are followed
- |
- | insert:
- | Insert generated page's URI into the destination
- | URI at the point marked with a * (example uses fictional
- | zip protocol)
- |
- | <uri type="insert" src-prefix="documents/" src="index.html"
- | dest="zip://*.zip/page.html"/>
- |
- | This means that
- | (1)
- |
- | In any of these scenarios, if the dest attribute is omitted,
- | the value provided globally using the <dest-dir> node will
- | be used instead.
- +-->
- <!--
- <uri type="replace"
- src-prefix="samples/"
- src="hello-world/hello.html"
- dest="build/dest/hello-world.html"/>
- -->
-
- <!--+
- | <uri> nodes can be grouped together in a <uris> node. This
- | enables a group of URIs to share properties. The following
- | properties can be set for a group of URIs:
- | * follow-links: should pages be crawled for links
- | * confirm-extensions: should file extensions be checked
- | for the correct mime type
- | * src-prefix: all source URIs should be
- | pre-pended with this prefix before
- | generation. The prefix is not
- | included when calculating the
- | destination URI
- | * dest: the base destination URI to be
- | shared by all pages in this group
- | * type: the method to be used to calculate
- | the destination URI. See above
- | section on <uri> node for details.
- |
- | Each <uris> node can have a name attribute. When a name
- | attribute has been specified, the -n switch on the command
- | line can be used to tell Cocoon to only process the URIs
- | within this URI group. When no -n switch is given, all
- | <uris> nodes are processed. Thus, one xconf file can be
- | used to manage multiple sites.
- +-->
- <!--
- <uris name="mirrors" follow-links="false">
- <uri type="append" src="mirrors.html"/>
- </uris>
- -->
-
- <!--+
- | File containing URIs (plain text, one per line).
- +-->
- <!--
- <uri-file>uris.txt</uri-file>
- -->
-</cocoon>
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/4607a3e1/src/docs/src/documentation/content/xdocs/index.xml
----------------------------------------------------------------------
diff --git a/src/docs/src/documentation/content/xdocs/index.xml b/src/docs/src/documentation/content/xdocs/index.xml
deleted file mode 100644
index 969e482..0000000
--- a/src/docs/src/documentation/content/xdocs/index.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Copyright 2002-2004 The Apache Software Foundation
-
- Licensed 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.
--->
-
-<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
-
-<document>
-
- <header>
- <title>ZooKeeper: Because Coordinating Distributed Systems is a Zoo</title>
- </header>
-
- <body>
- <p>ZooKeeper is a high-performance coordination service for
- distributed applications. It exposes common services - such as
- naming, configuration management, synchronization, and group
- services - in a simple interface so you don't have to write them
- from scratch. You can use it off-the-shelf to implement
- consensus, group management, leader election, and presence
- protocols. And you can build on it for your own, specific needs.
- </p>
-
- <p>
- The following documents describe concepts and procedures to get
- you started using ZooKeeper. If you have more questions, please
- ask the <a href="ext:lists">mailing list</a> or browse the
- archives.
- </p>
- <ul>
-
- <li><strong>ZooKeeper Overview</strong><p>Technical Overview Documents for Client Developers, Adminstrators, and Contributors</p>
- <ul><li><a href="zookeeperOver.html">Overview</a> - a bird's eye view of ZooKeeper, including design concepts and architecture</li>
- <li><a href="zookeeperStarted.html">Getting Started</a> - a tutorial-style guide for developers to install, run, and program to ZooKeeper</li>
- <li><a href="ext:relnotes">Release Notes</a> - new developer and user facing features, improvements, and incompatibilities</li>
- </ul>
- </li>
-
- <li><strong>Developers</strong><p> Documents for Developers using the ZooKeeper Client API</p>
- <ul>
- <li><a href="ext:api/index">API Docs</a> - the technical reference to ZooKeeper Client APIs</li>
- <li><a href="zookeeperProgrammers.html">Programmer's Guide</a> - a client application developer's guide to ZooKeeper</li>
- <li><a href="javaExample.html">ZooKeeper Java Example</a> - a simple Zookeeper client appplication, written in Java</li>
- <li><a href="zookeeperTutorial.html">Barrier and Queue Tutorial</a> - sample implementations of barriers and queues</li>
- <li><a href="recipes.html">ZooKeeper Recipes</a> - higher level solutions to common problems in distributed applications</li>
- </ul>
- </li>
-
- <li><strong>Administrators & Operators</strong> <p> Documents for Administrators and Operations Engineers of ZooKeeper Deployments</p>
- <ul>
- <li><a href="zookeeperAdmin.html">Administrator's Guide</a> - a guide for system administrators and anyone else who might deploy ZooKeeper</li>
- <li><a href="zookeeperQuotas.html">Quota Guide</a> - a guide for system administrators on Quotas in ZooKeeper. </li>
- <li><a href="zookeeperJMX.html">JMX</a> - how to enable JMX in ZooKeeper</li>
- <li><a href="zookeeperHierarchicalQuorums.html">Hierarchical quorums</a></li>
- <li><a href="zookeeperObservers.html">Observers</a> - non-voting ensemble members that easily improve ZooKeeper's scalability</li>
- <li><a href="zookeeperReconfig.html">Dynamic Reconfiguration</a> - a guide on how to use dynamic reconfiguration in ZooKeeper</li>
- </ul>
- </li>
-
- <li><strong>Contributors</strong><p> Documents for Developers Contributing to the ZooKeeper Open Source Project</p>
- <ul>
- <li><a href="zookeeperInternals.html">ZooKeeper Internals</a> - assorted topics on the inner workings of ZooKeeper</li>
- </ul>
- </li>
-
- <li><strong>Miscellaneous ZooKeeper Documentation</strong>
- <ul>
- <li><a href="ext:wiki">Wiki</a></li>
- <li><a href="ext:faq">FAQ</a></li>
- </ul>
- </li>
- </ul>
- </body>
-
-</document>
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/4607a3e1/src/docs/src/documentation/content/xdocs/javaExample.xml
----------------------------------------------------------------------
diff --git a/src/docs/src/documentation/content/xdocs/javaExample.xml b/src/docs/src/documentation/content/xdocs/javaExample.xml
deleted file mode 100644
index 16f7795..0000000
--- a/src/docs/src/documentation/content/xdocs/javaExample.xml
+++ /dev/null
@@ -1,664 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 2002-2004 The Apache Software Foundation
-
- Licensed 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.
--->
-
-<!DOCTYPE article PUBLIC "-//OASIS//DTD Simplified DocBook XML V1.0//EN"
-"http://www.oasis-open.org/docbook/xml/simple/1.0/sdocbook.dtd">
-<article id="ar_JavaExample">
- <title>ZooKeeper Java Example</title>
-
- <articleinfo>
- <legalnotice>
- <para>Licensed 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 <ulink
- url="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</ulink>.</para>
-
- <para>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.</para>
- </legalnotice>
-
- <abstract>
- <para>This article contains sample Java code for a simple watch client.</para>
-
- </abstract>
- </articleinfo>
-
- <section id="ch_Introduction">
- <title>A Simple Watch Client</title>
-
- <para>To introduce you to the ZooKeeper Java API, we develop here a very simple
- watch client. This ZooKeeper client watches a ZooKeeper node for changes
- and responds to by starting or stopping a program.</para>
-
- <section id="sc_requirements"><title>Requirements</title>
-
- <para>The client has four requirements:</para>
-
- <itemizedlist><listitem><para>It takes as parameters:</para>
- <itemizedlist>
- <listitem><para>the address of the ZooKeeper service</para></listitem>
- <listitem><para>the name of a znode - the one to be watched</para></listitem>
- <listitem><para>the name of a file to write the output to</para></listitem>
- <listitem><para>an executable with arguments.</para></listitem></itemizedlist></listitem>
- <listitem><para>It fetches the data associated with the znode and starts the executable.</para></listitem>
- <listitem><para>If the znode changes, the client refetches the contents and restarts the executable.</para></listitem>
- <listitem><para>If the znode disappears, the client kills the executable.</para></listitem></itemizedlist>
-
- </section>
-
- <section id="sc_design">
- <title>Program Design</title>
-
- <para>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 <emphasis role="bold">Executor</emphasis>
- maintains the ZooKeeper connection, and the class called the <emphasis role="bold">DataMonitor</emphasis> 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 exectuable 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.</para>
-
- </section>
-
- </section>
-
- <section id="sc_executor"><title>The Executor Class</title>
- <para>The Executor object is the primary container of the sample application. It contains
- both the <emphasis role="bold">ZooKeeper</emphasis> object, <emphasis role="bold">DataMonitor</emphasis>, as described above in
- <xref linkend="sc_design"/>. </para>
-
- <programlisting>
- // 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) {
- }
- }
-</programlisting>
-
-
- <para>
- 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:
- </para>
-
- <programlisting>
-public class Executor implements Watcher, Runnable, DataMonitor.DataMonitorListener {
-...</programlisting>
-
- <para>The <emphasis role="bold">Watcher</emphasis> interface is defined by the ZooKeeper Java API.
- ZooKeeper uses it to communicate back to its container. It supports only one method, <command>process()</command>, and ZooKeeper uses
- it to communciates generic events that the main thread would be intersted 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.)</para>
-
-<programlisting>
- public void process(WatchedEvent event) {
- dm.process(event);
- }
-</programlisting>
-
- <para>The <emphasis role="bold">DataMonitorListener</emphasis>
- interface, on the other hand, is not part of the 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 the Executor object.The DataMonitorListener interface looks like this:</para>
- <programlisting>
-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);
-}
-</programlisting>
- <para>This interface is defined in the DataMonitor class and implemented in the Executor class.
- When <command>Executor.exists()</command> 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 <emphasis>exist</emphasis>. </para>
-
- <para>When <command>Executor.closing()</command>
- is invoked, the Executor decides whether or not to shut itself down in response to the ZooKeeper connection permanently disappearing.</para>
-
- <para>As you might have guessed, DataMonitor is the object that invokes
- these methods, in response to changes in ZooKeeper's state.</para>
-
- <para>Here are Executor's implementation of
- <command>DataMonitorListener.exists()</command> and <command>DataMonitorListener.closing</command>:
- </para>
- <programlisting>
-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();
- }
-}
-</programlisting>
-
-</section>
-<section id="sc_DataMonitor"><title>The DataMonitor Class</title>
-<para>
-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:</para>
-<programlisting>
-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
- <emphasis role="bold">zk.exists(znode, true, this, null);</emphasis>
-}
-</programlisting>
-
-<para>The call to <command>ZooKeeper.exists()</command> checks for the existence of the znode,
-sets a watch, and passes a reference to itself (<command>this</command>)
-as the completion callback object. In this sense, it kicks things off, since the
-real processing happens when the watch is triggered.</para>
-
-<note>
-<para>Don't confuse the completion callback with the watch callback. The <command>ZooKeeper.exists()</command>
-completion callback, which happens to be the method <command>StatCallback.processResult()</command> implemented
-in the DataMonitor object, is invoked when the asynchronous <emphasis>setting of the watch</emphasis> operation
-(by <command>ZooKeeper.exists()</command>) completes on the server. </para>
-<para>
-The triggering of the watch, on the other hand, sends an event to the <emphasis>Executor</emphasis> object, since
-the Executor registered as the Watcher of the ZooKeeper object.</para>
-
-<para>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.</para>
-</note>
-
-<para>When the <command>ZooKeeper.exists()</command> operation completes on the server, the ZooKeeper API invokes this completion callback on
-the client:</para>
-
-<programlisting>
-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 {
- <emphasis role="bold">b = zk.getData(znode, false, null);</emphasis>
- } 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))) {
- <emphasis role="bold">listener.exists(b);</emphasis>
- prevData = b;
- }
-}
-</programlisting>
-
-<para>
-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 <command>ZooKeeper.getData()</command>, the watch event set by
-the <command>ZooKeeper.exists()</command> triggers a callback;
-if there is a communication error, a connection watch event fires when
-the connection comes back up.
-</para>
-
-<para>Finally, notice how DataMonitor processes watch events: </para>
-<programlisting>
- 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);
- }
- }
-</programlisting>
-<para>
-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 <ulink
-url="zookeeperProgrammers.html#ch_zkWatches">ZooKeeper Watches</ulink>
-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
-<command>ZooKeeper.exists()</command> to find out what has changed.
-</para>
-</section>
-
-<section id="sc_completeSourceCode">
- <title>Complete Source Listings</title>
- <example id="eg_Executor_java"><title>Executor.java</title><programlisting>
-/**
- * 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();
- }
- }
- }
-}
-</programlisting>
-
-</example>
-
-<example id="eg_DataMonitor_java">
- <title>DataMonitor.java</title>
- <programlisting>
-/**
- * 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;
- }
- }
-}
-</programlisting>
-</example>
-</section>
-
-
-
-</article>