summaryrefslogtreecommitdiff
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
parent03f98f1449a8c9dd9d3a78c1fb4b10595033a010 (diff)
downloadzookeeper-test-d116653e2920854e127d544b602d1d4c7cbafe2f.tar.gz
new program added, the setup for the config files on the server
-rw-r--r--ZKTest/.cproject4
-rwxr-xr-xZKTest/Debug/ZKTestbin191145 -> 191137 bytes
-rw-r--r--ZKTest/Debug/src/ZKTest.obin365008 -> 364792 bytes
-rw-r--r--ZKTest/src/ZKTest.cpp87
-rw-r--r--zkServerFileSetup/.cproject142
-rw-r--r--zkServerFileSetup/.gitignore2
-rw-r--r--zkServerFileSetup/.project27
-rw-r--r--zkServerFileSetup/src/zkServerFileSetup.cpp174
8 files changed, 389 insertions, 47 deletions
diff --git a/ZKTest/.cproject b/ZKTest/.cproject
index ca9760d..de38b07 100644
--- a/ZKTest/.cproject
+++ b/ZKTest/.cproject
@@ -26,8 +26,8 @@
<option id="gnu.cpp.compiler.option.include.paths.1914937798" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/usr/include/zookeeper"/>
</option>
- <option id="gnu.cpp.compiler.option.other.other.366567962" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
- <option id="gnu.cpp.compiler.option.preprocessor.def.1884295414" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+ <option id="gnu.cpp.compiler.option.other.other.366567962" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
+ <option id="gnu.cpp.compiler.option.preprocessor.def.1884295414" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="__GXX_EXPERIMENTAL_CXX0X__"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1811754685" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
diff --git a/ZKTest/Debug/ZKTest b/ZKTest/Debug/ZKTest
index 3ffd542..7975212 100755
--- a/ZKTest/Debug/ZKTest
+++ b/ZKTest/Debug/ZKTest
Binary files differ
diff --git a/ZKTest/Debug/src/ZKTest.o b/ZKTest/Debug/src/ZKTest.o
index eb10575..d38bcf4 100644
--- a/ZKTest/Debug/src/ZKTest.o
+++ b/ZKTest/Debug/src/ZKTest.o
Binary files differ
diff --git a/ZKTest/src/ZKTest.cpp b/ZKTest/src/ZKTest.cpp
index c4f4017..de2a3e2 100644
--- a/ZKTest/src/ZKTest.cpp
+++ b/ZKTest/src/ZKTest.cpp
@@ -25,7 +25,7 @@ using namespace std;
static zhandle_t *zk;
static const clientid_t *session_id;
char* nodeType = "default";
-struct String_vector list_of_children = {0};
+struct String_vector list_of_children = { 0 };
int timeout = 3000;
int responseCode = 0;
std::mutex mutex_lock;
@@ -47,26 +47,26 @@ int main(int argc, char **argv)
char* hosts = "localhost:2181";
char* check = "localhost";
char* check2 = ":";
- if(argc >1)
+ if (argc > 1)
{
- for (int i = 1; i < argc; i++ )
+ for (int i = 1; i < argc; i++)
{
- if(isdigit(argv[i][0]))
+ if (isdigit(argv[i][0]))
{
- if(strstr(argv[i],check2) != NULL)
+ if (strstr(argv[i], check2) != NULL)
{
hosts = argv[i];
}
}
- else if(strstr(argv[i],check) !=NULL)
+ else if (strstr(argv[i], check) != NULL)
{
- if(strstr(argv[i],check2) != NULL)
+ if (strstr(argv[i], check2) != NULL)
{
hosts = argv[1];
}
}
- else if(isalpha(argv[i][0]))
+ else if (isalpha(argv[i][0]))
{
nodeType = argv[i];
}
@@ -109,14 +109,12 @@ int main(int argc, char **argv)
* debug test to show that the loop does not continue until watcher
* is called
*/
- std::cout<<"loop locked"<<std::endl;
+ std::cout << "loop locked" << std::endl;
}
safeShutdown(zk);
return 0;
-}// End of Main
-
-
+} // End of Main
void safeShutdown(zhandle_t *zzh)
{
@@ -128,7 +126,6 @@ void safeShutdown(zhandle_t *zzh)
}
}
-
static const char* state2String(int state)
{
if (state == 0)
@@ -170,15 +167,16 @@ void watcher(zhandle_t *zzh, int type, int state, const char *path,
mutex_lock.unlock();
if (type == ZOO_SESSION_EVENT)
{
- std::cout<<type2String(type)<<std::endl;
+ std::cout << type2String(type) << std::endl;
if (state == ZOO_CONNECTED_STATE)
{
- std::cout<<state2String(type)<<std::endl;
+ 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, "/test", "my_data", 7, &ZOO_READ_ACL_UNSAFE,
+ ZOO_EPHEMERAL, NULL, 0);
/*
* Setting configuration to watch. taking the char[] provided by argv and appending it to a
@@ -191,64 +189,64 @@ void watcher(zhandle_t *zzh, int type, int state, const char *path,
ss >> temp;
string addition_of_strings = "/configTest/" + temp;
const char* config_to_watch = addition_of_strings.c_str();
- std::cout<<"setting watch for config type of "<<config_to_watch<<std::endl;
+ std::cout << "setting watch for config type of " << config_to_watch
+ << std::endl;
- if(zoo_wexists(zk, config_to_watch ,configurationwatcher, NULL , NULL)==0)
+ if (zoo_wexists(zk, config_to_watch, configurationwatcher, NULL, NULL)
+ == 0)
{
- char config_data[1024] = {0};
+ char config_data[1024] =
+ { 0 };
int data_length = sizeof(config_data);
zoo_get(zk, config_to_watch, true, config_data, &data_length, NULL);
setConfiguration(config_data);
}
-
- //responseCode = zoo_get_children(zk, "/childTest", true, NULL);
- //discoverChildren("/childTest");
session_id = zoo_client_id(zzh);
return;
}
else if (state == ZOO_AUTH_FAILED_STATE)
{
- std::cout<<state2String(type)<<std::endl;
+ 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, timeout, session_id, NULL,
- 0);
+ std::cout << state2String(type) << std::endl;
+ zk = zookeeper_init("localhost:2181", watcher, timeout, session_id,
+ NULL, 0);
}
}
else if (type == ZOO_DELETED_EVENT)
{
- std::cout<<type2String(type)<<std::endl;
+ std::cout << type2String(type) << std::endl;
zoo_exists(zk, path, true, NULL);
}
else if (type == ZOO_CHILD_EVENT)
{
- std::cout<<type2String(type)<<std::endl;
+ std::cout << type2String(type) << std::endl;
discoverChildren(path);
}
else if (type == ZOO_CHANGED_EVENT)
{
responseCode = zoo_exists(zk, path, true, NULL);
- std::cout<<type2String(type)<<std::endl;
+ std::cout << type2String(type) << std::endl;
}
else if (type == ZOO_CREATED_EVENT)
{
responseCode = zoo_exists(zk, path, true, NULL);
- std::cout<<type2String(type)<<std::endl;
+ std::cout << type2String(type) << std::endl;
cout << "creation of watched node detected" << std::endl;
}
}
void discoverChildren(const char* path)
{
- struct String_vector list_of_children_discovered = {0};
- cout << "discovering children of "<<path<< std::endl;
+ struct String_vector list_of_children_discovered = { 0 };
+ cout << "discovering children of " << path << std::endl;
zoo_get_children(zk, path, true, &list_of_children_discovered);
zoo_exists(zk, path, true, NULL);
- if(list_of_children_discovered.count)
+ if (list_of_children_discovered.count)
{
for (int i = 0; i < list_of_children_discovered.count; i++)
{
@@ -265,39 +263,38 @@ void discoverChildren(const char* path)
void configurationwatcher(zhandle_t *zzh, int type, int state, const char *path,
void *watchContext)
{
- char config_data[1049000] = {0};
+ char config_data[1049000] = { 0 };
int data_length = sizeof(config_data);
zoo_get(zk, path, true, config_data, &data_length, NULL);
- std::cout<<"i am a client of type "<<config_data<<std::endl;
setConfiguration(config_data);
- zoo_wexists(zk, path, configurationwatcher, NULL , NULL);
+ zoo_wexists(zk, path, configurationwatcher, NULL, NULL);
}
void setConfiguration(char* configString)
{
vector<char*> elements;
uint configBegin = 0;
- for (uint it = 0; it != strlen(configString); it++ )
+ for (uint it = 0; it != strlen(configString); it++)
{
- if(configString[it] == ';' || NULL)
+ if (configString[it] == ';')
{
string tempString;
- while(configBegin != it)
+ while (configBegin != it)
{
tempString += configString[configBegin];
configBegin++;
}
- configBegin = it+1;
- char* element = new char[tempString.length()+1];
- std::strcpy (element, tempString.c_str());
+ configBegin = it + 1;
+ char* element = new char[tempString.length() + 1];
+ std::strcpy(element, tempString.c_str());
elements.push_back(element);
}
}
- std::cout<<"i am a client of type "<<nodeType<<std::endl;
- std::cout<<"and i should watch the nodes:"<<std::endl;
+ std::cout << "i am a client of type " << nodeType << std::endl;
+ std::cout << "and i should watch the nodes:" << std::endl;
for (uint it = 0; it != elements.size(); it++)
{
- std::cout<<elements[it]<<std::endl;
+ std::cout << elements[it] << std::endl;
zoo_exists(zk, elements[it], true, NULL);
discoverChildren(elements[it]);
}
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;
+ }
+}