/** * Constructs a ZooKeeper lock object. * * @param zookeeper ZooKeeper client. * @param lockDir Path of the directory node to use for the lock. */ public ZooKeeperLock(ZooKeeperClient zookeeper, File lockDir) { this.mConstructorStack = CLEANUP_LOG.isDebugEnabled() ? Debug.getStackTrace() : null; this.mZKClient = zookeeper; this.mLockDir = lockDir; this.mLockPathPrefix = new File(lockDir, LOCK_NAME_PREFIX); // ZooKeeperClient.retain() should be the last line of the constructor. this.mZKClient.retain(); ResourceTracker.get().registerResource(this); }