public synchronized boolean tryLock(LockWatcher lw, byte data[]) throws KeeperException, InterruptedException { TryLockAsyncLockWatcher tlalw = new TryLockAsyncLockWatcher(lw); lockAsync(tlalw, data); if (tlalw.acquiredLock) { return true; } if (asyncLock != null) { zooKeeper.recursiveDelete(path + "/" + asyncLock, NodeMissingPolicy.SKIP); asyncLock = null; } return false; }
private static boolean zookeeperAvailable() { try { return zoo.exists("/"); } catch (KeeperException | InterruptedException e) { return false; } }
@Override public void putPersistentData(String zPath, byte[] data, int version, NodeExistsPolicy policy) throws KeeperException, InterruptedException { ZooUtil.putPersistentData(info, zPath, data, version, policy); }
public ZooLock(String zookeepers, int timeInMillis, String scheme, byte[] auth, String path) { this(new ZooCacheFactory().getZooCache(zookeepers, timeInMillis), ZooReaderWriter.getInstance(zookeepers, timeInMillis, scheme, auth), path); }
public synchronized boolean tryToCancelAsyncLockOrUnlock() throws InterruptedException, KeeperException { boolean del = false; if (asyncLock != null) { zooKeeper.recursiveDelete(path + "/" + asyncLock, NodeMissingPolicy.SKIP); del = true; } if (lock != null) { unlock(); del = true; } return del; }
@Override public void invalidateCache() { if (propCache != null) propCache.clear(); }
/** * Gets data at the given path. Status information is not returned. A watch is established by this * call. * * @param zPath * path to get * @return path data, or null if non-existent */ public byte[] get(final String zPath) { return get(zPath, null); }
public static synchronized ZooReaderWriter getInstance(String zookeepers, int timeInMillis, String scheme, byte[] auth) { if (instance == null) instance = new ZooReaderWriter(zookeepers, timeInMillis, scheme, auth); return instance; }
/** * Create a persistent node with the default ACL * * @return true if the node was created or altered; false if it was skipped */ public static boolean putPersistentData(ZooKeeperConnectionInfo info, String zPath, byte[] data, NodeExistsPolicy policy) throws KeeperException, InterruptedException { return putData(info, zPath, data, CreateMode.PERSISTENT, -1, policy, PUBLIC); }
@Override public void recursiveDelete(String zPath, NodeMissingPolicy policy) throws KeeperException, InterruptedException { ZooUtil.recursiveDelete(info, zPath, policy); }
@Override public boolean putPrivatePersistentData(String zPath, byte[] data, NodeExistsPolicy policy) throws KeeperException, InterruptedException { return ZooUtil.putPrivatePersistentData(info, zPath, data, policy); }
@Override public String putEphemeralSequential(String zPath, byte[] data) throws KeeperException, InterruptedException { return ZooUtil.putEphemeralSequential(info, zPath, data); }
@Override public void recursiveCopyPersistent(String source, String destination, NodeExistsPolicy policy) throws KeeperException, InterruptedException { ZooUtil.recursiveCopyPersistent(info, source, destination, policy); }
private void lostLock(LockLossReason reason) { LockWatcher localLw = lockWatcher; lock = null; lockWatcher = null; localLw.lostLock(reason); }
@Override public String putPersistentSequential(String zPath, byte[] data) throws KeeperException, InterruptedException { return ZooUtil.putPersistentSequential(info, zPath, data); }
/** * Clears the internal {@link ZooCache}. */ void invalidateCache() { propCache.clear(); }
@Override public boolean putPersistentData(String zPath, byte[] data, NodeExistsPolicy policy) throws KeeperException, InterruptedException { return ZooUtil.putPersistentData(info, zPath, data, policy); }
public static boolean putPersistentData(ZooKeeperConnectionInfo info, String zPath, byte[] data, int version, NodeExistsPolicy policy, List<ACL> acls) throws KeeperException, InterruptedException { return putData(info, zPath, data, CreateMode.PERSISTENT, version, policy, acls); }
@Override protected void finalize() { if (zooCache != null) zooCache.clear(); } }
@Override public boolean putPersistentData(String zPath, byte[] data, int version, NodeExistsPolicy policy, List<ACL> acls) throws KeeperException, InterruptedException { return ZooUtil.putPersistentData(info, zPath, data, version, policy, acls); }