public static boolean isLockHeld(ZooCache zc, LockID lid) { List<String> children = zc.getChildren(lid.path); if (children == null || children.size() == 0) { return false; } children = new ArrayList<>(children); Collections.sort(children); String lockNode = children.get(0); if (!lid.node.equals(lockNode)) return false; ZcStat stat = new ZcStat(); return zc.get(lid.path + "/" + lid.node, stat) != null && stat.getEphemeralOwner() == lid.eid; }
try { data = zooKeeper.getData(zPath, watcher, stat); zstat = new ZcStat(stat); } catch (KeeperException.BadVersionException | KeeperException.NoNodeException e1) { throw new ConcurrentModificationException();
public static long getSessionId(ZooCache zc, String path) { List<String> children = zc.getChildren(path); if (children == null || children.size() == 0) { return 0; } children = new ArrayList<>(children); Collections.sort(children); String lockNode = children.get(0); ZcStat stat = new ZcStat(); if (zc.get(path + "/" + lockNode, stat) != null) return stat.getEphemeralOwner(); return 0; }
try { data = zooKeeper.getData(zPath, watcher, stat); zstat = new ZcStat(stat); } catch (KeeperException.BadVersionException e1) { throw new ConcurrentModificationException();
ZcStat stat = new ZcStat(); byte[] lockData = ZooLock.getLockData(getZooCache(), lockPath, stat);
public static long getSessionId(ZooCache zc, String path) throws KeeperException, InterruptedException { List<String> children = zc.getChildren(path); if (children == null || children.size() == 0) { return 0; } children = new ArrayList<>(children); Collections.sort(children); String lockNode = children.get(0); ZcStat stat = new ZcStat(); if (zc.get(path + "/" + lockNode, stat) != null) return stat.getEphemeralOwner(); return 0; }
public static boolean isLockHeld(ZooCache zc, LockID lid) { List<String> children = zc.getChildren(lid.path); if (children == null || children.size() == 0) { return false; } children = new ArrayList<>(children); Collections.sort(children); String lockNode = children.get(0); if (!lid.node.equals(lockNode)) return false; ZcStat stat = new ZcStat(); return zc.get(lid.path + "/" + lid.node, stat) != null && stat.getEphemeralOwner() == lid.eid; }
ZcStat stat = new ZcStat(); byte[] lockData = ZooLock.getLockData(getZooCache(), lockPath, stat);
@Override public MonitorLocation get() { // lazily set up path and zooCache (see comment in constructor) if (this.context == null) { this.context = new ServerContext(new SiteConfiguration()); this.path = context.getZooKeeperRoot() + Constants.ZMONITOR_LOG4J_ADDR; this.zooCache = context.getZooCache(); } // get the current location from the cache and update if necessary ZcStat stat = new ZcStat(); byte[] loc = zooCache.get(path, stat); // mzxid is 0 if location does not exist and the non-zero transaction id of the last // modification otherwise return new MonitorLocation(stat.getMzxid(), loc); } }