@Test public void testGetChildren_EatNoNode() throws Exception { expect(zk.getChildren(eq(ZPATH), anyObject(Watcher.class))) .andThrow(new KeeperException.NoNodeException(ZPATH)); replay(zk); assertNull(zc.getChildren(ZPATH)); verify(zk); }
public List<String> getChildren(final String zPath) { Preconditions.checkState(!closed); ZooRunnable<List<String>> zr = new ZooRunnable<>() { @Override public List<String> run() throws KeeperException, InterruptedException { ImmutableCacheCopies lic = immutableCache; if (lic.childrenCache.containsKey(zPath)) { return lic.childrenCache.get(zPath); } cacheWriteLock.lock(); try { if (childrenCache.containsKey(zPath)) { return childrenCache.get(zPath); } final ZooKeeper zooKeeper = getZooKeeper(); List<String> children = zooKeeper.getChildren(zPath, watcher); if (children != null) { children = List.copyOf(children); } childrenCache.put(zPath, children); immutableCache = new ImmutableCacheCopies(++updateCount, immutableCache, childrenCache); return children; } catch (KeeperException ke) { if (ke.code() != Code.NONODE) { throw ke; } } finally { cacheWriteLock.unlock(); } return null; } }; return zr.retry(); }
ZooCache { public List<String> getChildren(final String zPath) { Preconditions.checkState(!closed); ZooRunnable<List<String>> zr = new ZooRunnable<>() { @Override public List<String> run() throws KeeperException, InterruptedException { ImmutableCacheCopies lic = immutableCache; if (lic.childrenCache.containsKey(zPath)) { return lic.childrenCache.get(zPath); } cacheWriteLock.lock(); try { if (childrenCache.containsKey(zPath)) { return childrenCache.get(zPath); } final ZooKeeper zooKeeper = getZooKeeper(); List<String> children = zooKeeper.getChildren(zPath, watcher); if (children != null) { children = List.copyOf(children); } childrenCache.put(zPath, children); immutableCache = new ImmutableCacheCopies(++updateCount, immutableCache, childrenCache); return children; } catch (KeeperException ke) { if (ke.code() != Code.NONODE) { throw ke; } } finally { cacheWriteLock.unlock(); } return null; } }; return zr.retry(); } }
ZooCache { public List<String> getChildren(final String zPath) { Preconditions.checkState(!closed); ZooRunnable<List<String>> zr = new ZooRunnable<>() { @Override public List<String> run() throws KeeperException, InterruptedException { ImmutableCacheCopies lic = immutableCache; if (lic.childrenCache.containsKey(zPath)) { return lic.childrenCache.get(zPath); } cacheWriteLock.lock(); try { if (childrenCache.containsKey(zPath)) { return childrenCache.get(zPath); } final ZooKeeper zooKeeper = getZooKeeper(); List<String> children = zooKeeper.getChildren(zPath, watcher); if (children != null) { children = List.copyOf(children); } childrenCache.put(zPath, children); immutableCache = new ImmutableCacheCopies(++updateCount, immutableCache, childrenCache); return children; } catch (KeeperException ke) { if (ke.code() != Code.NONODE) { throw ke; } } finally { cacheWriteLock.unlock(); } return null; } }; return zr.retry(); } ZooCache(String zooKeepers, int sessionTimeout);  ZooCache(String zooKeepers, int sessionTimeout, Watcher watcher);  ZooCache(ZooReader reader);  ZooCache(ZooReader reader, Watcher watcher); }
ZooCache { public List<String> getChildren(final String zPath) { Preconditions.checkState(!closed); ZooRunnable<List<String>> zr = new ZooRunnable<>() { @Override public List<String> run() throws KeeperException, InterruptedException { ImmutableCacheCopies lic = immutableCache; if (lic.childrenCache.containsKey(zPath)) { return lic.childrenCache.get(zPath); } cacheWriteLock.lock(); try { if (childrenCache.containsKey(zPath)) { return childrenCache.get(zPath); } final ZooKeeper zooKeeper = getZooKeeper(); List<String> children = zooKeeper.getChildren(zPath, watcher); if (children != null) { children = List.copyOf(children); } childrenCache.put(zPath, children); immutableCache = new ImmutableCacheCopies(++updateCount, immutableCache, childrenCache); return children; } catch (KeeperException ke) { if (ke.code() != Code.NONODE) { throw ke; } } finally { cacheWriteLock.unlock(); } return null; } }; return zr.retry(); } ZooCache(String zooKeepers, int sessionTimeout);  ZooCache(String zooKeepers, int sessionTimeout, Watcher watcher);  ZooCache(ZooReader reader);  ZooCache(ZooReader reader, Watcher watcher); List<String> getChildren(final String zPath); byte[] get(final String zPath); byte[] get(final String zPath, final ZcStat status); void clear(); void close(); long getUpdateCount(); void clear(String zPath); byte[] getLockData(String path); }
ZooCache { public List<String> getChildren(final String zPath) { Preconditions.checkState(!closed); ZooRunnable<List<String>> zr = new ZooRunnable<>() { @Override public List<String> run() throws KeeperException, InterruptedException { ImmutableCacheCopies lic = immutableCache; if (lic.childrenCache.containsKey(zPath)) { return lic.childrenCache.get(zPath); } cacheWriteLock.lock(); try { if (childrenCache.containsKey(zPath)) { return childrenCache.get(zPath); } final ZooKeeper zooKeeper = getZooKeeper(); List<String> children = zooKeeper.getChildren(zPath, watcher); if (children != null) { children = List.copyOf(children); } childrenCache.put(zPath, children); immutableCache = new ImmutableCacheCopies(++updateCount, immutableCache, childrenCache); return children; } catch (KeeperException ke) { if (ke.code() != Code.NONODE) { throw ke; } } finally { cacheWriteLock.unlock(); } return null; } }; return zr.retry(); } ZooCache(String zooKeepers, int sessionTimeout);  ZooCache(String zooKeepers, int sessionTimeout, Watcher watcher);  ZooCache(ZooReader reader);  ZooCache(ZooReader reader, Watcher watcher); List<String> getChildren(final String zPath); byte[] get(final String zPath); byte[] get(final String zPath, final ZcStat status); void clear(); void close(); long getUpdateCount(); void clear(String zPath); byte[] getLockData(String path);  }