ZKLogMetadataStore implements LogMetadataStore { @Override public Future<Iterator<String>> getLogs() { final Promise<Iterator<String>> promise = new Promise<Iterator<String>>(); final String nsRootPath = namespace.getPath(); try { final ZooKeeper zk = zkc.get(); zk.sync(nsRootPath, new AsyncCallback.VoidCallback() { @Override public void processResult(int syncRc, String syncPath, Object ctx) { if (KeeperException.Code.OK.intValue() == syncRc) { zk.getChildren(nsRootPath, false, new AsyncCallback.Children2Callback() { @Override public void processResult(int rc, String path, Object ctx, List<String> children, Stat stat) { if (KeeperException.Code.OK.intValue() == rc) { List<String> results = Lists.newArrayListWithExpectedSize(children.size()); for (String child : children) { if (!isReservedStreamName(child)) { results.add(child); } } promise.setValue(results.iterator()); } else if (KeeperException.Code.NONODE.intValue() == rc) { List<String> streams = Lists.newLinkedList(); promise.setValue(streams.iterator()); } else { promise.setException(new ZKException("Error reading namespace " + nsRootPath, KeeperException.Code.get(rc))); } } }, null); } else if (KeeperException.Code.NONODE.intValue() == syncRc) { List<String> streams = Lists.newLinkedList(); promise.setValue(streams.iterator()); } else { promise.setException(new ZKException("Error reading namespace " + nsRootPath, KeeperException.Code.get(syncRc))); } } }, null); zkc.get(); } catch (ZooKeeperClient.ZooKeeperConnectionException e) { promise.setException(e); } catch (InterruptedException e) { promise.setException(e); } return promise; } ZKLogMetadataStore(
            DistributedLogConfiguration conf,
            URI namespace,
            ZooKeeperClient zkc,
            OrderedScheduler scheduler); @Override Future<URI> createLog(String logName); @Override Future<Optional<URI>> getLogLocation(String logName); @Override Future<Iterator<String>> getLogs(); @Override void registerNamespaceListener(NamespaceListener listener);  }
@Test(timeout = 60000) public void testGetLogs() throws Exception { Set<String> logs = Sets.newHashSet(); for (int i = 0; i < 10; i++) { String logName = "test-" + i; logs.add(logName); createLogInNamespace(uri, logName); } Set<String> result = Sets.newHashSet(FutureUtils.result(metadataStore.getLogs())); assertEquals(10, result.size()); assertTrue(Sets.difference(logs, result).isEmpty()); }