How to use the node-zookeeper-client.CreateMode function in node-zookeeper-client

To help you get started, we’ve selected a few node-zookeeper-client 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 hyperledger-archives / caliper / src / comm / client / zoo-client.js View on Github external
.then((found)=>{
        if(found) {
            return Promise.resolve();
        }
        else {
            return zkUtil.createP(zk, zkUtil.NODE_CLIENT, null, ZooKeeper.CreateMode.PERSISTENT, 'Failed to create clients node due to');
        }
    })
    .then(()=>{         // create client node
github apache / dubbo-js / packages / dubbo / src / registry / zookeeper.ts View on Github external
private async _createRootConsumer(consumer: string) {
    let {res, err} = await go(this._exists(consumer));
    //check error
    if (err) {
      return err;
    }

    // current consumer root path was existed.
    if (res) {
      return null;
    }

    //create current consumer path
    ({err} = await go(this._create(consumer, zookeeper.CreateMode.PERSISTENT)));
    if (err) {
      return err;
    }

    log('create root comsumer %s successfull', consumer);
  }
github MZMonster / node-thrift-service / lib / zookeeper.js View on Github external
* manage zookeeper client
 *
 * @author zzxun 
 */
'use strict';

/**
 * module dependencies
 */
const _ = require('lodash');
const zookeeper = require('node-zookeeper-client');
const Promises = require('bluebird');
const EventEmitter = require('events').EventEmitter;
const utils = require('./util');

const CreateMode = zookeeper.CreateMode;

class ZookeeperService extends EventEmitter {

  constructor(options) {
    super();

    let self = this;

    self._root = options.root;
    // initial
    options = _.merge({
      connect       : '127.0.0.1:2181',
      sessionTimeout: 200000
    }, options);

    self._zk = zookeeper.createClient(options.connect, options);
github apache / dubbo-js / packages / dubbo-json-rpc / src / zookeeper-registry.js View on Github external
var createConsumer = function() {
    var url = 'consumer://' + ip.address() + '/' + provider + '?' + qs.stringify(params);
    this._client.create(
      consumers + '/' + qs.escape(url), new Buffer(''),
      zookeeper.CreateMode.EPHEMERAL,
      function (err, path) {
        //console.log(err, path);
      });
  }.bind(this);
github Corey600 / node-disconf-client / lib / ConfNode.js View on Github external
self._zk.exists(path, function (err, stat) {
        if (!err && !stat) {
            log.info('persistent node does need to create. path: %s', path);
            self._zk.mkdirp(
                path,
                new Buffer(data),
                zookeeper.CreateMode.PERSISTENT,
                callback
            );
        } else {
            callback(err, path);
        }
    });
    return this;
github node-modules / zookeeper-cluster-client / lib / index.js View on Github external
'use strict';

const zookeeper = require('node-zookeeper-client');
const ZookeeperClient = require('./api_client');

exports.createClient = (connectionString, options) => {
  options = options || {};
  options.connectionString = connectionString || 'localhost:2181';
  return new ZookeeperClient(options);
};

exports.ACL = zookeeper.ACL;
exports.Id = zookeeper.Id;
exports.Permission = zookeeper.Permission;
exports.CreateMode = zookeeper.CreateMode;
exports.State = zookeeper.State;
exports.Event = zookeeper.Event;
exports.Exception = zookeeper.Exception;
github SOHU-Co / kafka-node / lib / zookeeper.js View on Github external
function (callback) {
        that.client.create(path + '/ids/' + consumerId, null, null, zookeeper.CreateMode.EPHEMERAL, function (
          error,
          path
        ) {
          if (error) {
            callback(error);
          } else {
            callback();
          }
        });
      },
      function (callback) {
github XadillaX / illyria2 / lib / zookeeper.js View on Github external
(function() {

var Enum = require("enum");
var EventEmitter = require("events").EventEmitter;
var util = require("util");
var async = require("async");
var zookeeper = require("node-zookeeper-client");

var helper = require("./helper");

var CREATE_MODE = zookeeper.CreateMode;
var ZK_STATUS = new Enum([
    "NOT_CONNECTED",
    "CONNECTING",
    "CONNECTED"
]);

/**
 * illyria zookeeper wrapper
 * @param {String|Array} connectString the connect string(s)
 * @param {Object} options the connect options, refer to
 *                         https://github.com/alexguan/node-zookeeper-client
 *                         #client-createclientconnectionstring-options
 * @param {String} [root] the root path
 * @param {String} [prefix] the path's prefix
 * @constructor
 */
github scality / backbeat / lib / provisioning / ProvisionDispatcher.js View on Github external
() => this._client.create(
                zkPath, null, zookeeper.ACL.OPEN_ACL_UNSAFE,
                zookeeper.CreateMode.EPHEMERAL,
                err => {
                    if (err) {
                        return cb(err);
                    }
                    this._log.debug('registered owner zk node',
                                    { zkPath: `${this._zkEndpoint}${zkPath}` });
                    return cb(null, zkPath);
                })
        );
github hyperledger / caliper / packages / caliper-core / lib / client / caliper-zoo-client.js View on Github external
zkUtil.existsP(self.zk, zkUtil.NODE_ROOT, 'Failed to find NODE_ROOT due to').then((found)=>{
                if(found) {
                    return Promise.resolve();
                }
                else {
                    return zkUtil.createP(self.zk, zkUtil.NODE_ROOT, null, ZooKeeper.CreateMode.PERSISTENT, 'Failed to create NODE_ROOT due to');
                }
            }).then(()=>{
                return zkUtil.existsP(self.zk, zkUtil.NODE_CLIENT, 'Failed to find clients node due to');