ZooKeeperExt { public void deleteExt(final String path, int version, boolean recursive) throws InterruptedException, KeeperException { int attempt = 0; while (attempt < maxRetryAttempts) { try { if (!recursive) { zooKeeper.delete(path, version); return; } try { zooKeeper.delete(path, version); return; } catch (KeeperException.NotEmptyException e) { if (LOG.isDebugEnabled()) { LOG.debug("deleteExt: Cannot directly remove node " + path); } } List<String> childList = zooKeeper.getChildren(path, false); for (String child : childList) { if (progressable != null) { progressable.progress(); } deleteExt(path + "/" + child, -1, true); } zooKeeper.delete(path, version); return; } catch (KeeperException.ConnectionLossException e) { LOG.warn("deleteExt: Connection loss on attempt " + attempt + ", waiting " + retryWaitMsecs + " msecs before retrying.", e); } ++attempt; Thread.sleep(retryWaitMsecs); } throw new IllegalStateException("deleteExt: Failed to delete " + path + " after " + attempt + " tries!"); } ZooKeeperExt(String connectString,
                      int sessionTimeout,
                      int maxRetryAttempts,
                      int retryWaitMsecs,
                      Watcher watcher);  ZooKeeperExt(String connectString,
      int sessionTimeout,
      int maxRetryAttempts,
      int retryWaitMsecs,
      Watcher watcher,
      Progressable progressable); String createExt(
      final String path,
      byte[] data,
      List<ACL> acl,
      CreateMode createMode,
      boolean recursive); PathStat createOrSetExt(final String path,
      byte[] data,
      List<ACL> acl,
      CreateMode createMode,
      boolean recursive,
      int version); PathStat createOnceExt(final String path,
      byte[] data,
      List<ACL> acl,
      CreateMode createMode,
      boolean recursive); void deleteExt(final String path, int version, boolean recursive); Stat exists(String path, boolean watch); Stat exists(final String path, Watcher watcher); byte[] getData(final String path, Watcher watcher, Stat stat); byte[] getData(String path, boolean watch, Stat stat); List<String> getChildrenExt(
      final String path,
      boolean watch,
      boolean sequenceSorted,
      boolean fullPath); void close(); static final int SEQUENCE_NUMBER_LENGTH; }
@Test public void testDeleteExt() throws KeeperException, InterruptedException { if (zooKeeperExt == null) { System.out.println( "testDeleteExt: No prop.zookeeper.list set, skipping test"); return; } zooKeeperExt.createExt(BASE_PATH, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, false); zooKeeperExt.createExt(BASE_PATH + FIRST_PATH, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, false); try { zooKeeperExt.deleteExt(BASE_PATH, -1, false); } catch (KeeperException.NotEmptyException e) { System.out.println( "Correctly failed to delete since not recursive"); } zooKeeperExt.deleteExt(BASE_PATH, -1, true); }