Utils { public static Future<Versioned<byte[]>> zkGetData(ZooKeeperClient zkc, String path, boolean watch) { ZooKeeper zk; try { zk = zkc.get(); } catch (ZooKeeperClient.ZooKeeperConnectionException e) { return Future.exception(FutureUtils.zkException(e, path)); } catch (InterruptedException e) { return Future.exception(FutureUtils.zkException(e, path)); } return zkGetData(zk, path, watch); }  static long nowInNanos(); static long nowInMillis(); static long elapsedMSec(long startMsecTime); static boolean randomPercent(double percent); static void zkCreateFullPathOptimistic(
        ZooKeeperClient zkc,
        String path,
        byte[] data,
        final List<ACL> acl,
        final CreateMode createMode); static void zkAsyncCreateFullPathOptimisticRecursive(
        final ZooKeeperClient zkc,
        final String pathToCreate,
        final Optional<String> parentPathShouldNotCreate,
        final byte[] data,
        final List<ACL> acl,
        final CreateMode createMode,
        final AsyncCallback.StringCallback callback,
        final Object ctx); static Future<BoxedUnit> zkAsyncCreateFullPathOptimistic(
        final ZooKeeperClient zkc,
        final String pathToCreate,
        final byte[] data,
        final List<ACL> acl,
        final CreateMode createMode); static Future<BoxedUnit> zkAsyncCreateFullPathOptimistic(
        final ZooKeeperClient zkc,
        final String pathToCreate,
        final Optional<String> parentPathShouldNotCreate,
        final byte[] data,
        final List<ACL> acl,
        final CreateMode createMode); static Future<BoxedUnit> zkAsyncCreateFullPathOptimisticAndSetData(
        final ZooKeeperClient zkc,
        final String pathToCreate,
        final byte[] data,
        final List<ACL> acl,
        final CreateMode createMode); static Future<Versioned<byte[]>> zkGetData(ZooKeeperClient zkc, String path, boolean watch); static Future<Versioned<byte[]>> zkGetData(ZooKeeper zk, String path, boolean watch); static Future<ZkVersion> zkSetData(ZooKeeperClient zkc, String path, byte[] data, ZkVersion version); static Future<ZkVersion> zkSetData(ZooKeeper zk, String path, byte[] data, ZkVersion version); static Future<Void> zkDelete(ZooKeeperClient zkc, String path, ZkVersion version); static Future<Void> zkDelete(ZooKeeper zk, String path, ZkVersion version); static Future<Void> asyncClose(@Nullable AsyncCloseable closeable,
                                          boolean swallowIOException); static ZooKeeper sync(ZooKeeperClient zkc, String path); static void close(@Nullable Closeable closeable); static void close(@Nullable AsyncCloseable closeable); static void closeQuietly(@Nullable AsyncCloseable closeable); static Future<Void> closeSequence(ExecutorService executorService,
                                             AsyncCloseable... closeables); static Future<Void> closeSequence(ExecutorService executorService,
                                             boolean ignoreCloseError,
                                             AsyncCloseable... closeables);  }
@Test(timeout = 60000) public void testZkGetData() throws Exception { String path1 = "/zk-get-data/non-existent-path"; Versioned<byte[]> data = FutureUtils.result(Utils.zkGetData(zkc.get(), path1, false)); assertNull("No data should return from non-existent-path", data.getValue()); assertNull("No version should return from non-existent-path", data.getVersion()); String path2 = "/zk-get-data/path2"; byte[] rawData = "test-data".getBytes(UTF_8); FutureUtils.result(Utils.zkAsyncCreateFullPathOptimistic(zkc, path2, rawData, zkc.getDefaultACL(), CreateMode.PERSISTENT)); data = FutureUtils.result(Utils.zkGetData(zkc.get(), path2, false)); assertArrayEquals("Data should return as written", rawData, data.getValue()); assertEquals("Version should be zero", 0, ((ZkVersion) data.getVersion()).getZnodeVersion()); }