org.apache.hadoop.hbase.zookeeper.ZKUtil.listChildrenAndWatchThem()方法的使用及代码示例

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

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

ZKUtil.listChildrenAndWatchThem介绍

[英]List all the children of the specified znode, setting a watch for children changes and also setting a watch on every individual child in order to get the NodeCreated and NodeDeleted events.
[中]列出指定znode的所有子节点,为子节点更改设置监视,并为每个子节点设置监视,以获得NodeCreated和NodeDeleted事件。

代码示例

代码示例来源:origin: apache/hbase

break;
List<String> children = listChildrenAndWatchThem(zkw, node);
if (children == null) {
 continue;

代码示例来源:origin: apache/hbase

/**
 * Read the list of children under the archive znode as table names and then sets those tables to
 * the list of tables that we should archive
 * @throws KeeperException if there is an unexpected zk exception
 */
private void updateWatchedTables() throws KeeperException {
 // get the children and watch for new children
 LOG.debug("Updating watches on tables to archive.");
 // get the children and add watches for each of the children
 List<String> tables = ZKUtil.listChildrenAndWatchThem(watcher, archiveHFileZNode);
 LOG.debug("Starting archive for tables:" + tables);
 // if archiving is still enabled
 if (tables != null && tables.size() > 0) {
  getMonitor().setArchiveTables(tables);
 } else {
  LOG.debug("No tables to archive.");
  // only if we currently have a tracker, then clear the archive
  clearTables();
 }
}

代码示例来源:origin: apache/hbase

@Override
 public void nodeChildrenChanged(final String path) {
  if(path.equals(watcher.getZNodePaths().drainingZNode)) {
   try {
    final List<String> newNodes =
     ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().drainingZNode);
    add(newNodes);
   } catch (KeeperException e) {
    abortable.abort("Unexpected zk exception getting RS nodes", e);
   } catch (IOException e) {
    abortable.abort("Unexpected zk exception getting RS nodes", e);
   }
  }
 }
}

代码示例来源:origin: apache/hbase

/**
  * Get a list of all the other region servers in this cluster and set a watch
  * @return a list of server nanes
  */
 private List<String> getRegisteredRegionServers(boolean watch) {
  List<String> result = null;
  try {
   if (watch) {
    result = ZKUtil.listChildrenAndWatchThem(this.zookeeper,
        this.zookeeper.getZNodePaths().rsZNode);
   } else {
    result = ZKUtil.listChildrenNoWatch(this.zookeeper, this.zookeeper.getZNodePaths().rsZNode);
   }
  } catch (KeeperException e) {
   this.abortable.abort("Get list of registered region servers", e);
  }
  return result;
 }
}

代码示例来源:origin: apache/hbase

/**
 * Starts the tracking of draining RegionServers.
 *
 * <p>All Draining RSs will be tracked after this method is called.
 *
 * @throws KeeperException
 */
public void start() throws KeeperException, IOException {
 watcher.registerListener(this);
 // Add a ServerListener to check if a server is draining when it's added.
 serverManager.registerListener(new ServerListener() {
  @Override
  public void serverAdded(ServerName sn) {
   if (drainingServers.contains(sn)){
    serverManager.addServerToDrainList(sn);
   }
  }
 });
 List<String> servers =
  ZKUtil.listChildrenAndWatchThem(watcher, watcher.getZNodePaths().drainingZNode);
 add(servers);
}

代码示例来源:origin: XiaoMi/themis

