How to use the zookeeper.ZOO_SEQUENCE function in zookeeper

To help you get started, we’ve selected a few zookeeper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github howech / gestalt / examples / zookeeper_election.js View on Github external
zkc.zookeeper( function(zk) {
    console.log("creating temp node");
    zk.a_create("/chh/temp/node","stuff", ZooKeeper.ZOO_SEQUENCE + ZooKeeper.ZOO_EPHEMERAL ,function (rc, error, path)  {
        if (rc != 0) {
            console.log ("zk node create result: %d, error: '%s', path=%s", rc, error, path);
	} else {
	    // console.log("================== %s", path );
	    var me = path.match(/[^\/]+$/)[0];
	    console.log("My name is: %s", me);
	    var dir = "/chh/temp";
	    election(zk,dir,me);
	}
    });
});
github howech / gestalt / examples / cluster.js View on Github external
zk_ensure_path(zk, dir, function(err) {
	if(err) {
	    throw err;
	}
	zk.a_create(dir + "/n",name, ZooKeeper.ZOO_SEQUENCE + ZooKeeper.ZOO_EPHEMERAL,function (rc, error, path)  {
	    if (rc != 0) {
		throw new Error("Unable to create ballot node");
 	    } else {
 		var me = path.match(/[^\/]+$/)[0];
 		zk_election(zk,dir,me,become_leader);
 	    }
	});
    });
}