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/src/ZKTest.cpp | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 ZKTest/src/ZKTest.cpp (limited to 'ZKTest/src') 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?"<