gpt4 book ai didi

com.alibaba.wasp.zookeeper.ZKUtil.listChildrenAndWatchForNewChildren()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 11:21:32 26 4
gpt4 key购买 nike

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

ZKUtil.listChildrenAndWatchForNewChildren介绍

[英]Lists the children znodes of the specified znode. Also sets a watch on the specified znode which will capture a NodeDeleted event on the specified znode as well as NodeChildrenChanged if any children of the specified znode are created or deleted. Returns null if the specified node does not exist. Otherwise returns a list of children of the specified node. If the node exists but it has no children, an empty list will be returned.
[中]列出指定znode的子znode。还将在指定的znode上设置一个监视,该监视将捕获指定znode上的NodeDeleted事件,以及如果创建或删除指定znode的任何子节点,NodeChildrenChanged。如果指定的节点不存在,则返回null。否则返回指定节点的子节点列表。如果节点存在但没有子节点,则返回空列表。

代码示例

代码示例来源:origin: alibaba/wasp

/**
 * Blocks until there is at least one node in entityGroups in transition.
 * <p>
 * Used in testing only.
 * @param zkw zk reference
 * @throws org.apache.zookeeper.KeeperException
 * @throws InterruptedException
 */
public static void blockUntilRIT(ZooKeeperWatcher zkw)
  throws KeeperException, InterruptedException {
 while (!ZKUtil.nodeHasChildren(zkw, zkw.assignmentZNode)) {
  List<String> znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw,
    zkw.assignmentZNode);
  if (znodes == null || znodes.isEmpty()) {
   LOG.debug("No RIT in ZK");
  }
  Thread.sleep(100);
 }
}

代码示例来源:origin: alibaba/wasp

/**
 * Blocks until there are no node in entityGroups in transition.
 * <p>
 * Used in testing only.
 * @param zkw zk reference
 * @throws org.apache.zookeeper.KeeperException
 * @throws InterruptedException
 */
public static void blockUntilNoRIT(ZooKeeperWatcher zkw)
  throws KeeperException, InterruptedException {
 while (ZKUtil.nodeHasChildren(zkw, zkw.assignmentZNode)) {
  List<String> znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw,
    zkw.assignmentZNode);
  if (znodes != null && !znodes.isEmpty()) {
   for (String znode : znodes) {
    LOG.debug("ZK RIT -> " + znode);
   }
  }
  Thread.sleep(100);
 }
}

代码示例来源:origin: alibaba/wasp

/**
 * 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.
 *
 * @param zkw
 *          zookeeper reference
 * @param znode
 *          node to get children of and watch
 * @return list of znode names, null if the node doesn't exist
 * @throws org.apache.zookeeper.KeeperException
 */
public static List<String> listChildrenAndWatchThem(ZooKeeperWatcher zkw,
  String znode) throws KeeperException {
 List<String> children = listChildrenAndWatchForNewChildren(zkw, znode);
 if (children == null) {
  return null;
 }
 for (String child : children) {
  watchAndCheckExists(zkw, joinZNode(znode, child));
 }
 return children;
}

代码示例来源:origin: alibaba/wasp

nodes = ZKUtil.listChildrenAndWatchForNewChildren(this.watcher,
  this.watcher.assignmentZNode);
if (!nodes.isEmpty()) {

代码示例来源:origin: alibaba/wasp

@Override
 public void run() {
  try {
   // Just make sure we see the changes for the new znodes
   List<String> children = ZKUtil.listChildrenAndWatchForNewChildren(
     watcher, watcher.assignmentZNode);
   if (children != null) {
    for (String child : children) {
     // if entityGroup is in transition, we already have a watch
     // on it, so no need to watch it again. So, as I know for now,
     // this is needed to watch splitting nodes only.
     if (!entityGroupStates.isEntityGroupInTransition(child)) {
      ZKUtil.watchAndCheckExists(watcher,
        ZKUtil.joinZNode(watcher.assignmentZNode, child));
     }
    }
   }
  } catch (KeeperException e) {
   server.abort("Unexpected ZK exception reading unassigned children",
     e);
  }
 }
});

代码示例来源:origin: alibaba/wasp

ZKUtil.listChildrenAndWatchForNewChildren(this.watcher,
  this.watcher.assignmentZNode);
failoverCleanupDone();

代码示例来源:origin: alibaba/wasp

List<String> znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw,
  zkw.assignmentZNode);
String entityGroupName = znodes.get(0);

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com