How to use the node-zookeeper-client.State 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 XadillaX / illyria2 / lib / illyria-zk.js View on Github external
this.client.on("state", function(state) {
        // automatically reconnect
        if(self.clientStatus !== ZK_STATUS.NOT_CONNECTED &&
            state === zookeeper.State.EXPIRED) {
            setTimeout(self.connect, 1, callback, -1);
        }
    });
github xpush / node-xpush / lib / util / global-config.js View on Github external
Configure.prototype.setConfigOnce = function (key, value, cb) {
  var self = this;
  var newPath = this.basePath + '/' + key;

  if (self.zkClient.getState() != zookeeper.State.SYNC_CONNECTED) {
    return self._beforeConnected.push({method: "setOnce", cb: cb, k: key, v: value});
  }
  self.zkClient.exists(
    newPath,
    function (error, stat) {
      if (error) {
        console.log(error.stack);
        return;
      }

      if (!stat) {
        self._createZnodeWithData(newPath, JSON.stringify(value), function (err) {
          if (cb) cb(err);
        });
      } else {
        self.zkClient.setData(newPath, new Buffer(JSON.stringify(value)), -1,
github XadillaX / illyria2 / lib / zookeeper.js View on Github external
this.client.on("state", function(state) {
        if(self.clientStatus !== ZK_STATUS.NOT_CONNECTED &&
            state === zookeeper.State.EXPIRED) {
            setTimeout(self.connect, 100, function(err) {
                console.error(
                    "Illyria zookeeper failed to reconnect when expired: " +
                    err.message);
            });
        }
    });
github XadillaX / illyria2 / lib / server_zookeeper.js View on Github external
this.client.on("state", function(state) {
        if(self.clientStatus !== ZK_STATUS.NOT_CONNECTED &&
            state === zookeeper.State.EXPIRED) {
            setTimeout(self.connect, 100, function(err) {
                console.error(
                    "Illyria zookeeper failed to reconnect when expired: " +
                    err.message);
            });
        }
    });
github Corey600 / zoodubbo / lib / registry.js View on Github external
ZD.prototype.close = function () {
    var self = this;
    if (!self._client || !self._client.close) {
        return;
    }
    var state = self._client.getState();
    if (state == zookeeper.State.CONNECTED
        || state == zookeeper.State.CONNECTED_READ_ONLY) {
        this._client.close();
    }
};
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 joola / joola / lib / discovery / providers / zookeeper.js View on Github external
this.zookeeper.on('state', function (state) {
    switch (state) {
      case zookeeper.State.SYNC_CONNECTED:
        if (!self.initialized) {
          self.initialized = true;
          self.onconnected(callback);
        }
        else
          self.onconnected(function () {
          });
        break;
      case zookeeper.State.DISCONNECTED:
        self.ondisconnected();
        break;
      case zookeeper.State.EXPIRED:
        self.onexpired();
        break;
      default:
        break;
    }
  });
github scality / backbeat / bin / ingestion.js View on Github external
healthServer.onReadyCheck(() => {
        const state = ingestionPopulator.zkStatus();
        if (state.code === zookeeper.State.SYNC_CONNECTED.code) {
            return true;
        }
        log.error(`Zookeeper is not connected! ${state}`);
        return false;
    });
    log.info('Starting health probe server');
github scality / backbeat / extensions / lifecycle / conductor / LifecycleConductor.js View on Github external
isReady() {
        const state = this._zkClient && this._zkClient.getState();
        return this._producer && this._producer.isReady() && state &&
            state.code === zookeeper.State.SYNC_CONNECTED.code;
    }
}
github Corey600 / zoodubbo / lib / registry.js View on Github external
ZD.prototype.close = function () {
    var self = this;
    if (!self._client || !self._client.close) {
        return;
    }
    var state = self._client.getState();
    if (state == zookeeper.State.CONNECTED
        || state == zookeeper.State.CONNECTED_READ_ONLY) {
        this._client.close();
    }
};