Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
});
});
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);
}
});
});
}