ZKClient implements Watcher { public List<String> getChildren(final String path, final boolean watch) throws IOException, KeeperException, InterruptedException { Preconditions.checkArgument(zk != null); final FixedRetryPolicy policy = new FixedRetryPolicy(3); ZKRetryable<List<String>> retry = new ZKRetryable<List<String>>() { public boolean doTry() throws Exception { try { result = zk.getChildren(path, watch); } catch (KeeperException k) { defaultHandleException(k); } return true; } }; ZKRetryHarness harness = new ZKRetryHarness(retry, policy); if (harness.attempt()) { return retry.getResult(); } return Collections.emptyList(); } ZKClient(String hosts); boolean init(); synchronized boolean init(final InitCallback initCallback); synchronized void close(); boolean ensureExists(final String path, final byte[] data); void ensureDeleted(final String path, final int version); synchronized ZooKeeper getZK(); static long extractSuffix(String prefix, String znode); String getLastSequentialChild(final String path, final String prefix,
      final boolean watch); List<String> getChildren(final String path, final boolean watch); byte[] getData(final String path, final boolean watch, final Stat stat); Stat setData(final String path, final byte[] data, final int version); String create(final String path, final byte[] data,
      final List<ACL> acls, final CreateMode mode); void delete(final String path, final int version); Stat exists(final String path, final boolean watch); @Override void process(WatchedEvent event);  }
@Test public void testStandaloneUpAndDown() throws Exception { ZKInProcessServer zk = new ZKInProcessServer(2181, "/tmp/flume-test-zk/"); zk.start(); ZooKeeper client = new ZooKeeper("localhost:2181", 5000, new Watcher() { public void process(WatchedEvent event) { } }); Thread.sleep(1000); List<String> children = client.getChildren("/", false); LOG.warn("Got " + children.size() + " children"); assertTrue(children.size() > 0); zk.stop(); }