/** * Register callback notifications when child node added/deleted for a znode * * @param path */ @SuppressWarnings("restriction") public void registerChildrenCallback(String path) { try { transport.getZKHandle().getChildren().usingWatcher(watcher).inBackground((BackgroundCallback)watcher).forPath(path); } catch (Exception e) { LOGGER.error( "Exception while registering childrencallback for " + path, e); } }
/** * Set watch on each child node to receive notifications on node data * change/creation/deletion notifications * * @param path */ @SuppressWarnings("restriction") public void getChildrenAndSetWatch(String path) { List<String> children = null; try { children = transport.getZKHandle().getChildren().usingWatcher(watcher) .forPath(path); for (String child : children) { String childnodePath = (new StringBuilder()).append(path) .append("/").append(child).toString(); transport.getZKHandle().checkExists().usingWatcher(watcher) .forPath(childnodePath); getChildrenAndSetWatch(childnodePath); } }catch(NoNodeException nee){ LOGGER.warn( " NoNodeException While setting children watch for " + path + nee.getMessage()); } catch (Exception e) { LOGGER.error( " Exception While setting watch on " + path, e); } }
void refresh(final RefreshMode mode) throws Exception { ensurePath.ensure(client.getZookeeperClient()); final BackgroundCallback callback = new BackgroundCallback() { @Override public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { processChildren(event.getChildren(), mode); } }; client.getChildren().usingWatcher(childrenWatcher).inBackground(callback).forPath(path); }
private synchronized void sync(boolean watched) throws Exception { if ( watched ) { client.getChildren().usingWatcher(watcher).inBackground(callback).forPath(path); } else { client.getChildren().inBackground(callback).forPath(path); } }
List<String> children = null; try { children = getZKHandle().getChildren().usingWatcher(this) .forPath(path);
List<String> children = client.getChildren().usingWatcher(watcher).forPath(leasesPath); if ( !children.contains(nodeName) )
try nodes = (watcher != null) ? client.getChildren().usingWatcher(watcher).forPath(path) : client.getChildren().forPath(path);