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

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

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

ZKUtil.deleteChildrenRecursively介绍

[英]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.
[中]删除指定节点的所有子节点,但不删除节点本身。没有手表。抛出除处理删除子项之外的所有异常。

代码示例

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

  1. @Before
  2. public void setup() throws Exception {
  3. TEST_UTIL = new HBaseTestingUtility();
  4. TEST_UTIL.startMiniZKCluster();
  5. conf = TEST_UTIL.getConfiguration();
  6. // Use a different ZK wrapper instance for each tests.
  7. zkw =
  8. new ZKWatcher(conf, "split-log-manager-tests" + TEST_UTIL.getRandomUUID().toString(), null);
  9. master = new DummyMasterServices(zkw, conf);
  10. ZKUtil.deleteChildrenRecursively(zkw, zkw.getZNodePaths().baseZNode);
  11. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().baseZNode);
  12. assertTrue(ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode) != -1);
  13. LOG.debug(zkw.getZNodePaths().baseZNode + " created");
  14. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().splitLogZNode);
  15. assertTrue(ZKUtil.checkExists(zkw, zkw.getZNodePaths().splitLogZNode) != -1);
  16. LOG.debug(zkw.getZNodePaths().splitLogZNode + " created");
  17. resetCounters();
  18. // By default, we let the test manage the error as before, so the server
  19. // does not appear as dead from the master point of view, only from the split log pov.
  20. Mockito.when(sm.isServerOnline(Mockito.any())).thenReturn(true);
  21. to = 12000;
  22. conf.setInt(HConstants.HBASE_SPLITLOG_MANAGER_TIMEOUT, to);
  23. conf.setInt("hbase.splitlog.manager.unassigned.timeout", 2 * to);
  24. conf.setInt("hbase.splitlog.manager.timeoutmonitor.period", 100);
  25. to = to + 16 * 100;
  26. }

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

  1. @Before
  2. public void setup() throws Exception {
  3. TEST_UTIL.startMiniZKCluster();
  4. Configuration conf = TEST_UTIL.getConfiguration();
  5. zkw = new ZKWatcher(TEST_UTIL.getConfiguration(),
  6. "split-log-worker-tests", null);
  7. ds = new DummyServer(zkw, conf);
  8. ZKUtil.deleteChildrenRecursively(zkw, zkw.getZNodePaths().baseZNode);
  9. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().baseZNode);
  10. assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode), not(is(-1)));
  11. LOG.debug(zkw.getZNodePaths().baseZNode + " created");
  12. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().splitLogZNode);
  13. assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().splitLogZNode), not(is(-1)));
  14. LOG.debug(zkw.getZNodePaths().splitLogZNode + " created");
  15. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().rsZNode);
  16. assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().rsZNode), not(is(-1)));
  17. SplitLogCounters.resetCounters();
  18. executorService = new ExecutorService("TestSplitLogWorker");
  19. executorService.startExecutorService(ExecutorType.RS_LOG_REPLAY_OPS, 10);
  20. }

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

  1. @Test
  2. public void testRefreshKeys() throws Exception {
  3. Configuration conf = TEST_UTIL.getConfiguration();
  4. ZKWatcher zk = newZK(conf, "127.0.0.1", new MockAbortable());
  5. AuthenticationTokenSecretManager keyManager =
  6. new AuthenticationTokenSecretManager(conf, zk, "127.0.0.1",
  7. 60 * 60 * 1000, 60 * 1000);
  8. ZKSecretWatcher watcher = new ZKSecretWatcher(conf, zk, keyManager);
  9. ZKUtil.deleteChildrenRecursively(zk, watcher.getKeysParentZNode());
  10. Integer[] keys = { 1, 2, 3, 4, 5, 6 };
  11. for (Integer key : keys) {
  12. AuthenticationKey ak = new AuthenticationKey(key,
  13. System.currentTimeMillis() + 600 * 1000, null);
  14. ZKUtil.createWithParents(zk,
  15. ZNodePaths.joinZNode(watcher.getKeysParentZNode(), key.toString()),
  16. Writables.getBytes(ak));
  17. }
  18. Assert.assertNull(keyManager.getCurrentKey());
  19. watcher.refreshKeys();
  20. for (Integer key : keys) {
  21. Assert.assertNotNull(keyManager.getKey(key.intValue()));
  22. }
  23. }
  24. }

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

  1. public void clearChildZNodes() throws KeeperException {
  2. // TODO This is potentially racy since not atomic. update when we support zk that has multi
  3. LOG.info("Clearing all procedure znodes: " + acquiredZnode + " " + reachedZnode + " "
  4. + abortZnode);
  5. // If the coordinator was shutdown mid-procedure, then we are going to lose
  6. // an procedure that was previously started by cleaning out all the previous state. Its much
  7. // harder to figure out how to keep an procedure going and the subject of HBASE-5487.
  8. ZKUtil.deleteChildrenRecursively(watcher, acquiredZnode);
  9. ZKUtil.deleteChildrenRecursively(watcher, reachedZnode);
  10. ZKUtil.deleteChildrenRecursively(watcher, abortZnode);
  11. }

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

  1. /**
  2. * Deletes all unassigned nodes regardless of their state.
  3. *
  4. * <p>No watchers are set.
  5. *
  6. * <p>This method is used by the Master during cluster startup to clear out
  7. * any existing state from other cluster runs.
  8. *
  9. * @param zkw zk reference
  10. * @throws KeeperException if unexpected zookeeper exception
  11. */
  12. public static void deleteAllNodes(ZooKeeperWatcher zkw)
  13. throws KeeperException {
  14. LOG.debug(zkw.prefix("Deleting any existing unassigned nodes"));
  15. ZKUtil.deleteChildrenRecursively(zkw, zkw.assignmentZNode);
  16. }

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

  1. /**
  2. * Deletes all unassigned nodes regardless of their state.
  3. *
  4. * <p>No watchers are set.
  5. *
  6. * <p>This method is used by the Master during cluster startup to clear out
  7. * any existing state from other cluster runs.
  8. *
  9. * @param zkw zk reference
  10. * @throws KeeperException if unexpected zookeeper exception
  11. */
  12. public static void deleteAllNodes(ZooKeeperWatcher zkw)
  13. throws KeeperException {
  14. LOG.debug(zkw.prefix("Deleting any existing unassigned nodes"));
  15. ZKUtil.deleteChildrenRecursively(zkw, zkw.assignmentZNode);
  16. }

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

  1. public static void deleteRecoveringRegionZNodes(ZooKeeperWatcher watcher, List<String> regions) {
  2. try {
  3. if (regions == null) {
  4. // remove all children under /home/recovering-regions
  5. LOG.debug("Garbage collecting all recovering region znodes");
  6. ZKUtil.deleteChildrenRecursively(watcher, watcher.recoveringRegionsZNode);
  7. } else {
  8. for (String curRegion : regions) {
  9. String nodePath = ZKUtil.joinZNode(watcher.recoveringRegionsZNode, curRegion);
  10. ZKUtil.deleteNodeRecursively(watcher, nodePath);
  11. }
  12. }
  13. } catch (KeeperException e) {
  14. LOG.warn("Cannot remove recovering regions from ZooKeeper", e);
  15. }
  16. }

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

  1. @Before
  2. public void setup() throws Exception {
  3. TEST_UTIL = new HBaseTestingUtility();
  4. TEST_UTIL.startMiniZKCluster();
  5. conf = TEST_UTIL.getConfiguration();
  6. // Use a different ZK wrapper instance for each tests.
  7. zkw =
  8. new ZKWatcher(conf, "split-log-manager-tests" + TEST_UTIL.getRandomUUID().toString(), null);
  9. master = new DummyMasterServices(zkw, conf);
  10. ZKUtil.deleteChildrenRecursively(zkw, zkw.getZNodePaths().baseZNode);
  11. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().baseZNode);
  12. assertTrue(ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode) != -1);
  13. LOG.debug(zkw.getZNodePaths().baseZNode + " created");
  14. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().splitLogZNode);
  15. assertTrue(ZKUtil.checkExists(zkw, zkw.getZNodePaths().splitLogZNode) != -1);
  16. LOG.debug(zkw.getZNodePaths().splitLogZNode + " created");
  17. resetCounters();
  18. // By default, we let the test manage the error as before, so the server
  19. // does not appear as dead from the master point of view, only from the split log pov.
  20. Mockito.when(sm.isServerOnline(Mockito.any())).thenReturn(true);
  21. to = 12000;
  22. conf.setInt(HConstants.HBASE_SPLITLOG_MANAGER_TIMEOUT, to);
  23. conf.setInt("hbase.splitlog.manager.unassigned.timeout", 2 * to);
  24. conf.setInt("hbase.splitlog.manager.timeoutmonitor.period", 100);
  25. to = to + 16 * 100;
  26. }

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

  1. @Before
  2. public void setup() throws Exception {
  3. TEST_UTIL.startMiniZKCluster();
  4. Configuration conf = TEST_UTIL.getConfiguration();
  5. zkw = new ZKWatcher(TEST_UTIL.getConfiguration(),
  6. "split-log-worker-tests", null);
  7. ds = new DummyServer(zkw, conf);
  8. ZKUtil.deleteChildrenRecursively(zkw, zkw.getZNodePaths().baseZNode);
  9. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().baseZNode);
  10. assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().baseZNode), not(is(-1)));
  11. LOG.debug(zkw.getZNodePaths().baseZNode + " created");
  12. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().splitLogZNode);
  13. assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().splitLogZNode), not(is(-1)));
  14. LOG.debug(zkw.getZNodePaths().splitLogZNode + " created");
  15. ZKUtil.createAndFailSilent(zkw, zkw.getZNodePaths().rsZNode);
  16. assertThat(ZKUtil.checkExists(zkw, zkw.getZNodePaths().rsZNode), not(is(-1)));
  17. SplitLogCounters.resetCounters();
  18. executorService = new ExecutorService("TestSplitLogWorker");
  19. executorService.startExecutorService(ExecutorType.RS_LOG_REPLAY_OPS, 10);
  20. }

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

  1. @Test
  2. public void testRefreshKeys() throws Exception {
  3. Configuration conf = TEST_UTIL.getConfiguration();
  4. ZKWatcher zk = newZK(conf, "127.0.0.1", new MockAbortable());
  5. AuthenticationTokenSecretManager keyManager =
  6. new AuthenticationTokenSecretManager(conf, zk, "127.0.0.1",
  7. 60 * 60 * 1000, 60 * 1000);
  8. ZKSecretWatcher watcher = new ZKSecretWatcher(conf, zk, keyManager);
  9. ZKUtil.deleteChildrenRecursively(zk, watcher.getKeysParentZNode());
  10. Integer[] keys = { 1, 2, 3, 4, 5, 6 };
  11. for (Integer key : keys) {
  12. AuthenticationKey ak = new AuthenticationKey(key,
  13. System.currentTimeMillis() + 600 * 1000, null);
  14. ZKUtil.createWithParents(zk,
  15. ZNodePaths.joinZNode(watcher.getKeysParentZNode(), key.toString()),
  16. Writables.getBytes(ak));
  17. }
  18. Assert.assertNull(keyManager.getCurrentKey());
  19. watcher.refreshKeys();
  20. for (Integer key : keys) {
  21. Assert.assertNotNull(keyManager.getKey(key.intValue()));
  22. }
  23. }
  24. }

相关文章