zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Sharpe <realrichardsha...@gmail.com>
Subject Help with what I am doing wrong with the C interface ...
Date Sun, 11 Jan 2015 17:59:51 GMT
Hi folks,

I am not sure if this is the correct interface, however, I am trying
to develop a config backend for Samba that connects to Zookeeper. The
intent is that parts of Samba's smb.conf would be stored in zookeeper
to make life easier in clustered environments.

I am constrained to use C both by the code I am working with and by
inclination. The examples in C are somewhat sparse.

I am trying to use the sync interface at the moment and I get zero
children back when I call zoo_get_children, however, if I use cli_mt I
can see that there is one child node under /samba in zookeeper:

    [root@localhost zookeeper-3.4.6]# ./src/c/cli_mt localhost:2181
    Got a new session id: 0x14accb10de10004

    ls /
    time = 1 msec
    /: rc = 0
    time = 1 msec
    ls /samba
    time = 1 msec
    /samba: rc = 0
    time = 1 msec

I am pretty certain that I am asking for the children of /samba as my
logging code shows me that I am feeding that path to zoo_get_children
and when I had a bug that appended a trailing slash I got error -8

Here are what I think are the relevant parts of the code I have at the moment:

static void zoo_watcher(zhandle_t *zzh, int type, int state, const char *path,
                        void *context)
        DEBUG(10, ("%s called\n",__func__));


        zh = zookeeper_init(host_port, zoo_watcher, 30000, &myId, 0, 0);
        if (!zh) {
                DEBUG(10, ("Problem with zookeeper_init: %s\n",


        struct String_vector strings;

        rc = zoo_get_children(zh, zookeeper_key, false, &strings);

There are hints in the test code for the C client interface that
perhaps I should be doing something real in the watcher function above
but I am not sure.

Any hints would be appreciated.

Richard Sharpe

View raw message