/** * 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); } }
/** * 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); } }
/** * 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; }
nodes = ZKUtil.listChildrenAndWatchForNewChildren(this.watcher, this.watcher.assignmentZNode); if (!nodes.isEmpty()) {
@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); } } });
ZKUtil.listChildrenAndWatchForNewChildren(this.watcher, this.watcher.assignmentZNode); failoverCleanupDone();
List<String> znodes = ZKUtil.listChildrenAndWatchForNewChildren(zkw, zkw.assignmentZNode); String entityGroupName = znodes.get(0);