com.sleepycat.je.txn
Class LatchedLockManager

java.lang.Object
  extended by com.sleepycat.je.txn.LockManager
      extended by com.sleepycat.je.txn.LatchedLockManager

public class LatchedLockManager
extends LockManager

LatchedLockManager uses latches to implement its critical sections.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sleepycat.je.txn.LockManager
LockManager.LockAttemptResult
 
Field Summary
 
Fields inherited from class com.sleepycat.je.txn.LockManager
lockTableLatch, TOTAL_LOCK_OVERHEAD
 
Constructor Summary
LatchedLockManager(EnvironmentImpl envImpl)
           
 
Method Summary
protected  LockManager.LockAttemptResult attemptLock(Long nodeId, Locker locker, LockType type, boolean nonBlockingRequest)
           
(package private)  void demote(long nodeId, Locker locker)
          Demote a lock from write to read.
protected  void dumpLockTable(LockStats stats)
          Dump the lock table to the lock stats.
(package private)  Locker getWriteOwnerLocker(Long nodeId)
           
(package private)  boolean isLocked(Long nodeId)
          Test the status of the lock on nodeId.
(package private)  boolean isOwner(Long nodeId, Locker locker, LockType type)
          Return true if this locker owns this a lock of this type on given node.
(package private)  boolean isWaiter(Long nodeId, Locker locker)
          Return true if this locker is waiting on this lock.
protected  String makeTimeoutMsg(String lockOrTxn, Locker locker, long nodeId, 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 nodeId)
          Return the number of owners of this lock.
(package private)  int nWaiters(Long nodeId)
          Return the number of waiters for this lock.
protected  Set releaseAndFindNotifyTargets(long nodeId, Lock lock, Locker locker, boolean removeFromLocker)
          Release the lock, and return the set of new owners to notify, if any.
(package private)  void transfer(long nodeId, Locker owningLocker, Locker destLocker, boolean demoteToRead)
          Transfer ownership a lock from one locker to another locker.
(package private)  void transferMultiple(long nodeId, Locker owningLocker, Locker[] destLockers)
          Transfer ownership a lock from one locker to a set of other txns, cloning the lock as necessary.
protected  boolean validateOwnership(Long nodeId, Locker locker, LockType type, boolean flushFromWaiters, MemoryBudget mb)
           
 
Methods inherited from class com.sleepycat.je.txn.LockManager
attemptLockInternal, demoteInternal, dump, dumpLockTableInternal, dumpToString, getWriteOwnerLockerInternal, isLockedInternal, isOwnerInternal, isWaiterInternal, lock, lockStat, makeTimeoutMsgInternal, nOwnersInternal, nWaitersInternal, release, release, releaseAndFindNotifyTargetsInternal, transferInternal, transferMultipleInternal, validateOwnershipInternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LatchedLockManager

public LatchedLockManager(EnvironmentImpl envImpl)
                   throws DatabaseException
Throws:
DatabaseException
Method Detail

attemptLock

protected LockManager.LockAttemptResult attemptLock(Long nodeId,
                                                    Locker locker,
                                                    LockType type,
                                                    boolean nonBlockingRequest)
                                             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)

makeTimeoutMsg

protected String makeTimeoutMsg(String lockOrTxn,
                                Locker locker,
                                long nodeId,
                                LockType type,
                                LockGrantType grantType,
                                Lock useLock,
                                long timeout,
                                long start,
                                long now,
                                DatabaseImpl database)
                         throws DatabaseException
Description copied from class: LockManager
Create a informative lock or txn timeout message.

Specified by:
makeTimeoutMsg in class LockManager
Throws:
DatabaseException
See Also:
LockManager.makeTimeoutMsg(java.lang.String, 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

protected Set releaseAndFindNotifyTargets(long nodeId,
                                          Lock lock,
                                          Locker locker,
                                          boolean removeFromLocker)
                                   throws DatabaseException
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.
Throws:
DatabaseException
See Also:
LockManager#releaseAndNotifyTargets

transfer

void transfer(long nodeId,
              Locker owningLocker,
              Locker destLocker,
              boolean demoteToRead)
        throws DatabaseException
Description copied from class: LockManager
Transfer ownership a lock from one locker to another locker. We're not sending any notification to the waiters on the lock table, and the past and present owner should be ready for the transfer.

Specified by:
transfer in class LockManager
Throws:
DatabaseException
See Also:
LockManager.transfer(long, com.sleepycat.je.txn.Locker, com.sleepycat.je.txn.Locker, boolean)

transferMultiple

void transferMultiple(long nodeId,
                      Locker owningLocker,
                      Locker[] destLockers)
                throws DatabaseException
Description copied from class: LockManager
Transfer ownership a lock from one locker to a set of other txns, cloning the lock as necessary. This will always be demoted to read, as we can't have multiple locker owners any other way. We're not sending any notification to the waiters on the lock table, and the past and present owners should be ready for the transfer.

Specified by:
transferMultiple in class LockManager
Throws:
DatabaseException
See Also:
LockManager.transferMultiple(long, com.sleepycat.je.txn.Locker, com.sleepycat.je.txn.Locker[])

demote

void demote(long nodeId,
            Locker locker)
      throws DatabaseException
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
Throws:
DatabaseException
See Also:
LockManager.demote(long, com.sleepycat.je.txn.Locker)

isLocked

boolean isLocked(Long nodeId)
           throws DatabaseException
Description copied from class: LockManager
Test the status of the lock on nodeId. 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:
nodeId - The NodeId to check.
Returns:
true if any transaction holds any lock on the nodeid. false if no lock is held by any transaction.
Throws:
DatabaseException
See Also:
LockManager.isLocked(java.lang.Long)

isOwner

boolean isOwner(Long nodeId,
                Locker locker,
                LockType type)
          throws DatabaseException
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
Throws:
DatabaseException
See Also:
LockManager.isOwner(java.lang.Long, com.sleepycat.je.txn.Locker, com.sleepycat.je.txn.LockType)

isWaiter

boolean isWaiter(Long nodeId,
                 Locker locker)
           throws DatabaseException
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
Throws:
DatabaseException
See Also:
LockManager.isWaiter(java.lang.Long, com.sleepycat.je.txn.Locker)

nWaiters

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

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

nOwners

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

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

getWriteOwnerLocker

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

validateOwnership

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

dumpLockTable

protected void dumpLockTable(LockStats stats)
                      throws DatabaseException
Description copied from class: LockManager
Dump the lock table to the lock stats.

Specified by:
dumpLockTable in class LockManager
Throws:
DatabaseException
See Also:
LockManager.dumpLockTable(com.sleepycat.je.LockStats)


Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.