Description

zktreeutil program is intended to manage and manipulate zk-tree data quickly,
efficiently and with ease. The utility operates on free-form ZK-tree and hence
can be used for any cluster managed by Zookeeper. Here are the basic
functionalities -

EXPORT: The whole/partial ZK-tree is exported into a XML file. This helps in
capturing a current snapshot of the data for backup/analysis. For a subtree
export, one need to specify the path to the ZK-subtree with proper option.
Since Zookeeper store binary data against znode, the data dumped on xml file
is based64 encoded with an attribute "encode=true". Optionally one may specify
not to encode data with --noencode option if data stored on zookeeper is
guaranteed to be text data.

IMPORT: The ZK (sub)tree can be imported from XML into ZK cluster. This helps in
priming the new ZK cluster with static configuration. The import can be
non-intrusive by making only additions and modifications in the existing data.
One may optionally delete existing (sub)tree before importing the new data
with --force option. The znodes which carries an attribute "encode=true" will be
decoded and written to zookeeper.

DIFF: Creates a diff between live ZK data vs data saved in XML file. Diff can
ignore some ZK-tree branches (possibly dynamic data) on reading the optional
ignore flag from XML file. Taking diff on a ZK-subtree achieved by providing
path to ZK-subtree with diff command.

UPDATE: Make the incremental changes into the live ZK-tree from saved XML,
essentially after running the diff.

DUMP: Dumps the ZK (sub)tree on the standard output device reading either from
live ZK server or XML file.

The exported ZK data into XML file can be shortened by only keeping the static
ZK nodes which are required to prime an application. The dynamic zk nodes
(created on-the-fly) can be ignored by setting a 'ignore' attribute at the root
node of the dynamic subtree (see tests/zk_sample.xml), possibly deleting all
inner ZK nodes under that. Once ignored, the whole subtree is ignored during
DIFF, UPDATE and WRITE.