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 Pathable<T> usingWatcher(Watcher watcher) { return new PathableDecorator<>(inner.usingWatcher(wrap(watcher))); }
@Override public Pathable<T> usingWatcher(CuratorWatcher watcher) { return new PathableDecorator<>(inner.usingWatcher(wrap(watcher))); } }
private void readValue() throws Exception { Stat localStat = new Stat(); byte[] bytes = client.getData().storingStatIn(localStat).usingWatcher(watcher).forPath(path); updateValue(localStat.getVersion(), bytes); }
void getDataAndStat(final String fullPath) throws Exception { Stat stat = new Stat(); byte[] data = client.getData().storingStatIn(stat).usingWatcher(dataWatcher).forPath(fullPath); applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, data); }
void getDataAndStat(final String fullPath) throws Exception { Stat stat = new Stat(); byte[] data = client.getData().storingStatIn(stat).usingWatcher(dataWatcher).forPath(fullPath); applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, data); }
void getDataAndStat(final String fullPath) throws Exception { try { Stat stat = new Stat(); byte[] data = client.getData().storingStatIn(stat).usingWatcher(dataWatcher).forPath(fullPath); applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, data); } catch (KeeperException.NoNodeException ignore) { } }
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); }
void getDataAndStat(final String fullPath) throws Exception { if (client.checkExists().forPath(fullPath) == null) { return; } final List<String> children = client.getChildren().usingWatcher(watcher).forPath(fullPath); if ( cacheData ) { Stat stat = new Stat(); byte[] data = null; if ( dataIsCompressed ) { data = client.getData().decompressed().storingStatIn(stat).usingWatcher(watcher).forPath(fullPath); } else { data = client.getData().storingStatIn(stat).usingWatcher(watcher).forPath(fullPath); } applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, data, children); } else { Stat stat = client.checkExists().usingWatcher(watcher).forPath(fullPath); applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, null, children); } }
void getDataAndStat(final String fullPath) throws Exception { if (client.checkExists().forPath(fullPath) == null) { return; } final List<String> children = client.getChildren().usingWatcher(watcher).forPath(fullPath); if ( cacheData ) { Stat stat = new Stat(); byte[] data = null; if ( dataIsCompressed ) { data = client.getData().decompressed().storingStatIn(stat).usingWatcher(watcher).forPath(fullPath); } else { data = client.getData().storingStatIn(stat).usingWatcher(watcher).forPath(fullPath); } applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, data, children); } else { Stat stat = client.checkExists().usingWatcher(watcher).forPath(fullPath); applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, null, 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; } }