summaryrefslogtreecommitdiff
path: root/zkServerFileSetup
diff options
context:
space:
mode:
authorMike Smith <mike.smith@codethink.co.uk>2014-11-26 15:41:46 +0000
committerMike Smith <mike.smith@codethink.co.uk>2014-11-26 15:41:46 +0000
commitd116653e2920854e127d544b602d1d4c7cbafe2f (patch)
treeb7f00b5feb6bd13a5d19a7d11ec7054680df1c08 /zkServerFileSetup
parent03f98f1449a8c9dd9d3a78c1fb4b10595033a010 (diff)
downloadzookeeper-test-d116653e2920854e127d544b602d1d4c7cbafe2f.tar.gz
new program added, the setup for the config files on the server
Diffstat (limited to 'zkServerFileSetup')
-rw-r--r--zkServerFileSetup/.cproject142
-rw-r--r--zkServerFileSetup/.gitignore2
-rw-r--r--zkServerFileSetup/.project27
-rw-r--r--zkServerFileSetup/src/zkServerFileSetup.cpp174
4 files changed, 345 insertions, 0 deletions
diff --git a/zkServerFileSetup/.cproject b/zkServerFileSetup/.cproject
new file mode 100644
index 0000000..8bb81be
--- /dev/null
+++ b/zkServerFileSetup/.cproject
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1535525572">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1535525572" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1535525572" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1535525572." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.234951327" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.398068577" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
+ <builder buildPath="${workspace_loc:/zkServerFileSetup}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.456398550" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.1546572125" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.298139789" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
+ <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1178107021" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.374902227" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.1533101230" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/usr/include/zookeeper"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.692276410" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1580829096" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.886542453" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.exe.debug.option.debugging.level.1666741827" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.42981504" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.607258368" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.127781932" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
+ <option id="gnu.cpp.link.option.libs.1612098559" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
+ <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="zookeeper_mt"/>
+ </option>
+ <option id="gnu.cpp.link.option.paths.871685820" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
+ <listOptionValue builtIn="false" value="/usr/lib/x86_64-linux-gnu/"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.114665552" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.38385106" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
+ <option id="gnu.both.asm.option.include.paths.1295375962" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/usr/include/zookeeper"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.452908051" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="cdt.managedbuild.config.gnu.exe.release.792985849">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.792985849" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.792985849" name="Release" parent="cdt.managedbuild.config.gnu.exe.release">
+ <folderInfo id="cdt.managedbuild.config.gnu.exe.release.792985849." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.2146698248" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.497215493" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
+ <builder buildPath="${workspace_loc:/zkServerFileSetup}/Release" id="cdt.managedbuild.target.gnu.builder.exe.release.1955012591" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.321083495" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.149362266" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
+ <option id="gnu.cpp.compiler.exe.release.option.optimization.level.458510089" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.exe.release.option.debugging.level.953763575" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.1102786263" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/usr/include/zookeeper"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.857666801" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.2122827463" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.238361341" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.exe.release.option.debugging.level.901363251" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1432564061" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1524812828" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.650566521" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
+ <option id="gnu.cpp.link.option.paths.1848432164" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
+ <listOptionValue builtIn="false" value="/usr/lib/x86_64-linux-gnu/"/>
+ </option>
+ <option id="gnu.cpp.link.option.libs.1965419485" superClass="gnu.cpp.link.option.libs" valueType="libs">
+ <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="zookeeper_mt"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.399969362" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.155136521" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.2029447244" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="zkServerFileSetup.cdt.managedbuild.target.gnu.exe.1772217507" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.792985849;cdt.managedbuild.config.gnu.exe.release.792985849.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.149362266;cdt.managedbuild.tool.gnu.cpp.compiler.input.857666801">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1535525572;cdt.managedbuild.config.gnu.exe.debug.1535525572.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.298139789;cdt.managedbuild.tool.gnu.cpp.compiler.input.692276410">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1535525572;cdt.managedbuild.config.gnu.exe.debug.1535525572.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1580829096;cdt.managedbuild.tool.gnu.c.compiler.input.42981504">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.792985849;cdt.managedbuild.config.gnu.exe.release.792985849.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.2122827463;cdt.managedbuild.tool.gnu.c.compiler.input.1432564061">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope"/>
+</cproject>
diff --git a/zkServerFileSetup/.gitignore b/zkServerFileSetup/.gitignore
new file mode 100644
index 0000000..ac01e66
--- /dev/null
+++ b/zkServerFileSetup/.gitignore
@@ -0,0 +1,2 @@
+/Debug/
+/Release/
diff --git a/zkServerFileSetup/.project b/zkServerFileSetup/.project
new file mode 100644
index 0000000..2553369
--- /dev/null
+++ b/zkServerFileSetup/.project
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>zkServerFileSetup</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
diff --git a/zkServerFileSetup/src/zkServerFileSetup.cpp b/zkServerFileSetup/src/zkServerFileSetup.cpp
new file mode 100644
index 0000000..03f48f0
--- /dev/null
+++ b/zkServerFileSetup/src/zkServerFileSetup.cpp
@@ -0,0 +1,174 @@
+//============================================================================
+// Name : zkServerFileSetup.cpp
+// Author : Michael P Smith
+// Version :
+// Copyright :
+// Description : Hello World in C++, Ansi-style
+//============================================================================
+
+//============================================================================
+// Name : ZKTest.cpp
+// Author : Michael P Smith (AKA, Krin), Under Codethink .Ltd
+// Version : 0.0.1
+// Copyright : Your copyright notice
+// Description : a first attempt at making a zookeeper client in C
+//============================================================================
+
+#include <iostream>
+#include <cstring>
+#include <string.h>
+#include <sstream>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "zookeeper.h"
+
+using namespace std;
+
+static zhandle_t *zk;
+static const clientid_t *session_id;
+void watcher(zhandle_t *zzh, int type, int state, const char *path,
+ void *watcherCtx);
+
+int main(int argc, char **argv)
+{
+ session_id = NULL;
+ char* p;
+ cout << "Initialising Zookeeper" << endl; // prints !!!Hello World!!!
+
+ zk = zookeeper_init("localhost:2181", watcher, 3000, session_id, NULL, 0);
+ while (!zk)
+ {
+
+ }
+ p = strtok(NULL, " ");
+ std::cout << "starting authentication" << std::endl;
+
+ zoo_add_auth(zk, "digest", p, p ? strlen(p) : 0, NULL, NULL);
+ while (zoo_state(zk) == 0)
+ {
+
+ }
+ std::cout << "authentication step done" << std::endl;
+
+ while (zk)
+ {
+ }
+ cout << "End of setup Program" << std::endl;
+ return 0;
+} // End of Main
+
+void safeShutdown(zhandle_t *zzh)
+{
+ if (zzh)
+ {
+ cout << "closing Zookeeper connection" << std::endl;
+ zookeeper_close(zzh);
+ zk = 0;
+ }
+}
+
+static const char* state2String(int state)
+{
+ if (state == 0)
+ return "CLOSED_STATE";
+ if (state == ZOO_CONNECTING_STATE)
+ return "CONNECTING_STATE";
+ if (state == ZOO_ASSOCIATING_STATE)
+ return "ASSOCIATING_STATE";
+ if (state == ZOO_CONNECTED_STATE)
+ return "CONNECTED_STATE";
+ if (state == ZOO_EXPIRED_SESSION_STATE)
+ return "EXPIRED_SESSION_STATE";
+ if (state == ZOO_AUTH_FAILED_STATE)
+ return "AUTH_FAILED_STATE";
+
+ return "INVALID_STATE";
+}
+
+static const char* type2String(int type)
+{
+ if (type == ZOO_CREATED_EVENT)
+ return "CREATED_EVENT";
+ if (type == ZOO_DELETED_EVENT)
+ return "DELETED_EVENT";
+ if (type == ZOO_CHANGED_EVENT)
+ return "CHANGED_EVENT";
+ if (type == ZOO_CHILD_EVENT)
+ return "CHILD_EVENT";
+ if (type == ZOO_SESSION_EVENT)
+ return "SESSION_EVENT";
+ if (type == ZOO_NOTWATCHING_EVENT)
+ return "NOTWATCHING_EVENT";
+
+ return "UNKNOWN_EVENT_TYPE";
+}
+void watcher(zhandle_t *zzh, int type, int state, const char *path,
+ void *watcherCtx)
+{
+ if (type == ZOO_SESSION_EVENT)
+ {
+ std::cout << type2String(type) << std::endl;
+ if (state == ZOO_CONNECTED_STATE)
+ {
+ std::cout << state2String(type) << std::endl;
+ /*
+ * create a temporary zookeeper node that will vanish when this client disconnects,
+ * useful for testing.
+ */
+ zoo_create(zk, "/test", "my_data", 7, &ZOO_OPEN_ACL_UNSAFE,
+ ZOO_EPHEMERAL, NULL, 0);
+
+ zoo_create(zk, "/configTest", "top level configuration file", 28, &ZOO_OPEN_ACL_UNSAFE,
+ 0, NULL, 0);
+ char* znodeData = "/configTest/typeOneNode;/typeOneNodeWatchingTest;/typeOneNodeWatchingTest/youShouldSeeThis;";
+ zoo_create(zk, "/configTest/typeOneNode",znodeData, strlen(znodeData), &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
+
+ char* znodeData1 = "/configTest/typeTwoNode;/typeTwoNodeWatchingTest;/typeTwoNodeWatchingTest/youShouldSeeThis;/typeTwoNodeWatchingTest/youShouldSeeThis/AndThisAlso;";
+ zoo_create(zk, "/configTest/typeTwoNode",znodeData1, strlen(znodeData1), &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
+
+ char* znodeData2 = "dataPlaceHolder";
+ zoo_create(zk, "/typeOneNodeWatchingTest",znodeData2, strlen(znodeData2), &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
+ zoo_create(zk, "/typeTwoNodeWatchingTest",znodeData2, strlen(znodeData2), &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
+ zoo_create(zk, "/typeTwoNodeWatchingTest/youShouldSeeThis",znodeData2, strlen(znodeData2), &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
+ zoo_create(zk, "/typeTwoNodeWatchingTest/youShouldSeeThis/AndThisAlso",znodeData2, strlen(znodeData2), &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
+ zoo_create(zk, "/typeOneNodeWatchingTest/youShouldSeeThis",znodeData2, strlen(znodeData2), &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
+
+ safeShutdown(zk);
+ session_id = zoo_client_id(zzh);
+ return;
+ }
+ else if (state == ZOO_AUTH_FAILED_STATE)
+ {
+ std::cout << state2String(type) << std::endl;
+ safeShutdown(zzh);
+ }
+ else if (state == ZOO_EXPIRED_SESSION_STATE)
+ {
+ std::cout << state2String(type) << std::endl;
+ zk = zookeeper_init("localhost:2181", watcher, 3000, session_id,
+ NULL, 0);
+ }
+ }
+ else if (type == ZOO_DELETED_EVENT)
+ {
+ std::cout << type2String(type) << std::endl;
+ zoo_exists(zk, path, true, NULL);
+ }
+ else if (type == ZOO_CHILD_EVENT)
+ {
+ std::cout << type2String(type) << std::endl;
+ }
+ else if (type == ZOO_CHANGED_EVENT)
+ {
+ zoo_exists(zk, path, true, NULL);
+ std::cout << type2String(type) << std::endl;
+ }
+ else if (type == ZOO_CREATED_EVENT)
+ {
+ zoo_exists(zk, path, true, NULL);
+ std::cout << type2String(type) << std::endl;
+ cout << "creation of watched node detected" << std::endl;
+ }
+}