/** * Gets the current data in the unassigned node for the specified entityGroup * name or fully-qualified path. * * <p> * Returns null if the entityGroup does not currently have a node. * * <p> * Sets a watch on the node if the node exists. * * @param zkw zk reference * @param pathOrEntityGroupName fully-specified path or entityGroup name * @return znode content * @throws org.apache.zookeeper.KeeperException if unexpected zookeeper exception */ public static byte[] getData(ZooKeeperWatcher zkw, String pathOrEntityGroupName) throws KeeperException { String node = getPath(zkw, pathOrEntityGroupName); return ZKUtil.getDataAndWatch(zkw, node); }
/** * Gets the data of the node. * * <p> * If the node is currently available, the most up-to-date known version of * the data is returned. If the node is not currently available, null is * returned. * @param refresh whether to refresh the data by calling ZK directly. * @return data of the node, null if unavailable */ public synchronized byte[] getData(boolean refresh) { if (refresh) { try { this.data = ZKUtil.getDataAndWatch(watcher, node); } catch (KeeperException e) { abortable.abort("Unexpected exception handling getData", e); } } return this.data; }
/** * Gets the current data in the unassigned node for the specified entityGroup * name or fully-qualified path. * * <p> * Returns null if the entityGroup does not currently have a node. * * <p> * Sets a watch on the node if the node exists. * * @param zkw zk reference * @param pathOrEntityGroupName fully-specified path or entityGroup name * @param stat object to populate the version. * @return znode content * @throws org.apache.zookeeper.KeeperException if unexpected zookeeper exception */ public static byte[] getDataAndWatch(ZooKeeperWatcher zkw, String pathOrEntityGroupName, Stat stat) throws KeeperException { String node = getPath(zkw, pathOrEntityGroupName); return ZKUtil.getDataAndWatch(zkw, node, stat); }
@Override public synchronized void nodeCreated(String path) { if (!path.equals(node)) return; try { byte[] data = ZKUtil.getDataAndWatch(watcher, node); if (data != null) { this.data = data; notifyAll(); } else { nodeDeleted(path); } } catch (KeeperException e) { abortable.abort("Unexpected exception handling nodeCreated event", e); } }
try { this.data = ZKUtil.getDataAndWatch(watcher, node); } catch (KeeperException e) { try { this.data = ZKUtil.getDataAndWatch(watcher, node); } catch (KeeperException e) { LOG.warn("Unexpected exception handling blockUntilAvailable", e);
try { if (ZKUtil.watchAndCheckExists(watcher, node)) { byte[] data = ZKUtil.getDataAndWatch(watcher, node); if (data != null) { this.data = data;
byte[] bytes = ZKUtil.getDataAndWatch(this.watcher, this.watcher.getMasterAddressZNode()); if (bytes == null) {
existingBytes = ZKUtil.getDataAndWatch(zkw, node); } catch (KeeperException.NoNodeException nne) { return false;
String nodeName = ZKAssign.getNodeName(zkw, entityGroup .getEntityGroupInfo().getEncodedName()); ZKUtil.getDataAndWatch(zkw, nodeName, stat);