summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Smith <mike.smith@codethink.co.uk>2014-11-20 16:41:41 +0000
committerMike Smith <mike.smith@codethink.co.uk>2014-11-20 16:41:41 +0000
commit9ea6dcf3615bbce36e1f90f85eb47aba25fecdba (patch)
tree970c2c318d404770d6c3f7d7be53311ca13997d7
parent2a7bb9ea3747b02e5f13f301444f1f8635fdfaa4 (diff)
downloadzookeeper-test-9ea6dcf3615bbce36e1f90f85eb47aba25fecdba.tar.gz
attempting to get child watches to happen recursivly, so that children of children are also watched
-rwxr-xr-xZKTest/Debug/ZKTestbin91773 -> 91991 bytes
-rw-r--r--ZKTest/Debug/src/ZKTest.obin180024 -> 181256 bytes
-rw-r--r--ZKTest/src/ZKTest.cpp23
3 files changed, 17 insertions, 6 deletions
diff --git a/ZKTest/Debug/ZKTest b/ZKTest/Debug/ZKTest
index 21cf97d..1abce8b 100755
--- a/ZKTest/Debug/ZKTest
+++ b/ZKTest/Debug/ZKTest
Binary files differ
diff --git a/ZKTest/Debug/src/ZKTest.o b/ZKTest/Debug/src/ZKTest.o
index f2f42a9..f4c4187 100644
--- a/ZKTest/Debug/src/ZKTest.o
+++ b/ZKTest/Debug/src/ZKTest.o
Binary files differ
diff --git a/ZKTest/src/ZKTest.cpp b/ZKTest/src/ZKTest.cpp
index 3518271..05691ba 100644
--- a/ZKTest/src/ZKTest.cpp
+++ b/ZKTest/src/ZKTest.cpp
@@ -18,6 +18,7 @@ using namespace std;
static zhandle_t *zk;
static const clientid_t *session_id;
+struct String_vector *list_of_children;
int timeout = 3000;
int responseCode = 0;
@@ -46,7 +47,6 @@ int main(int argc, char **argv)
}
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)
{
@@ -117,14 +117,25 @@ void watcher(zhandle_t *zzh, int type, int state, const char *path,
{
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;
}
+ else if (state == ZOO_CHANGED_EVENT)
+ {
+ responseCode = zoo_exists(zk, path, true, NULL);
+ std::cout<<"£"<<std::endl;
+ responseCode = zoo_get_children(zk, path, true, list_of_children);
+ std::cout<<"£"<<std::endl;
+ if(list_of_children)
+ {
+ for (int i = 0; i < list_of_children->count; i++)
+ {
+ std::cout<<list_of_children->count<<std::endl;
+ responseCode = zoo_exists(zk, path + '/' + *list_of_children->data[i] , true, NULL);
+ }
+ }
+ cout << "change detected" << std::endl;
+ }
}