private List<String> getChildren() throws Exception { final Stat childrenStat = new Stat(); while (true) { final List<String> possibleChildren = curator.getChildren() .storingStatIn(childrenStat) .usingWatcher(childrenWatcher) .forPath(path); if (clusterId == null) { // Do not do any checks if the clusterId is not specified on the command line. return possibleChildren; } try { curator.inTransaction() .check().forPath(Paths.configId(clusterId)).and() .check().withVersion(childrenStat.getVersion()).forPath(path).and() .commit(); } catch (KeeperException.BadVersionException e) { // Jobs have somehow changed while we were creating the transaction, retry. continue; } return possibleChildren; } }
@Override public WatchPathable<List<String>> storingStatIn(Stat stat) { return new WatchPathableDecorator<>(inner.storingStatIn(stat)); }
void refresh(final String path, final RefreshMode mode) throws Exception { ensurePath.ensure(client.getZookeeperClient()); Stat stat = new Stat(); try { List<String> children = client.getChildren().storingStatIn(stat).usingWatcher(watcher).forPath(path); processChildren(path, children, mode); updateIfNeeded(path, stat, children); } catch (KeeperException.NoNodeException e) { // node no longer exists - ignore log.debug("Node {} is no longer available.", path); } }
void refresh(final String path, final RefreshMode mode) throws Exception { ensurePath.ensure(client.getZookeeperClient()); Stat stat = new Stat(); List<String> children = client.getChildren().storingStatIn(stat).usingWatcher(watcher).forPath(path); processChildren(path, children, mode); updateIfNeeded(path, stat, children); }
private List<String> getChildren() throws Exception { Stat childrenStat = new Stat(); while (true) { final List<String> possibleChildren = curator.getChildren() .storingStatIn(childrenStat) .usingWatcher(childrenWatcher) .forPath(path); if (clusterId == null) { // Do not do any checks if the clusterId is not specified on the command line. return possibleChildren; } try { curator.inTransaction() .check().forPath(Paths.configId(clusterId)).and() .check().withVersion(childrenStat.getVersion()).forPath(path).and() .commit(); } catch (KeeperException.BadVersionException e) { // Jobs have somehow changed while we were creating the transaction, retry. continue; } return possibleChildren; } }