Exemplo n.º 1
0
zk.connect(function(err) {
    if(err) throw err;
    console.log('zk session established, id=%s.', zk.client_id);
    zk.a_get_children('/app_config/smart_monitor_ports', true, function(rc, error, children) {
        console.log(rc, error, children);
    });
});
Exemplo n.º 2
0
// {
//   name: '',
//   data: '',
//   children: [
//     {
//       name: '',
//       data: '',
//       children: []
//     }
//   ]
// }
function recurse(path, callback) {
  var node = {
    name: path
  };
  zk.a_get(path, false, function(rc, error, stat, data) {
    node.data = data.toString('utf8');
  });
  zk.a_get_children(path, false, function(rc, error, children) {
    console.log(path, 'has:', children);
    async.map(children, function(child, cb) {
      var childPath;
      if (path.length > 1) {
        childPath = path + '/' + child;
      } else {
        childPath = path + child;
      }
      recurse(childPath, cb);
    }, function(err, childNodes) {
      if (err) return callback(err);
      node.children = childNodes;
      // TODO: Explicitly wait for data.
      callback(err, node);
    });
  });
}
Exemplo n.º 3
0
 function getBrokerPartitions(callback) {
   log.debug('getConsumerOffsets/getBrokerPartitions');
   zk.a_get_children(groupTopicPath, false, function(rc, error, brokerPartitions) {
     if (rc != 0) return callback(error);
     return callback(null, brokerPartitions);
   });
 },
Exemplo n.º 4
0
 function getBrokerList(callback) {
   log.debug('getBrokers/getBrokerList');
   zk.a_get_children(brokerIdPath, false, function(rc, error, children) {
     if (rc != 0) return callback(error);
     if (children.length == 0) return callback('No brokers');
     callback(null, children);
   });
 },
Exemplo n.º 5
0
 zk.a_create("/test","", 0,function (rc, error, path){
      zk.a_get_children("/test",false,function(rc,error,children){
          var count = 0;
          var finish = 0
          if(children)
              finish = children.length
          if(finish==0){
              done()
              return;
          }
 
          for(var i in children){
              zk.a_delete_("/test/"+children[i],-1,function(rc,error,path){
                  count++;
                  if(count>=finish){
                      done()
                  }
              })
          }
      })
  })