public static void createEphemeralPathExpectConflict(final ZkClient client, final String path, final String data)
            throws Exception {
        try {
            createEphemeralPath(client, path, data);
        }
        catch (final ZkNodeExistsException e) {

            // this canZkConfig happen when there is connection loss; make sure
            // the data
            // is what we intend to write
            String storedData = null;
            try {
                storedData = readData(client, path);
            }
            catch (final ZkNoNodeException e1) {
                // the node disappeared; treat as if node existed and let caller
                // handles this
            }
            catch (final Exception e2) {
                throw e2;
            }
            if (storedData == null || !storedData.equals(data)) {
                throw e;
            }
            else {
                // otherwise, the creation succeeded, return normally
                logger.info(path + " exists with value " + data + " during connection loss; this is ok");
            }
        }
        catch (final Exception e) {
            throw e;
        }

    }
Create an ephemeral node with the given path and data. Throw
NodeExistException if node already exists.
metamorphosis-commons/src/main/java/com/taobao/metamorphosis/utils/ZkUtils.java