From bf26fc210218f51181127f49ef9e1f81f2f7de57 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Wed, 19 Nov 2014 15:16:18 +0000 Subject: initial commit of zookeeper proof-of-concept program --- ZKTest/.cproject | 158 +++++++++++++++++++++++++++++++++++++++++++++ ZKTest/.project | 27 ++++++++ ZKTest/Debug/ZKTest | Bin 0 -> 91773 bytes ZKTest/Debug/makefile | 59 +++++++++++++++++ ZKTest/Debug/objects.mk | 8 +++ ZKTest/Debug/sources.mk | 27 ++++++++ ZKTest/Debug/src/ZKTest.d | 15 +++++ ZKTest/Debug/src/ZKTest.o | Bin 0 -> 180024 bytes ZKTest/Debug/src/subdir.mk | 24 +++++++ ZKTest/src/ZKTest.cpp | 130 +++++++++++++++++++++++++++++++++++++ 10 files changed, 448 insertions(+) create mode 100644 ZKTest/.cproject create mode 100644 ZKTest/.project create mode 100755 ZKTest/Debug/ZKTest create mode 100644 ZKTest/Debug/makefile create mode 100644 ZKTest/Debug/objects.mk create mode 100644 ZKTest/Debug/sources.mk create mode 100644 ZKTest/Debug/src/ZKTest.d create mode 100644 ZKTest/Debug/src/ZKTest.o create mode 100644 ZKTest/Debug/src/subdir.mk create mode 100644 ZKTest/src/ZKTest.cpp diff --git a/ZKTest/.cproject b/ZKTest/.cproject new file mode 100644 index 0000000..4f3143f --- /dev/null +++ b/ZKTest/.cproject @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZKTest/.project b/ZKTest/.project new file mode 100644 index 0000000..9c37192 --- /dev/null +++ b/ZKTest/.project @@ -0,0 +1,27 @@ + + + ZKTest + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/ZKTest/Debug/ZKTest b/ZKTest/Debug/ZKTest new file mode 100755 index 0000000..21cf97d Binary files /dev/null and b/ZKTest/Debug/ZKTest differ 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 new file mode 100644 index 0000000..f2f42a9 Binary files /dev/null and b/ZKTest/Debug/src/ZKTest.o differ 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 +#include +#include +#include +#include +#include +#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?"<