com.sleepycat.je.txn
Class SyncedLockManager

java.lang.Object
  extended by com.sleepycat.je.txn.LockManager
      extended by com.sleepycat.je.txn.SyncedLockManager
All Implemented Interfaces:
EnvConfigObserver

public class SyncedLockManager
extends LockManager

SyncedLockManager uses the synchronized keyword to implement its critical sections.


Field Summary
 
Fields inherited from class com.sleepycat.je.txn.LockManager
lockTableLatches, nLockTables, TOTAL_LOCKIMPL_OVERHEAD, TOTAL_THINLOCKIMPL_OVERHEAD
 
Constructor Summary
SyncedLockManager(EnvironmentImpl envImpl)
           
 
Method Summary
(package private)  LockAttemptResult attemptLock(Long lsn, Locker locker, LockType type, boolean nonBlockingRequest, boolean jumpAheadOfWaiters)
           
(package private)  void demote(long lsn, Locker locker)
          Demote a lock from write to read.
(package private)  void dumpLockTable(StatGroup stats, boolean clear)
          Dump the lock table to the lock stats.
 LockType getOwnedLockType(Long lsn, Locker locker)
          Returns the LockType if the given locker owns a lock on the given node, or null if the lock is not owned.
 Set<LockInfo> getOwners(Long lsn)
          Returns the Lockers that own a lock on the given LSN.
(package private)  Locker getWriteOwnerLocker(Long lsn)
           
(package private)  boolean isLocked(Long lsn)
          Test the status of the lock on LSN.
 boolean isLockUncontended(Long lsn)
           
(package private)  boolean isOwner(Long lsn, Locker locker, LockType type)
          Return true if this locker owns this a lock of this type on given node.
(package private)  boolean isWaiter(Long lsn, Locker locker)
          Return true if this locker is waiting on this lock.
(package private)  Lock lookupLock(Long lsn)
           
(package private)  LockConflictException makeTimeoutMsg(boolean isLockNotTxnTimeout, Locker locker, long lsn, LockType type, LockGrantType grantType, Lock useLock, long timeout, long start, long now, DatabaseImpl database)
          Create a informative lock or txn timeout message.
(package private)  int nOwners(Long lsn)
          Return the number of owners of this lock.
(package private)  int nWaiters(Long lsn)
          Return the number of waiters for this lock.
(package private)  Set<Locker> releaseAndFindNotifyTargets(long lsn, Locker locker)
          Release the lock, and return the set of new owners to notify, if any.
protected  LockAttemptResult stealLock(Long lsn, Locker locker, LockType lockType, MemoryBudget mb)
           
(package private)  boolean validateOwnership(Long lsn, Locker locker, LockType type, boolean flushFromWaiters, MemoryBudget mb)
           
 
Methods inherited from class com.sleepycat.je.txn.LockManager
attemptLockInternal, demoteInternal, dump, dumpLockTableInternal, dumpToString, envConfigUpdate, getLockTableIndex, getLockTableIndex, getOwnedLockTypeInternal, getOwnersInternal, getThreadLockers, getWriteOwnerLockerInternal, isLockedInternal, isLockUncontendedInternal, isOwnerInternal, isWaiterInternal, loadStats, lock, lockStat, lookupLockInternal, makeTimeoutMsgInternal, newLockNotAvailableException, nOwnersInternal, nWaitersInternal, registerThreadLocker, release, releaseAndFindNotifyTargetsInternal, setLockTableDump, stealLockInternal, unregisterThreadLocker, validateOwnershipInternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncedLockManager

public SyncedLockManager(EnvironmentImpl envImpl)
Method Detail

getOwners

public Set<LockInfo> getOwners(Long lsn)
Description copied from class: LockManager
Returns the Lockers that own a lock on the given LSN. Note that when this method returns, there is nothing to prevent these lockers from releasing the lock or being closed.

Specified by:
getOwners in class LockManager

getOwnedLockType

public LockType getOwnedLockType(Long lsn,
                                 Locker locker)
Description copied from class: LockManager
Returns the LockType if the given locker owns a lock on the given node, or null if the lock is not owned.

Specified by:
getOwnedLockType in class LockManager

isLockUncontended

public boolean isLockUncontended(Long lsn)
Specified by:
isLockUncontended in class LockManager

lookupLock

Lock lookupLock(Long lsn)
Specified by:
lookupLock in class LockManager
See Also:
LockManager.attemptLock(java.lang.Long, com.sleepycat.je.txn.Locker, com.sleepycat.je.txn.LockType, boolean, boolean)

attemptLock

LockAttemptResult attemptLock(Long lsn,
                              Locker locker,
                              LockType type,
                              boolean nonBlockingRequest,
                              boolean jumpAheadOfWaiters)
                        throws DatabaseException
