com.sleepycat.je.txn
Interface Lock

All Known Implementing Classes:
LockImpl, ThinLockImpl

interface Lock

A Lock embodies the lock state of an LSN. It includes a set of owners and a list of waiters.


Method Summary
 void demote(Locker locker)
          Downgrade a write lock to a read lock.
 void flushWaiter(Locker locker, MemoryBudget mb, int lockTableIndex)
          Remove this locker from the waiter list.
 LockType getOwnedLockType(Locker locker)
          Returns the LockType if the given locker owns this lock, or null if the lock is not owned.
 Set<LockInfo> getOwnersClone()
          Get a new Set of the owners.
 List<LockInfo> getWaitersListClone()
          Get a list of waiters for debugging and error messages.
 Locker getWriteOwnerLocker()
          Return the locker that has a write ownership on this lock.
 boolean isOwnedWriteLock(Locker locker)
          Return true if locker is an owner of this Lock and this is a write lock.
 boolean isOwner(Locker locker, LockType lockType)
          Return true if locker is an owner of this Lock for lockType, false otherwise.
 boolean isThin()
           
 boolean isWaiter(Locker locker)
          Return true if locker is a waiter on this Lock.
 LockAttemptResult lock(LockType requestType, Locker locker, boolean nonBlockingRequest, boolean jumpAheadOfWaiters, MemoryBudget mb, int lockTableIndex)
          Attempts to acquire the lock and returns the LockGrantType.
 int nOwners()
           
 int nWaiters()
           
 Set<Locker> release(Locker locker, MemoryBudget mb, int lockTableIndex)
          Releases a lock and moves the next waiter(s) to the owners.
 void stealLock(Locker locker, MemoryBudget mb, int lockTableIndex)
          Removes all owners except for the given owner, and sets the Preempted property on the removed owners.
 String toString()
          Debug dumper.
 

Method Detail

getWaitersListClone

List<LockInfo> getWaitersListClone()
Get a list of waiters for debugging and error messages.


flushWaiter

void flushWaiter(Locker locker,
                 MemoryBudget mb,
                 int lockTableIndex)
Remove this locker from the waiter list.


getOwnersClone

Set<LockInfo> getOwnersClone()
Get a new Set of the owners.


isOwner

boolean isOwner(Locker locker,
                LockType lockType)
Return true if locker is an owner of this Lock for lockType, false otherwise. This method is only used by unit tests.


isOwnedWriteLock

boolean isOwnedWriteLock(Locker locker)
Return true if locker is an owner of this Lock and this is a write lock.


getOwnedLockType

LockType getOwnedLockType(Locker locker)
Returns the LockType if the given locker owns this lock, or null if the lock is not owned.


isWaiter

boolean isWaiter(Locker locker)
Return true if locker is a waiter on this Lock. This method is only used by unit tests.


nWaiters

int nWaiters()

nOwners

int nOwners()

lock

LockAttemptResult lock(LockType requestType,
                       Locker locker,
                       boolean nonBlockingRequest,
                       boolean jumpAheadOfWaiters,
                       MemoryBudget mb,
                       int lockTableIndex)
                       throws DatabaseException
Attempts to acquire the lock and returns the LockGrantType. Assumes we hold the lockTableLatch when entering this method.

Throws:
DatabaseException

release

Set<Locker> release(Locker locker,
                    MemoryBudget mb,
                    int lockTableIndex)
Releases a lock and moves the next waiter(s) to the owners.

Returns:
- null if we were not the owner, - a non-empty set if owners should be notified after releasing, - an empty set if no notification is required.

stealLock

void stealLock(Locker locker,
               MemoryBudget mb,
               int lockTableIndex)
               throws DatabaseException
Removes all owners except for the given owner, and sets the Preempted property on the removed owners.

Throws:
DatabaseException

demote

void demote(Locker locker)
Downgrade a write lock to a read lock.


getWriteOwnerLocker

Locker getWriteOwnerLocker()
Return the locker that has a write ownership on this lock. If no write owner exists, return null.


isThin

boolean isThin()

toString

String toString()
Debug dumper.

Overrides:
toString in class Object


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