private String findTop(String txpath) throws KeeperException, InterruptedException { List<String> ops = zk.getChildren(txpath); ops = new ArrayList<>(ops); String max = ""; for (String child : ops) if (child.startsWith("repo_") && child.compareTo(max) > 0) max = child; if (max.equals("")) return null; return max; }
@Override public List<Long> list() { try { ArrayList<Long> l = new ArrayList<>(); List<String> transactions = zk.getChildren(path); for (String txid : transactions) { l.add(parseTid(txid)); } return l; } catch (Exception e) { throw new RuntimeException(e); } }
public static void deleteLock(IZooReaderWriter zk, String path) throws InterruptedException, KeeperException { List<String> children; children = zk.getChildren(path); if (children == null || children.size() == 0) { throw new IllegalStateException("No lock is held at " + path); } Collections.sort(children); String lockNode = children.get(0); if (!lockNode.startsWith(LOCK_PREFIX)) { throw new RuntimeException("Node " + lockNode + " at " + path + " is not a lock node"); } zk.recursiveDelete(path + "/" + lockNode, NodeMissingPolicy.SKIP); }
public void deleteLocks(IZooReaderWriter zk, String path, String txidStr) throws KeeperException, InterruptedException { // delete any locks assoc w/ fate operation List<String> lockedIds = zk.getChildren(path); for (String id : lockedIds) { List<String> lockNodes = zk.getChildren(path + "/" + id); for (String node : lockNodes) { String lockPath = path + "/" + id + "/" + node; byte[] data = zk.getData(path + "/" + id + "/" + node, null); String lda[] = new String(data, UTF_8).split(":"); if (lda[1].equals(txidStr)) zk.recursiveDelete(lockPath, NodeMissingPolicy.SKIP); } } }
private Iterator<String> getIter1() { if (iter1 == null) { try { List<String> children; if (table == null || isMeta(table)) { children = zoo.getChildren(context.getZooKeeperRoot() + Constants.ZPROBLEMS); } else { children = Collections.emptyList(); } iter1 = children.iterator(); } catch (Exception e) { throw new RuntimeException(e); } } return iter1; }
private static void writeHumanReadable(PrintStream out, String root) throws KeeperException, InterruptedException { write(out, 0, "%s:", root); for (String child : zk.getChildren(root, null)) if (!child.equals("zookeeper")) childHumanReadable(out, root, child, 1); }
public static boolean deleteLock(IZooReaderWriter zk, String path, String lockData) throws InterruptedException, KeeperException { List<String> children; children = zk.getChildren(path); if (children == null || children.size() == 0) { throw new IllegalStateException("No lock is held at " + path); } Collections.sort(children); String lockNode = children.get(0); if (!lockNode.startsWith(LOCK_PREFIX)) { throw new RuntimeException("Node " + lockNode + " at " + path + " is not a lock node"); } byte[] data = zk.getData(path + "/" + lockNode, null); if (lockData.equals(new String(data, UTF_8))) { zk.recursiveDelete(path + "/" + lockNode, NodeMissingPolicy.FAIL); return true; } return false; } }
@Override public SortedMap<Long,byte[]> getEarlierEntries(long entry) { SortedMap<Long,byte[]> result = new TreeMap<>(); try { List<String> children = Collections.emptyList(); try { children = zoo.getChildren(path); } catch (KeeperException.NoNodeException ex) { // the path does not exist (it was deleted or not created yet), that is ok there are no // earlier entries then } for (String name : children) { // this try catch must be done inside the loop because some subset of the children may exist try { byte[] data = zoo.getData(path + "/" + name, null); long order = Long.parseLong(name.substring(PREFIX.length())); if (order <= entry) result.put(order, data); } catch (KeeperException.NoNodeException ex) { // ignored } } } catch (Exception ex) { throw new RuntimeException(ex); } return result; }
private static void zapDirectory(IZooReaderWriter zoo, String path, Opts opts) throws KeeperException, InterruptedException { List<String> children = zoo.getChildren(path); for (String child : children) { message("Deleting " + path + "/" + child + " from zookeeper", opts); zoo.recursiveDelete(path + "/" + child, NodeMissingPolicy.SKIP); } } }
private static void writeXml(PrintStream out, String root) throws KeeperException, InterruptedException { write(out, 0, "<dump root='%s'>", root); for (String child : zk.getChildren(root, null)) if (!child.equals("zookeeper")) childXml(out, root, child, 1); write(out, 0, "</dump>"); }
List<String> ops; try { ops = zk.getChildren(txpath); } catch (KeeperException.NoNodeException e) { return Collections.emptyList();
List<String> children = zooKeeper.getChildren(path);
List<String> txdirs = new ArrayList<>(zk.getChildren(path)); Collections.sort(txdirs);
static void getRootLogEntries(ServerContext context, final ArrayList<LogEntry> result) throws KeeperException, InterruptedException, IOException { IZooReaderWriter zoo = context.getZooReaderWriter(); String root = getZookeeperLogLocation(context); // there's a little race between getting the children and fetching // the data. The log can be removed in between. while (true) { result.clear(); for (String child : zoo.getChildren(root)) { try { LogEntry e = LogEntry.fromBytes(zoo.getData(root + "/" + child, null)); // upgrade from !0;!0<< -> +r<< e = new LogEntry(RootTable.EXTENT, 0, e.server, e.filename); result.add(e); } catch (KeeperException.NoNodeException ex) { continue; } } break; } }
for (String child : zk.getChildren(root)) { if (Constants.ZINSTANCES.equals("/" + child)) { for (String instanceName : zk.getChildren(root + Constants.ZINSTANCES)) { String instanceNamePath = root + Constants.ZINSTANCES + "/" + instanceName; byte[] id = zk.getData(instanceNamePath, null);
private static void childHumanReadable(PrintStream out, String root, String child, int indent) throws KeeperException, InterruptedException { String path = root + "/" + child; if (root.endsWith("/")) path = root + child; Stat stat = zk.getStatus(path); if (stat == null) return; String node = child; if (stat.getEphemeralOwner() != 0) { node = "*" + child + "*"; } if (stat.getDataLength() == 0) { write(out, indent, "%s:", node); } else { write(out, indent, "%s: %s", node, value(path).value); } if (stat.getNumChildren() > 0) { for (String c : zk.getChildren(path, null)) { childHumanReadable(out, path, c, indent + 1); } } } }
zoo.putPersistentData(zooRoot + Constants.ZRECOVERY, zero, NodeExistsPolicy.SKIP); for (String id : zoo.getChildren(zooRoot + Constants.ZTABLES)) { log.debug("Prepping table {} for compaction cancellations.", id); zoo.putPersistentData( for (String id : zoo.getChildren(zooRoot + Constants.ZTABLES)) { log.debug("Converting table {} WALog setting to Durability", id); try { for (String tableId : zoo.getChildren(tables)) { Namespace.ID targetNamespace = (MetadataTable.ID.canonicalID().equals(tableId) || RootTable.ID.canonicalID().equals(tableId)) ? Namespace.ID.ACCUMULO perm.initialize(getContext(), true); String users = getZooKeeperRoot() + "/users"; for (String user : zoo.getChildren(users)) { zoo.putPersistentData(users + "/" + user + "/Namespaces", new byte[0], NodeExistsPolicy.SKIP);
value.value); for (String c : zk.getChildren(path, null)) { childXml(out, path, c, indent + 1);
private static void zapDirectory(IZooReaderWriter zoo, String path, Opts opts) { try { List<String> children = zoo.getChildren(path); for (String child : children) { message("Deleting " + path + "/" + child + " from zookeeper", opts); zoo.recursiveDelete(path + "/" + child, NodeMissingPolicy.SKIP); } } catch (Exception e) { e.printStackTrace(); } } }
private static void zapDirectory(IZooReaderWriter zoo, String path, Opts opts) throws KeeperException, InterruptedException { List<String> children = zoo.getChildren(path); for (String child : children) { message("Deleting " + path + "/" + child + " from zookeeper", opts); zoo.recursiveDelete(path + "/" + child, NodeMissingPolicy.SKIP); } } }