use of org.apache.distributedlog.ZooKeeperClient in project bookkeeper by apache.
the class BKNamespaceDriver method enumerateLogsWithMetadataInNamespace.
public Map<String, byte[]> enumerateLogsWithMetadataInNamespace() throws IOException, IllegalArgumentException {
String namespaceRootPath = namespace.getPath();
HashMap<String, byte[]> result = new HashMap<String, byte[]>();
ZooKeeperClient zkc = writerZKC;
try {
ZooKeeper zk = Utils.sync(zkc, namespaceRootPath);
Stat currentStat = zk.exists(namespaceRootPath, false);
if (currentStat == null) {
return result;
}
List<String> children = zk.getChildren(namespaceRootPath, false);
for (String child : children) {
if (isReservedStreamName(child)) {
continue;
}
String zkPath = String.format("%s/%s", namespaceRootPath, child);
currentStat = zk.exists(zkPath, false);
if (currentStat == null) {
result.put(child, new byte[0]);
} else {
result.put(child, zk.getData(zkPath, false, currentStat));
}
}
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
LOG.error("Interrupted while deleting " + namespaceRootPath, ie);
throw new IOException("Interrupted while reading " + namespaceRootPath, ie);
} catch (KeeperException ke) {
LOG.error("Error reading" + namespaceRootPath + "entry in zookeeper", ke);
throw new IOException("Error reading" + namespaceRootPath + "entry in zookeeper", ke);
}
return result;
}
Aggregations