On Mon, 12 Apr 2010 14:33:44 -0700
Mahadev Konar <maha...@yahoo-inc.com> wrote:

> Hi Kevin,
>  Thanks for the info. Could you cut and paste the code you are using
> that prints the view info?
> That would help. We can then create a jira and follow up on that.
> Also, a zookeeper client can never go back in time (even if its gets
> disconnected and connected back to another server).
> Thanks
> mahadev

Ah, sorry, I meant to include that last time.

This is the function I use to read the cversion:

static int32_t read_path_cversion(zhandle_t *zkhandle, const char
*path) {
    struct Stat stat;
    int zoo_result;

    memset(&stat, 0, sizeof(struct Stat));

    zoo_result = zoo_exists(zkhandle, path, 0, &stat);

    if (zoo_result != ZOK) {
        return -1;

    return stat.cversion;

It gets called by this function, which is called whenever the client
(re)connects to the server or when the watch on the group node gets

static int process_membership_change(zhandle_t *zkhandle, zk_comm_t
*context, const char *path) {
    struct String_vector children;
    int32_t view_before = 0;
    int32_t view_after = view_before + 1;
    int zoo_result = 0;
    int i;

    while (view_before != view_after) {
        view_before = read_path_cversion(zkhandle, path);

        zoo_result = zoo_get_children(zkhandle, path, 1, &children);
        if (zoo_result != ZOK) {
            return zoo_result;

        view_after = read_path_cversion(zkhandle, path);

    printlog(LOG_CRITICAL, "ZK(%" PRIu32 "): %u Beginning new view #%"
PRId32 ".  Unsetting panic...\n", context->comm->id, time(NULL),

    (call application function to restart with group #view_after)

    More application logic

Let me know if any other details would be helpful.


Reply via email to