public static int createAndWatch(ZKWatcher zkw, String znode, byte[] data)
    throws KeeperException, KeeperException.NodeExistsException {
    try {
      zkw.getRecoverableZooKeeper().create(znode, data, zkw.createACL(znode),
        CreateMode.PERSISTENT);
      Stat stat = zkw.getRecoverableZooKeeper().exists(znode, zkw);
      if (stat == null) {
        // Likely a race condition. Someone deleted the znode.
        throw KeeperException.create(KeeperException.Code.SYSTEMERROR,
          "ZK.exists returned null (i.e.: znode does not exist) for znode=" + znode);
      }

      return stat.getVersion();
    } catch (InterruptedException e) {
      zkw.interruptedException(e);
      return -1;
    }
  }
Creates the specified node with the specified data and watches it.
<p>
Throws an exception if the node already exists.
<p>
The node created is persistent and open access.
<p>
Returns the version number of the created node if successful.
@param zkw   zk reference
@param znode path of node to create
@param data  data of node to create
@return version of node created
@throws KeeperException                     if unexpected zookeeper exception
@throws KeeperException.NodeExistsException if node already exists
hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java