private void getChildren() throws Exception { BackgroundCallback callback = new BackgroundCallback() { @Override public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { if (event.getResultCode() == KeeperException.Code.OK.intValue()) { checkLeadership(event.getChildren()); } } }; client.getChildren().inBackground(callback).forPath(latchPath); }
public static List<String> getSortedChildren( CuratorFramework client, String basePath, final String lockName, final LockInternalsSorter sorter) throws Exception { List<String> children = client.getChildren().forPath(basePath); List<String> sortedList = Lists.newArrayList(children); Collections.sort( sortedList, new Comparator<String>() { @Override public int compare(String lhs, String rhs) { return sorter .fixForSorting(lhs, lockName) .compareTo(sorter.fixForSorting(rhs, lockName)); } }); return sortedList; }
private List<String> registerPathNodeDataChangeWatcher(final String path) throws Exception { return zkClient_.getChildren().usingWatcher(createChildNodeChangeWatcher()).forPath(path); }