List of usage examples for org.apache.zookeeper.server DataTree getData
public byte[] getData(String path, Stat stat, Watcher watcher) throws KeeperException.NoNodeException
From source file:com.linkedin.helix.tools.ZKLogFormatter.java
License:Apache License
private static void traverse(DataTree dt, int startId, String startPath) throws Exception { LinkedList<Pair> queue = new LinkedList<Pair>(); queue.add(new Pair(startPath, startId)); while (!queue.isEmpty()) { Pair pair = queue.removeFirst(); String path = pair._path; DataNode head = dt.getNode(path); Stat stat = new Stat(); byte[] data = null; try {/*w ww. j a va2 s.c o m*/ data = dt.getData(path, stat, null); } catch (NoNodeException e) { e.printStackTrace(); } // print the node format(startId, pair, head, data); Set<String> children = head.getChildren(); if (children != null) { for (String child : children) { String childPath; if (path.endsWith("/")) { childPath = path + child; } else { childPath = path + "/" + child; } queue.add(new Pair(childPath, startId)); } } startId = startId + 1; } }