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

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

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

ZKUtil.deleteChildrenRecursivelyMultiOrSequential介绍

[英]Delete all the children of the specified node but not the node itself. This will first traverse the znode tree for listing the children and then delete these znodes using multi-update api or sequential based on the specified configurations.

Sets no watches. Throws all exceptions besides dealing with deletion of children.

If the following is true:

  • runSequentialOnMultiFailure is true
    on calling multi, we get a ZooKeeper exception that can be handled by a sequential call(*), we retry the operations one-by-one (sequentially).
    [中]删除指定节点的所有子节点,但不删除节点本身。这将首先遍历znode树以列出子节点,然后根据指定的配置使用多更新api或顺序删除这些znode。
    没有手表。抛出除处理删除子项之外的所有异常。
    如果以下情况属实:
    runSequentialOnMultiFailure是真的
    在调用multi时,我们会得到一个ZooKeeper异常,该异常可以通过顺序调用(
    )来处理,我们会逐个(顺序)重试这些操作。

代码示例

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

/**
 * Delete all the children of the specified node but not the node itself.
 *
 * Sets no watches.  Throws all exceptions besides dealing with deletion of
 * children.
 *
 * @throws KeeperException if a ZooKeeper operation fails
 */
public static void deleteChildrenRecursively(ZKWatcher zkw, String node)
  throws KeeperException {
 deleteChildrenRecursivelyMultiOrSequential(zkw, true, node);
}

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

public void clearChildZNodes() throws KeeperException {
 LOG.debug("Clearing all znodes {}, {}, {}", acquiredZnode, reachedZnode, abortZnode);
 // If the coordinator was shutdown mid-procedure, then we are going to lose
 // an procedure that was previously started by cleaning out all the previous state. Its much
 // harder to figure out how to keep an procedure going and the subject of HBASE-5487.
 ZKUtil.deleteChildrenRecursivelyMultiOrSequential(watcher, true, acquiredZnode, reachedZnode,
  abortZnode);
 if (LOG.isTraceEnabled()) {
  logZKTree(this.baseZNode);
 }
}

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

/**
 * Verifies that for the given root node, it should delete all the child nodes
 * recursively using multi-update api.
 */
@Test
public void testdeleteChildrenRecursivelyMulti() throws Exception {
 String parentZNode = "/testRootMulti";
 createZNodeTree(parentZNode);
 ZKUtil.deleteChildrenRecursivelyMultiOrSequential(zkw, true, parentZNode);
 assertTrue("Wrongly deleted parent znode!",
   ZKUtil.checkExists(zkw, parentZNode) > -1);
 List<String> children = zkw.getRecoverableZooKeeper().getChildren(
   parentZNode, false);
 assertTrue("Failed to delete child znodes!", 0 == children.size());
}

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

@Test
public void testDeleteChildrenRecursivelyMultiOrSequential() throws Exception {
 String parentZNode1 = "/testdeleteChildren1";
 String parentZNode2 = "/testdeleteChildren2";
 String parentZNode3 = "/testdeleteChildren3";
 createZNodeTree(parentZNode1);
 createZNodeTree(parentZNode2);
 createZNodeTree(parentZNode3);
 ZKUtil.deleteChildrenRecursivelyMultiOrSequential(zkw, true, parentZNode1, parentZNode2,
  parentZNode3);
 assertTrue("Wrongly deleted parent znode 1!", ZKUtil.checkExists(zkw, parentZNode1) > -1);
 List<String> children = zkw.getRecoverableZooKeeper().getChildren(parentZNode1, false);
 assertTrue("Failed to delete child znodes of parent znode 1!", 0 == children.size());
 assertTrue("Wrongly deleted parent znode 2!", ZKUtil.checkExists(zkw, parentZNode2) > -1);
 children = zkw.getRecoverableZooKeeper().getChildren(parentZNode2, false);
 assertTrue("Failed to delete child znodes of parent znode 1!", 0 == children.size());
 assertTrue("Wrongly deleted parent znode 3!", ZKUtil.checkExists(zkw, parentZNode3) > -1);
 children = zkw.getRecoverableZooKeeper().getChildren(parentZNode3, false);
 assertTrue("Failed to delete child znodes of parent znode 1!", 0 == children.size());
}

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

/**
 * Delete all the children of the specified node but not the node itself.
 *
 * Sets no watches.  Throws all exceptions besides dealing with deletion of
 * children.
 *
 * @throws KeeperException if a ZooKeeper operation fails
 */
public static void deleteChildrenRecursively(ZKWatcher zkw, String node)
  throws KeeperException {
 deleteChildrenRecursivelyMultiOrSequential(zkw, true, node);
}

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

/**
 * Delete all the children of the specified node but not the node itself.
 *
 * Sets no watches.  Throws all exceptions besides dealing with deletion of
 * children.
 *
 * If hbase.zookeeper.useMulti is true, use ZooKeeper's multi-update functionality.
 * Otherwise, run the list of operations sequentially.
 *
 * @throws KeeperException
 */
public static void deleteChildrenRecursively(ZooKeeperWatcher zkw, String node)
  throws KeeperException {
 deleteChildrenRecursivelyMultiOrSequential(zkw, true, node);
}

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

