//============================================================================ // 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?"<