com.indeed.util.zookeeper.ZooKeeperConnection.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中com.indeed.util.zookeeper.ZooKeeperConnection.<init>()方法的一些代码示例,展示了ZooKeeperConnection.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperConnection.<init>()方法的具体详情如下:
包路径:com.indeed.util.zookeeper.ZooKeeperConnection
类名称:ZooKeeperConnection
方法名:<init>

ZooKeeperConnection.<init>介绍

暂无

代码示例

代码示例来源:origin: indeedeng/imhotep

public ServiceZooKeeperWrapper(final String zkNodes, final String hostname, final int port,
                final String rootPath) {
  zkConnection = new ZooKeeperConnection(zkNodes, TIMEOUT);
  this.rootPath = rootPath;
  nodeName = UUID.randomUUID().toString();
  data = (hostname+":"+port).getBytes(Charsets.UTF_8);
  closed = false;
  createNode();
  zkConnection.register(new MyWatcher());
}

代码示例来源:origin: indeedeng/imhotep

public ZkHostsReloader(final String zkNodes, final String zkPath, final boolean readHostsBeforeReturning) {
  super("ZkHostsReloader");
  zkConnection = new ZooKeeperConnection(zkNodes, TIMEOUT);
  try {
    zkConnection.connect();
  } catch (Exception e) {
    throw Throwables.propagate(e);
  }
  this.zkPath = trimEndingSlash(zkPath);
  closed = false;
  hosts = new ArrayList<Host>();
  if (readHostsBeforeReturning) {
    int retries = 0;
    while (true) {
      updateLastLoadCheck();
      if (load()) {
        loadComplete();
        break;
      }
      try {
        Thread.sleep(TIMEOUT);
      } catch (InterruptedException e) {
        log.error("interrupted", e);
      }
      if (++retries == 5) {
        throw new RuntimeException("unable to connect to zookeeper");
      }
    }
  }
}

相关文章