com.sleepycat.je.txn
Class Lock

java.lang.Object
  extended by com.sleepycat.je.txn.Lock

public class Lock
extends Object

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


Constructor Summary
Lock(Long nodeId)
          Create a Lock.
 
Method Summary
(package private)  void demote(Locker locker)
          Downgrade a write lock to a read lock.
(package private)  void flushWaiter(Locker locker, MemoryBudget mb)
          Remove this locker from the waiter list.
(package private)  Long getNodeId()
           
(package private)  Set getOwnersClone()
          Get a new Set of the owners.
(package private)  List getWaitersListClone()
          Get a list of waiters for debugging and error messages.
(package private)  Locker getWriteOwnerLocker()
          Return the locker that has a write ownership on this lock.
(package private)  boolean isOwnedWriteLock(Locker locker)
          Return true if locker is an owner of this Lock and this is a write lock.
(package private)  boolean isOwner(Locker locker, LockType lockType)
          Return true if locker is an owner of this Lock for lockType, false otherwise.
(package private)  boolean isWaiter(Locker locker)
          Return true if locker is a waiter on this Lock.
(package private)  LockGrantType lock(LockType requestType, Locker locker, boolean nonBlockingRequest, MemoryBudget mb)
          Attempts to acquire the lock and returns the LockGrantType.
(package private)  int nOwners()
           
(package private)  int nWaiters()
           
(package private)  Set release(Locker locker, MemoryBudget mb)
          Releases a lock and moves the next waiter(s) to the owners.
 String toString()
          Debug dumper.
(package private)  LockType transfer(Locker currentLocker, Locker destLocker, MemoryBudget mb)
          Transfer a lock from one transaction to another.
(package private)  LockType transferMultiple(Locker currentLocker, Locker[] destLockers, MemoryBudget mb)
          Transfer a lock from one transaction to many others.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Lock

Lock(Long nodeId)
Create a Lock.

Method Detail

getNodeId

Long getNodeId()

getWaitersListClone

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


flushWaiter

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


getOwnersClone

Set 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.


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

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


release

Set release(Locker locker,
            MemoryBudget mb)
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.

demote

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


transfer

LockType transfer(Locker currentLocker,
                  Locker destLocker,
                  MemoryBudget mb)
            throws DatabaseException
Transfer a lock from one transaction to another. Make sure that this destination locker is only present as a single reader or writer.

Throws:
DatabaseException

transferMultiple

LockType transferMultiple(Locker currentLocker,
                          Locker[] destLockers,
                          MemoryBudget mb)
                    throws DatabaseException
Transfer a lock from one transaction to many others. Only really needed for case where a write handle lock is being transferred to multiple read handles.

Throws:
DatabaseException

getWriteOwnerLocker

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


toString

public String toString()
Debug dumper.

Overrides:
toString in class Object


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