@Override public final LocalDatabase getDatabase() { return manager().mDatabaseRef.get(); }
/** * Checks the lock ownership for the given key. * * <p><i>Note: This method is intended for advanced use cases.</i> * * @return {@link LockResult#UNOWNED UNOWNED}, {@link * LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} */ public final LockResult lockCheck(long indexId, byte[] key) { return manager().check(this, indexId, key, hash(indexId, key)); }
/** * Checks the lock ownership for the given key. * * <p><i>Note: This method is intended for advanced use cases.</i> * * @return {@link LockResult#UNOWNED UNOWNED}, {@link * LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} */ public final LockResult lockCheck(long indexId, byte[] key) { return manager().check(this, indexId, key, hash(indexId, key)); }
/** * Checks the lock ownership for the given key. * * <p><i>Note: This method is intended for advanced use cases.</i> * * @return {@link LockResult#UNOWNED UNOWNED}, {@link * LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} */ public final LockResult lockCheck(long indexId, byte[] key) { return manager().check(this, indexId, key, hash(indexId, key)); }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult tryLock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws DeadlockException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result == LockResult.TIMED_OUT_LOCK) { Lock waitingFor = mWaitingFor; if (waitingFor != null) { try { // Perform deadlock detection except for the fast-fail case. if (nanosTimeout != 0) { detectDeadlock(waitingFor, lockType, nanosTimeout, hash); } } finally { mWaitingFor = null; } } } return result; }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult tryLock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws DeadlockException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result == LockResult.TIMED_OUT_LOCK) { Lock waitingFor = mWaitingFor; if (waitingFor != null) { try { // Perform deadlock detection except for the fast-fail case. if (nanosTimeout != 0) { waitingFor.detectDeadlock(this, lockType, nanosTimeout); } } finally { mWaitingFor = null; } } } return result; }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult lock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result.isHeld()) { return result; } throw failed(lockType, result, nanosTimeout); }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult tryLock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws DeadlockException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result == LockResult.TIMED_OUT_LOCK) { Lock waitingFor = mWaitingFor; if (waitingFor != null) { try { // Perform deadlock detection except for the fast-fail case. if (nanosTimeout != 0) { waitingFor.detectDeadlock(this, lockType, nanosTimeout); } } finally { mWaitingFor = null; } } } return result; }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult lock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result.isHeld()) { return result; } throw failed(lockType, result, nanosTimeout, hash); }
/** * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE */ final LockResult lock(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (result.isHeld()) { return result; } throw failed(lockType, result, nanosTimeout); }
/** * NT == No Timeout or deadlock exception thrown * * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE * @return {@link LockResult#TIMED_OUT_LOCK TIMED_OUT_LOCK}, {@link * LockResult#ACQUIRED ACQUIRED}, {@link LockResult#OWNED_SHARED * OWNED_SHARED}, {@link LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or * {@link LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} */ @SuppressWarnings("incomplete-switch") final LockResult lockNT(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (!result.isHeld()) { switch (result) { case ILLEGAL: throw new IllegalUpgradeException(); case INTERRUPTED: throw new LockInterruptedException(); } } return result; }
/** * NT == No Timeout or deadlock exception thrown * * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE * @return {@link LockResult#TIMED_OUT_LOCK TIMED_OUT_LOCK}, {@link * LockResult#ACQUIRED ACQUIRED}, {@link LockResult#OWNED_SHARED * OWNED_SHARED}, {@link LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or * {@link LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} */ @SuppressWarnings("incomplete-switch") final LockResult lockNT(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (!result.isHeld()) { switch (result) { case ILLEGAL: throw new IllegalUpgradeException(); case INTERRUPTED: throw new LockInterruptedException(); } } return result; }
/** * NT == No Timeout or deadlock exception thrown * * @param lockType TYPE_SHARED, TYPE_UPGRADABLE, or TYPE_EXCLUSIVE * @return {@link LockResult#TIMED_OUT_LOCK TIMED_OUT_LOCK}, {@link * LockResult#ACQUIRED ACQUIRED}, {@link LockResult#OWNED_SHARED * OWNED_SHARED}, {@link LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or * {@link LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} */ @SuppressWarnings("incomplete-switch") final LockResult lockNT(int lockType, long indexId, byte[] key, int hash, long nanosTimeout) throws LockFailureException { LockResult result = manager().getLockHT(hash) .tryLock(lockType, this, indexId, key, hash, nanosTimeout); if (!result.isHeld()) { switch (result) { case ILLEGAL: throw new IllegalUpgradeException(); case INTERRUPTED: throw new LockInterruptedException(); } } return result; }