From 03f98f1449a8c9dd9d3a78c1fb4b10595033a010 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Tue, 25 Nov 2014 17:10:29 +0000 Subject: now allows initial config to be specified --- ZKTest/Debug/ZKTest | Bin 140071 -> 191145 bytes ZKTest/Debug/src/ZKTest.o | Bin 259776 -> 365008 bytes ZKTest/src/ZKTest.cpp | 79 +++++++++++++++++++++++++++++++++++----------- 3 files changed, 60 insertions(+), 19 deletions(-) (limited to 'ZKTest') diff --git a/ZKTest/Debug/ZKTest b/ZKTest/Debug/ZKTest index d9d17c1..3ffd542 100755 Binary files a/ZKTest/Debug/ZKTest and b/ZKTest/Debug/ZKTest differ diff --git a/ZKTest/Debug/src/ZKTest.o b/ZKTest/Debug/src/ZKTest.o index 11cfd6d..eb10575 100644 Binary files a/ZKTest/Debug/src/ZKTest.o and b/ZKTest/Debug/src/ZKTest.o differ diff --git a/ZKTest/src/ZKTest.cpp b/ZKTest/src/ZKTest.cpp index 07a2307..c4f4017 100644 --- a/ZKTest/src/ZKTest.cpp +++ b/ZKTest/src/ZKTest.cpp @@ -7,7 +7,10 @@ //============================================================================ #include +#include +#include #include +#include #include #include #include @@ -26,9 +29,9 @@ struct String_vector list_of_children = {0}; int timeout = 3000; int responseCode = 0; std::mutex mutex_lock; - void safeShutdown(zhandle_t *zzh); void configure(); +void setConfiguration(char* configString); void configurationwatcher(zhandle_t *zzh, int type, int state, const char *path, void *watcherCtx); void watcher(zhandle_t *zzh, int type, int state, const char *path, @@ -41,12 +44,12 @@ int main(int argc, char **argv) * checking to see if the host entered as the second argument is valid * if no host is entered the program will default to local host */ - char* hosts; + char* hosts = "localhost:2181"; char* check = "localhost"; char* check2 = ":"; if(argc >1) { - for (int i = 1; i < argc-1; i++ ) + for (int i = 1; i < argc; i++ ) { if(isdigit(argv[i][0])) { @@ -171,30 +174,36 @@ void watcher(zhandle_t *zzh, int type, int state, const char *path, if (state == ZOO_CONNECTED_STATE) { std::cout<> temp; string addition_of_strings = "/configTest/" + temp; - const char* node_to_watch = addition_of_strings.c_str(); - std::cout<<"setting watch for config type of "< elements; + uint configBegin = 0; + for (uint it = 0; it != strlen(configString); it++ ) + { + if(configString[it] == ';' || NULL) + { + string tempString; + while(configBegin != it) + { + tempString += configString[configBegin]; + configBegin++; + } + 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 "<