Specified by:
attemptLock in class LockManager
Throws:
DatabaseException
See Also:
LockManager.attemptLock(java.lang.Long, com.sleepycat.je.txn.Locker, com.sleepycat.je.txn.LockType, boolean, boolean)

makeTimeoutMsg

LockConflictException makeTimeoutMsg(boolean isLockNotTxnTimeout,
                                     Locker locker,
                                     long lsn,
                                     LockType type,
                                     LockGrantType grantType,
                                     Lock useLock,
                                     long timeout,
                                     long start,
                                     long now,
                                     DatabaseImpl database)
Description copied from class: LockManager
Create a informative lock or txn timeout message.

Specified by:
makeTimeoutMsg in class LockManager
See Also:
LockManager.makeTimeoutMsg(boolean, com.sleepycat.je.txn.Locker, long, com.sleepycat.je.txn.LockType, com.sleepycat.je.txn.LockGrantType, com.sleepycat.je.txn.Lock, long, long, long, com.sleepycat.je.dbi.DatabaseImpl)

releaseAndFindNotifyTargets

Set<Locker> releaseAndFindNotifyTargets(long lsn,
                                        Locker locker)
Description copied from class: LockManager
Release the lock, and return the set of new owners to notify, if any.

Specified by:
releaseAndFindNotifyTargets in class LockManager
Returns:
null if the lock does not exist or the given locker was not the owner, a non-empty set if owners should be notified after releasing, an empty set if no notification is required.
See Also:
LockManager#releaseAndNotifyTargets

demote

void demote(long lsn,
            Locker locker)
Description copied from class: LockManager
Demote a lock from write to read. Call back to the owning locker to move this to its read collection.

Specified by:
demote in class LockManager
See Also:
LockManager.demote(long, com.sleepycat.je.txn.Locker)

isLocked

boolean isLocked(Long lsn)
Description copied from class: LockManager
Test the status of the lock on LSN. If any transaction holds any lock on it, true is returned. If no transaction holds a lock on it, false is returned. This method is only used by unit tests.

Specified by:
isLocked in class LockManager
Parameters:
lsn - The LSN to check.
Returns:
true if any transaction holds any lock on the LSN. false if no lock is held by any transaction.
See Also:
LockManager.isLocked(java.lang.Long)

isOwner

boolean isOwner(Long lsn,
                Locker locker,
                LockType type)
Description copied from class: LockManager
Return true if this locker owns this a lock of this type on given node. This method is only used by unit tests.

Specified by:
isOwner in class LockManager
See Also:
LockManager.isOwner(java.lang.Long, com.sleepycat.je.txn.Locker, com.sleepycat.je.txn.LockType)

isWaiter

boolean isWaiter(Long lsn,
                 Locker locker)
Description copied from class: LockManager
Return true if this locker is waiting on this lock. This method is only used by unit tests.

Specified by:
isWaiter in class LockManager
See Also:
LockManager.isWaiter(java.lang.Long, com.sleepycat.je.txn.Locker)

nWaiters

int nWaiters(Long lsn)
Description copied from class: LockManager
Return the number of waiters for this lock.

Specified by:
nWaiters in class LockManager
See Also:
LockManager.nWaiters(java.lang.Long)

nOwners

int nOwners(Long lsn)
Description copied from class: LockManager
Return the number of owners of this lock.

Specified by:
nOwners in class LockManager
See Also:
LockManager.nOwners(java.lang.Long)

getWriteOwnerLocker

Locker getWriteOwnerLocker(Long lsn)
Specified by:
getWriteOwnerLocker in class LockManager
Returns:
the transaction that owns the write lock for this
See Also:
LockManager#getWriterOwnerLocker

validateOwnership

boolean validateOwnership(Long lsn,
                          Locker locker,
                          LockType type,
                          boolean flushFromWaiters,
                          MemoryBudget mb)
Specified by:
validateOwnership in class LockManager
See Also:
LockManager.validateOwnership(java.lang.Long, com.sleepycat.je.txn.Locker, com.sleepycat.je.txn.LockType, boolean, com.sleepycat.je.dbi.MemoryBudget)

stealLock

protected LockAttemptResult stealLock(Long lsn,
                                      Locker locker,
                                      LockType lockType,
                                      MemoryBudget mb)
                               throws DatabaseException
Specified by:
stealLock in class LockManager
Throws:
DatabaseException
See Also:
LockManager.stealLock(java.lang.Long, com.sleepycat.je.txn.Locker, com.sleepycat.je.txn.LockType, com.sleepycat.je.dbi.MemoryBudget)

dumpLockTable

void dumpLockTable(StatGroup stats,
                   boolean clear)
Description copied from class: LockManager
Dump the lock table to the lock stats.

Specified by:
dumpLockTable in class LockManager
See Also:
LockManager.dumpLockTable(com.sleepycat.je.utilint.StatGroup, boolean)


Copyright (c) 2004-2012 Oracle. All rights reserved.