diff options
author | Mike Smith <mike.smith@codethink.co.uk> | 2014-11-19 15:16:18 +0000 |
---|---|---|
committer | Mike Smith <mike.smith@codethink.co.uk> | 2014-11-19 15:16:18 +0000 |
commit | bf26fc210218f51181127f49ef9e1f81f2f7de57 (patch) | |
tree | e8fc16eba2c246e438d163aa0f7b95a959d93050 | |
download | zookeeper-test-bf26fc210218f51181127f49ef9e1f81f2f7de57.tar.gz |
initial commit of zookeeper proof-of-concept program
-rw-r--r-- | ZKTest/.cproject | 158 | ||||
-rw-r--r-- | ZKTest/.project | 27 | ||||
-rwxr-xr-x | ZKTest/Debug/ZKTest | bin | 0 -> 91773 bytes | |||
-rw-r--r-- | ZKTest/Debug/makefile | 59 | ||||
-rw-r--r-- | ZKTest/Debug/objects.mk | 8 | ||||
-rw-r--r-- | ZKTest/Debug/sources.mk | 27 | ||||
-rw-r--r-- | ZKTest/Debug/src/ZKTest.d | 15 | ||||
-rw-r--r-- | ZKTest/Debug/src/ZKTest.o | bin | 0 -> 180024 bytes | |||
-rw-r--r-- | ZKTest/Debug/src/subdir.mk | 24 | ||||
-rw-r--r-- | ZKTest/src/ZKTest.cpp | 130 |
10 files changed, 448 insertions, 0 deletions
diff --git a/ZKTest/.cproject b/ZKTest/.cproject new file mode 100644 index 0000000..4f3143f --- /dev/null +++ b/ZKTest/.cproject @@ -0,0 +1,158 @@ +<?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.1901448955"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1901448955" 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.1901448955" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug"> + <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1901448955." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1539185564" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.270339900" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> + <builder buildPath="${workspace_loc:/ZKTest}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.1905446556" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.1534597167" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.872951966" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"> + <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.809431294" 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.213108775" 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.1914937798" 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.1811754685" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1250781423" 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.1932776923" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.exe.debug.option.debugging.level.1709059116" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <option id="gnu.c.compiler.option.include.paths.221757768" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value="/usr/include/zookeeper"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.323699468" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.685367334" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1004635513" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"> + <option id="gnu.cpp.link.option.libs.376290738" 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.807601619" 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.2048713482" 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.999369000" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug"> + <option id="gnu.both.asm.option.include.paths.488412531" 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.646352957" 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.1941090211"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.1941090211" 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.1941090211" name="Release" parent="cdt.managedbuild.config.gnu.exe.release"> + <folderInfo id="cdt.managedbuild.config.gnu.exe.release.1941090211." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1806995213" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.1643218951" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/> + <builder buildPath="${workspace_loc:/ZKTest}/Release" id="cdt.managedbuild.target.gnu.builder.exe.release.2036168266" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.372775253" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.308803272" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release"> + <option id="gnu.cpp.compiler.exe.release.option.optimization.level.49146104" 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.1964167130" 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.33323844" 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.1259315012" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1571826105" 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.110880178" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.exe.release.option.debugging.level.573648089" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/> + <option id="gnu.c.compiler.option.include.paths.1777760561" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value="/usr/include/zookeeper"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1046404675" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1415822815" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.2092160826" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"> + <option id="gnu.cpp.link.option.libs.765426599" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" srcPrefixMapping="" srcRootPath="" value="/usr/lib/x86_64-linux-gnu/libzookeeper_mt.a"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.918681803" 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.1843090464" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release"> + <option id="gnu.both.asm.option.include.paths.1657336140" 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.1159903939" 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="ZKTest.cdt.managedbuild.target.gnu.exe.1433633248" 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.debug.1901448955;cdt.managedbuild.config.gnu.exe.debug.1901448955.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1250781423;cdt.managedbuild.tool.gnu.c.compiler.input.323699468"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1941090211;cdt.managedbuild.config.gnu.exe.release.1941090211.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.308803272;cdt.managedbuild.tool.gnu.cpp.compiler.input.1259315012"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1901448955;cdt.managedbuild.config.gnu.exe.debug.1901448955.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.872951966;cdt.managedbuild.tool.gnu.cpp.compiler.input.1811754685"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1941090211;cdt.managedbuild.config.gnu.exe.release.1941090211.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1571826105;cdt.managedbuild.tool.gnu.c.compiler.input.1046404675"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Multiple configurations"> + <resource resourceType="PROJECT" workspacePath="/ZKTest"/> + </configuration> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/ZKTest"/> + </configuration> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/ZKTest"/> + </configuration> + </storageModule> +</cproject> diff --git a/ZKTest/.project b/ZKTest/.project new file mode 100644 index 0000000..9c37192 --- /dev/null +++ b/ZKTest/.project @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>ZKTest</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/ZKTest/Debug/ZKTest b/ZKTest/Debug/ZKTest Binary files differnew file mode 100755 index 0000000..21cf97d --- /dev/null +++ b/ZKTest/Debug/ZKTest diff --git a/ZKTest/Debug/makefile b/ZKTest/Debug/makefile new file mode 100644 index 0000000..6e2c718 --- /dev/null +++ b/ZKTest/Debug/makefile @@ -0,0 +1,59 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +-include ../makefile.init + +RM := rm -rf + +# All of the sources participating in the build are defined here +-include sources.mk +-include src/subdir.mk +-include subdir.mk +-include objects.mk + +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(strip $(CC_DEPS)),) +-include $(CC_DEPS) +endif +ifneq ($(strip $(C++_DEPS)),) +-include $(C++_DEPS) +endif +ifneq ($(strip $(C_UPPER_DEPS)),) +-include $(C_UPPER_DEPS) +endif +ifneq ($(strip $(CXX_DEPS)),) +-include $(CXX_DEPS) +endif +ifneq ($(strip $(CPP_DEPS)),) +-include $(CPP_DEPS) +endif +ifneq ($(strip $(C_DEPS)),) +-include $(C_DEPS) +endif +endif + +-include ../makefile.defs + +# Add inputs and outputs from these tool invocations to the build variables + +# All Target +all: ZKTest + +# Tool invocations +ZKTest: $(OBJS) $(USER_OBJS) + @echo 'Building target: $@' + @echo 'Invoking: GCC C++ Linker' + g++ -L/usr/lib/x86_64-linux-gnu/ -o "ZKTest" $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Finished building target: $@' + @echo ' ' + +# Other Targets +clean: + -$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(C_UPPER_DEPS)$(CXX_DEPS)$(OBJS)$(CPP_DEPS)$(C_DEPS) ZKTest + -@echo ' ' + +.PHONY: all clean dependents +.SECONDARY: + +-include ../makefile.targets diff --git a/ZKTest/Debug/objects.mk b/ZKTest/Debug/objects.mk new file mode 100644 index 0000000..81bf874 --- /dev/null +++ b/ZKTest/Debug/objects.mk @@ -0,0 +1,8 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +USER_OBJS := + +LIBS := -lzookeeper_mt + diff --git a/ZKTest/Debug/sources.mk b/ZKTest/Debug/sources.mk new file mode 100644 index 0000000..db4ff87 --- /dev/null +++ b/ZKTest/Debug/sources.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +C_UPPER_SRCS := +CXX_SRCS := +C++_SRCS := +OBJ_SRCS := +CC_SRCS := +ASM_SRCS := +CPP_SRCS := +C_SRCS := +O_SRCS := +S_UPPER_SRCS := +CC_DEPS := +C++_DEPS := +EXECUTABLES := +C_UPPER_DEPS := +CXX_DEPS := +OBJS := +CPP_DEPS := +C_DEPS := + +# Every subdirectory with source files must be described here +SUBDIRS := \ +src \ + diff --git a/ZKTest/Debug/src/ZKTest.d b/ZKTest/Debug/src/ZKTest.d new file mode 100644 index 0000000..85e6b78 --- /dev/null +++ b/ZKTest/Debug/src/ZKTest.d @@ -0,0 +1,15 @@ +src/ZKTest.d: ../src/ZKTest.cpp /usr/include/zookeeper/zookeeper.h \ + /usr/include/zookeeper/proto.h \ + /usr/include/zookeeper/zookeeper_version.h \ + /usr/include/zookeeper/recordio.h \ + /usr/include/zookeeper/zookeeper.jute.h + +/usr/include/zookeeper/zookeeper.h: + +/usr/include/zookeeper/proto.h: + +/usr/include/zookeeper/zookeeper_version.h: + +/usr/include/zookeeper/recordio.h: + +/usr/include/zookeeper/zookeeper.jute.h: diff --git a/ZKTest/Debug/src/ZKTest.o b/ZKTest/Debug/src/ZKTest.o Binary files differnew file mode 100644 index 0000000..f2f42a9 --- /dev/null +++ b/ZKTest/Debug/src/ZKTest.o diff --git a/ZKTest/Debug/src/subdir.mk b/ZKTest/Debug/src/subdir.mk new file mode 100644 index 0000000..3451882 --- /dev/null +++ b/ZKTest/Debug/src/subdir.mk @@ -0,0 +1,24 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +CPP_SRCS += \ +../src/ZKTest.cpp + +OBJS += \ +./src/ZKTest.o + +CPP_DEPS += \ +./src/ZKTest.d + + +# Each subdirectory must supply rules for building sources it contributes +src/%.o: ../src/%.cpp + @echo 'Building file: $<' + @echo 'Invoking: GCC C++ Compiler' + g++ -I/usr/include/zookeeper -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/ZKTest/src/ZKTest.cpp b/ZKTest/src/ZKTest.cpp new file mode 100644 index 0000000..3518271 --- /dev/null +++ b/ZKTest/src/ZKTest.cpp @@ -0,0 +1,130 @@ +//============================================================================ +// 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 <string.h> +#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; +int timeout = 3000; +int responseCode = 0; + +void safeShutdown(zhandle_t *zzh); +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, timeout, 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; + + //responseCode = zoo_create(zk, "/test","my_data",7, &ZOO_OPEN_ACL_UNSAFE, ZOO_EPHEMERAL, NULL, NULL); + while (zk) + { + + } + + std::cout<<"why are we here?"<<std::endl; + safeShutdown(zk); + return 0; +} + +/////////////////////////////////////////////////////////////////////// +/// END OF MAIN /// +/////////////////////////////////////////////////////////////////////// + +void safeShutdown(zhandle_t *zzh) +{ + if (zzh) + { + cout << "closing Zookeeper connection" << std::endl; + zookeeper_close(zzh); + zk = 0; + } +} + +void watcher(zhandle_t *zzh, int type, int state, const char *path, + void *watcherCtx) +{ + if (type == ZOO_SESSION_EVENT) + { + if (state == ZOO_CONNECTED_STATE) + { + cout << "session Connected" << std::endl; + zoo_create(zk, "/test","my_data",7, &ZOO_OPEN_ACL_UNSAFE, ZOO_EPHEMERAL, NULL, 0); + zoo_create(zk, "/childTest","my_data",7, &ZOO_OPEN_ACL_UNSAFE, 0, NULL, 0); + zoo_exists(zk, "/test", true, NULL); + /*zoo_exists tests if a node exists, and if the 3rd argument is non 0 sets a watch + * that watch is triggered upon any change to the file specified in arg 2 + * argument 1 is the zookeeper session to make the request too + * */ + + responseCode = zoo_get_children(zk, "/childTest", true, NULL); + /* + * as zoo_exists but watches children of the specified node. + * argument 4 is a string that can be used to return the path of child nodes. + */ + + std::cout<<responseCode<<std::endl; + session_id = zoo_client_id(zzh); + } + else + { + std::cout<<"change detected!"<<std::endl; + } + } + if (state == ZOO_AUTH_FAILED_STATE) + { + cout << "Refused connection WATCHER RESPONDED " << std::endl; + ; + safeShutdown(zzh); + } + else if (state == ZOO_EXPIRED_SESSION_STATE) + { + cout << "session expired attempting to re-connect" << std::endl; + zk = zookeeper_init("localhost:2181", watcher, timeout, session_id, NULL, + 0); + } + else if (state == ZOO_DELETED_EVENT) + { + cout << "node delete detected" << std::endl; + } + else if (state == ZOO_CHANGED_EVENT) + { + responseCode = zoo_exists(zk, path, true, NULL); + cout << "change detected" << std::endl; + } + else if (state == ZOO_CHILD_EVENT) + { + zoo_get_children(zk, path, true, NULL); + cout << "child change detected" << std::endl; + } +} |