ZooKeeperExt { public String createExt( final String path, byte[] data, List<ACL> acl, CreateMode createMode, boolean recursive) throws KeeperException, InterruptedException { if (LOG.isDebugEnabled()) { LOG.debug("createExt: Creating path " + path); } int attempt = 0; while (attempt < maxRetryAttempts) { try { if (!recursive) { return zooKeeper.create(path, data, acl, createMode); } try { return zooKeeper.create(path, data, acl, createMode); } catch (KeeperException.NoNodeException e) { if (LOG.isDebugEnabled()) { LOG.debug("createExt: Cannot directly create node " + path); } } int pos = path.indexOf("/", 1); for (; pos != -1; pos = path.indexOf("/", pos + 1)) { try { if (progressable != null) { progressable.progress(); } String filePath = path.substring(0, pos); if (zooKeeper.exists(filePath, false) == null) { zooKeeper.create( filePath, null, acl, CreateMode.PERSISTENT); } } catch (KeeperException.NodeExistsException e) { if (LOG.isDebugEnabled()) { LOG.debug("createExt: Znode " + path.substring(0, pos) + " already exists"); } } } return zooKeeper.create(path, data, acl, createMode); } catch (KeeperException.ConnectionLossException e) { LOG.warn("createExt: Connection loss on attempt " + attempt + ", " + "waiting " + retryWaitMsecs + " msecs before retrying.", e); } ++attempt; Thread.sleep(retryWaitMsecs); } throw new IllegalStateException("createExt: Failed to create " + 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 testCreateExt() throws KeeperException, InterruptedException { if (zooKeeperExt == null) { System.out.println( "testCreateExt: No prop.zookeeper.list set, skipping test"); return; } System.out.println("Created: " + zooKeeperExt.createExt( BASE_PATH + FIRST_PATH, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, true)); zooKeeperExt.deleteExt(BASE_PATH + FIRST_PATH, -1, false); zooKeeperExt.deleteExt(BASE_PATH, -1, false); }