public void clearChildZNodes() throws KeeperException {
 LOG.info("Clearing all procedure znodes: " + acquiredZnode + " " + reachedZnode + " "
   + abortZnode);
 // If the coordinator was shutdown mid-procedure, then we are going to lose
 // an procedure that was previously started by cleaning out all the previous state. Its much
 // harder to figure out how to keep an procedure going and the subject of HBASE-5487.
 ZKUtil.deleteChildrenRecursivelyMultiOrSequential(watcher, true, acquiredZnode, reachedZnode,
  abortZnode);
 if (LOG.isTraceEnabled()) {
  logZKTree(this.baseZNode);
 }
}

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

/**
 * Verifies that for the given root node, it should delete all the child nodes
 * recursively using multi-update api.
 */
@Test
public void testdeleteChildrenRecursivelyMulti() throws Exception {
 String parentZNode = "/testRootMulti";
 createZNodeTree(parentZNode);
 ZKUtil.deleteChildrenRecursivelyMultiOrSequential(zkw, true, parentZNode);
 assertTrue("Wrongly deleted parent znode!",
   ZKUtil.checkExists(zkw, parentZNode) > -1);
 List<String> children = zkw.getRecoverableZooKeeper().getChildren(
   parentZNode, false);
 assertTrue("Failed to delete child znodes!", 0 == children.size());
}

代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper

/**
 * Verifies that for the given root node, it should delete all the child nodes
 * recursively using multi-update api.
 */
@Test
public void testdeleteChildrenRecursivelyMulti() throws Exception {
 String parentZNode = "/testRootMulti";
 createZNodeTree(parentZNode);
 ZKUtil.deleteChildrenRecursivelyMultiOrSequential(zkw, true, parentZNode);
 assertTrue("Wrongly deleted parent znode!",
   ZKUtil.checkExists(zkw, parentZNode) > -1);
 List<String> children = zkw.getRecoverableZooKeeper().getChildren(
   parentZNode, false);
 assertTrue("Failed to delete child znodes!", 0 == children.size());
}

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

@Test
public void testDeleteChildrenRecursivelyMultiOrSequential() throws Exception {
 String parentZNode1 = "/testdeleteChildren1";
 String parentZNode2 = "/testdeleteChildren2";
 String parentZNode3 = "/testdeleteChildren3";
 createZNodeTree(parentZNode1);
 createZNodeTree(parentZNode2);
 createZNodeTree(parentZNode3);
 ZKUtil.deleteChildrenRecursivelyMultiOrSequential(zkw, true, parentZNode1, parentZNode2,
  parentZNode3);
 assertTrue("Wrongly deleted parent znode 1!", ZKUtil.checkExists(zkw, parentZNode1) > -1);
 List<String> children = zkw.getRecoverableZooKeeper().getChildren(parentZNode1, false);
 assertTrue("Failed to delete child znodes of parent znode 1!", 0 == children.size());
 assertTrue("Wrongly deleted parent znode 2!", ZKUtil.checkExists(zkw, parentZNode2) > -1);
 children = zkw.getRecoverableZooKeeper().getChildren(parentZNode2, false);
 assertTrue("Failed to delete child znodes of parent znode 1!", 0 == children.size());
 assertTrue("Wrongly deleted parent znode 3!", ZKUtil.checkExists(zkw, parentZNode3) > -1);
 children = zkw.getRecoverableZooKeeper().getChildren(parentZNode3, false);
 assertTrue("Failed to delete child znodes of parent znode 1!", 0 == children.size());
}

代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper

@Test
public void testDeleteChildrenRecursivelyMultiOrSequential() throws Exception {
 String parentZNode1 = "/testdeleteChildren1";
 String parentZNode2 = "/testdeleteChildren2";
 String parentZNode3 = "/testdeleteChildren3";
 createZNodeTree(parentZNode1);
 createZNodeTree(parentZNode2);
 createZNodeTree(parentZNode3);
 ZKUtil.deleteChildrenRecursivelyMultiOrSequential(zkw, true, parentZNode1, parentZNode2,
  parentZNode3);
 assertTrue("Wrongly deleted parent znode 1!", ZKUtil.checkExists(zkw, parentZNode1) > -1);
 List<String> children = zkw.getRecoverableZooKeeper().getChildren(parentZNode1, false);
 assertTrue("Failed to delete child znodes of parent znode 1!", 0 == children.size());
 assertTrue("Wrongly deleted parent znode 2!", ZKUtil.checkExists(zkw, parentZNode2) > -1);
 children = zkw.getRecoverableZooKeeper().getChildren(parentZNode2, false);
 assertTrue("Failed to delete child znodes of parent znode 1!", 0 == children.size());
 assertTrue("Wrongly deleted parent znode 3!", ZKUtil.checkExists(zkw, parentZNode3) > -1);
 children = zkw.getRecoverableZooKeeper().getChildren(parentZNode3, false);
 assertTrue("Failed to delete child znodes of parent znode 1!", 0 == children.size());
}

相关文章

微信公众号

最新文章

更多