protected void loadAliveClients() throws KeeperException, IOException {
 aliveClients.clear();
 aliveClients.addAll(ZKUtil.listChildrenAndWatchThem(watcher, aliveClientParentPath));
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * List this cluster's peers' IDs
 * @return list of all peers' identifiers
 */
public List<String> listPeersIdsAndWatch() {
 List<String> ids = null;
 try {
  ids = ZKUtil.listChildrenAndWatchThem(this.zookeeper, this.peersZNode);
 } catch (KeeperException e) {
  this.abortable.abort("Cannot get the list of peers ", e);
 }
 return ids;
}

代码示例来源:origin: harbby/presto-connectors

/**
 * List all registered peer clusters and set a watch on their znodes.
 */
@Override
public List<String> getAllPeerIds() {
 List<String> ids = null;
 try {
  ids = ZKUtil.listChildrenAndWatchThem(this.zookeeper, this.peersZNode);
 } catch (KeeperException e) {
  this.abortable.abort("Cannot get the list of peers ", e);
 }
 return ids;
}

代码示例来源:origin: harbby/presto-connectors

/**
  * Get a list of all the other region servers in this cluster and set a watch
  * @return a list of server nanes
  */
 private List<String> getRegisteredRegionServers() {
  List<String> result = null;
  try {
   result = ZKUtil.listChildrenAndWatchThem(this.zookeeper, this.zookeeper.rsZNode);
  } catch (KeeperException e) {
   this.abortable.abort("Get list of registered region servers", e);
  }
  return result;
 }
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Get a list of all the other region servers in this cluster
 * and set a watch
 * @return a list of server nanes
 */
public List<String> getRegisteredRegionServers() {
 List<String> result = null;
 try {
  result = ZKUtil.listChildrenAndWatchThem(
    this.zookeeper, this.zookeeper.rsZNode);
 } catch (KeeperException e) {
  this.abortable.abort("Get list of registered region servers", e);
 }
 return result;
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Starts the tracking of draining RegionServers.
 *
 * <p>All Draining RSs will be tracked after this method is called.
 *
 * @throws KeeperException
 */
public void start() throws KeeperException, IOException {
 watcher.registerListener(this);
 List<String> servers =
  ZKUtil.listChildrenAndWatchThem(watcher, watcher.drainingZNode);
 add(servers);
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Starts the tracking of draining RegionServers.
 *
 * <p>All Draining RSs will be tracked after this method is called.
 *
 * @throws KeeperException
 */
public void start() throws KeeperException, IOException {
 watcher.registerListener(this);
 List<String> servers =
  ZKUtil.listChildrenAndWatchThem(watcher, watcher.drainingZNode);
 add(servers);
}

代码示例来源:origin: co.cask.hbase/hbase

/**
 * Starts the tracking of online RegionServers.
 *
 * <p>All RSs will be tracked after this method is called.
 *
 * @throws KeeperException
 * @throws IOException
 */
public void start() throws KeeperException, IOException {
 watcher.registerListener(this);
 List<String> servers =
  ZKUtil.listChildrenAndWatchThem(watcher, watcher.rsZNode);
 add(servers);
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Starts the tracking of online RegionServers.
 *
 * <p>All RSs will be tracked after this method is called.
 *
 * @throws KeeperException
 * @throws IOException
 */
public void start() throws KeeperException, IOException {
 watcher.registerListener(this);
 List<String> servers =
  ZKUtil.listChildrenAndWatchThem(watcher, watcher.rsZNode);
 add(servers);
}

代码示例来源:origin: co.cask.hbase/hbase

@Override
public void nodeChildrenChanged(String path) {
 if (path.equals(watcher.rsZNode)) {
  try {
   List<String> servers =
    ZKUtil.listChildrenAndWatchThem(watcher, watcher.rsZNode);
   add(servers);
  } catch (IOException e) {
   abortable.abort("Unexpected zk exception getting RS nodes", e);
  } catch (KeeperException e) {
   abortable.abort("Unexpected zk exception getting RS nodes", e);
  }
 }
}

代码示例来源:origin: co.cask.hbase/hbase

@Override
public void nodeChildrenChanged(final String path) {
 if(path.equals(watcher.drainingZNode)) {
  try {
   final List<String> newNodes =
    ZKUtil.listChildrenAndWatchThem(watcher, watcher.drainingZNode);
   add(newNodes);
  } catch (KeeperException e) {
   abortable.abort("Unexpected zk exception getting RS nodes", e);
  } catch (IOException e) {
   abortable.abort("Unexpected zk exception getting RS nodes", e);
  }
 }
}

代码示例来源:origin: harbby/presto-connectors

@Override
 public void nodeChildrenChanged(final String path) {
  if(path.equals(watcher.drainingZNode)) {
   try {
    final List<String> newNodes =
     ZKUtil.listChildrenAndWatchThem(watcher, watcher.drainingZNode);
    add(newNodes);
   } catch (KeeperException e) {
    abortable.abort("Unexpected zk exception getting RS nodes", e);
   } catch (IOException e) {
    abortable.abort("Unexpected zk exception getting RS nodes", e);
   }
  }
 }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void nodeChildrenChanged(String path) {
 if (path.equals(watcher.rsZNode)
   && !server.isAborted() && !server.isStopped()) {
  try {
   List<String> servers =
    ZKUtil.listChildrenAndWatchThem(watcher, watcher.rsZNode);
   add(servers);
  } catch (IOException e) {
   server.abort("Unexpected zk exception getting RS nodes", e);
  } catch (KeeperException e) {
   server.abort("Unexpected zk exception getting RS nodes", e);
  }
 }
}

代码示例来源:origin: org.apache.hbase/hbase-replication

/**
  * Get a list of all the other region servers in this cluster and set a watch
  * @return a list of server nanes
  */
 private List<String> getRegisteredRegionServers(boolean watch) {
  List<String> result = null;
  try {
   if (watch) {
    result = ZKUtil.listChildrenAndWatchThem(this.zookeeper,
        this.zookeeper.getZNodePaths().rsZNode);
   } else {
    result = ZKUtil.listChildrenNoWatch(this.zookeeper, this.zookeeper.getZNodePaths().rsZNode);
   }
  } catch (KeeperException e) {
   this.abortable.abort("Get list of registered region servers", e);
  }
  return result;
 }
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Read the list of children under the archive znode as table names and then sets those tables to
 * the list of tables that we should archive
 * @throws KeeperException if there is an unexpected zk exception
 */
private void updateWatchedTables() throws KeeperException {
 // get the children and watch for new children
 LOG.debug("Updating watches on tables to archive.");
 // get the children and add watches for each of the children
 List<String> tables = ZKUtil.listChildrenAndWatchThem(watcher, archiveHFileZNode);
 LOG.debug("Starting archive for tables:" + tables);
 // if archiving is still enabled
 if (tables != null && tables.size() > 0) {
  getMonitor().setArchiveTables(tables);
 } else {
  LOG.debug("No tables to archive.");
  // only if we currently have a tracker, then clear the archive
  clearTables();
 }
}

相关文章

微信公众号

最新文章

更多