/** Locks key. This will block until the key is acquired or the default timeout is reached. */ public Lock lock(TYPE key) { return lock(key, timeoutMs, TimeUnit.MILLISECONDS); }
@Override public void acquire() { if (throwExceptionOnLock) throw new CuratorLockException("Thrown by mock"); lock = locks.lock(path); }
@Override public boolean acquire(long timeout, TimeUnit unit) { if (throwExceptionOnLock) throw new CuratorLockException("Thrown by mock"); if (timeoutOnLock) return false; try { lock = locks.lock(path, timeout, unit); return true; } catch (UncheckedTimeoutException e) { return false; } }