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 nodeId, Locker locker, LockType type, boolean nonBlockingRequest)
           
(package private)  void demote(long nodeId, 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.
(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.
(package private)  Lock lookupLock(Long nodeId)
           
(package private)  LockConflictException makeTimeoutMsg(boolean isLockNotTxnTimeout, 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.
(package private)  Set<Locker> releaseAndFindNotifyTargets(long nodeId, Locker locker)
          Release the lock, and return the set of new owners to notify, if any.
protected  LockAttemptResult stealLock(Long nodeId, Locker locker, LockType lockType, MemoryBudget mb)
           
(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.
(package private)  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, envConfigUpdate, getLockTableIndex, getLockTableIndex, getThreadLockers, getWriteOwnerLockerInternal, isLockedInternal, isOwnerInternal, isWaiterInternal, loadStats, lock, lockStat, lookupLockInternal, makeTimeoutMsgInternal, newLockNotAvailableException, nOwnersInternal, nWaitersInternal, registerThreadLocker, release, releaseAndFindNotifyTargetsInternal, setLockTableDump, stealLockInternal, transferInternal, transferMultipleInternal, 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

lookupLock

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

attemptLock

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

LockConflictException makeTimeoutMsg(boolean isLockNotTxnTimeout,
                                     Locker locker,
                                     long nodeId,
                                     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 nodeId,
                                        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

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)
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 nodeId)
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.
See Also:
LockManager.isLocked(java.lang.Long)

isOwner

boolean isOwner(Long nodeId,
                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 nodeId,
                 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 nodeId)
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 nodeId)
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 nodeId)
Specified by:
getWriteOwnerLocker in class LockManager
Returns:
the transaction that owns the write lock for this
See Also:
LockManager#getWriterOwnerLocker

validateOwnership

boolean validateOwnership(Long nodeId,
                          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 nodeId,
                                      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-2010 Oracle. All rights reserved.