com.sleepycat.je.txn
Class BasicLocker

java.lang.Object
  extended by com.sleepycat.je.txn.Locker
      extended by com.sleepycat.je.txn.BasicLocker
Direct Known Subclasses:
BuddyLocker, ThreadLocker

public class BasicLocker
extends Locker

A concrete Locker that simply tracks locks and releases them when operationEnd is called.


Field Summary
 
Fields inherited from class com.sleepycat.je.txn.Locker
defaultNoWait, deleteInfo, envImpl, handleLockToHandleMap, handleToHandleLockMap, id, lockManager, lockTimeOutMillis, readUncommittedDefault, thread
 
Constructor Summary
BasicLocker(EnvironmentImpl env)
          Creates a BasicLocker.
 
Method Summary
(package private)  void addLock(Long nodeId, Lock lock, LockType type, LockGrantType grantStatus, MemoryBudget mb)
          Add a lock to set owned by this transaction.
protected  void checkState(boolean ignoreCalledByAbort)
           
 LockStats collectStats(LockStats stats)
          stats
 boolean createdNode(long nodeId)
          Always false for this txn.
protected  long generateId(TxnManager txnManager)
          BasicLockers always have a fixed id, because they are never used for recovery.
 boolean getAbortKnownDeleted(long nodeId)
           
 long getAbortLsn(long nodeId)
           
 long getOwnerAbortLsn(long nodeId)
          Get the abort LSN for this node in the txn that owns the lock on this node.
 Txn getTxnLocker()
          No transactional locker is available.
 Locker getWriteOwnerLocker(long nodeId)
          Get the txn that owns the lock on this node.
 boolean isReadCommittedIsolation()
          Is never read-committed isolation.
 boolean isSerializableIsolation()
          Is never serializable isolation.
 boolean isTransactional()
          Is never transactional.
 LockResult lock(long nodeId, LockType lockType, DatabaseImpl database)
          Get a lock on the given nodeId, using the configured noWait and timeout.
 void markDeleteAtTxnEnd(DatabaseImpl db, boolean deleteAtCommit, MemoryBudget mb)
          Database operations like remove and truncate leave behind residual DatabaseImpls that must be purged at transaction commit or abort.
(package private)  void moveWriteToReadLock(long nodeId, Lock lock, MemoryBudget mb)
          A lock is being demoted.
 Locker newNonTxnLocker()
          Creates a new instance of this txn for the same environment.
 LockGrantType nonBlockingReadLock(long nodeId, DatabaseImpl database)
          Get a non-blocking read lock on this nodeId and return LockGrantType.DENIED if it is not granted.
 void operationEnd()
          Release locks at the end of the transaction.
 void operationEnd(boolean operationOK)
          Release locks at the end of the transaction.
 void registerCursor(CursorImpl cursor)
          This txn doesn't store cursors.
 void releaseNonTxnLocks()
          Releases all locks, since all locks held by this locker are non-transactional.
(package private)  void removeLock(long nodeId, Lock lock)
          Remove a lock from the set owned by this txn.
 void setHandleLockOwner(boolean ignore, Database dbHandle, boolean dbIsClosing)
          Transfer any MapLN locks to the db handle.
 void unRegisterCursor(CursorImpl cursor)
          This txn doesn't store cursors.
 
Methods inherited from class com.sleepycat.je.txn.Locker
addDeleteInfo, addToHandleMaps, demoteLock, dumpLockTable, getId, getLockTimeout, getTxnStartMillis, getTxnTimeOut, getWaitingFor, isHandleLockTransferrable, isReadUncommittedDefault, isTimedOut, operationEnd, releaseLock, rememberHandleWriteLock, setLockTimeout, setOnlyAbortable, setTxnTimeout, setWaitingFor, sharesLocksWith, toString, transferHandleLock, transferHandleLockToHandle, unregisterHandle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicLocker

public BasicLocker(EnvironmentImpl env)
            throws DatabaseException
Creates a BasicLocker.

Throws:
DatabaseException
Method Detail

generateId

protected long generateId(TxnManager txnManager)
BasicLockers always have a fixed id, because they are never used for recovery.

Specified by:
generateId in class Locker

checkState

protected void checkState(boolean ignoreCalledByAbort)
                   throws DatabaseException
Specified by:
checkState in class Locker
Throws:
DatabaseException

lock

public LockResult lock(long nodeId,
                       LockType lockType,
                       DatabaseImpl database)
                throws DatabaseException
Get a lock on the given nodeId, using the configured noWait and timeout.

Specified by:
lock in class Locker
Throws:
DatabaseException

nonBlockingReadLock

public LockGrantType nonBlockingReadLock(long nodeId,
                                         DatabaseImpl database)
                                  throws DatabaseException
Get a non-blocking read lock on this nodeId and return LockGrantType.DENIED if it is not granted. Note that this always gets LockType.READ, not RANGE_READ, and should only be used in specialized internal cases. It should not be used for API-level operations.

Throws:
DatabaseException

getWriteOwnerLocker

public Locker getWriteOwnerLocker(long nodeId)
                           throws DatabaseException
Get the txn that owns the lock on this node. Return null if there's no owning txn found.

Throws:
DatabaseException

getOwnerAbortLsn

public long getOwnerAbortLsn(long nodeId)
                      throws DatabaseException
Get the abort LSN for this node in the txn that owns the lock on this node. Return null if there's no owning txn found.

Throws:
DatabaseException

isTransactional

public boolean isTransactional()
Is never transactional.

Specified by:
isTransactional in class Locker

isSerializableIsolation

public boolean isSerializableIsolation()
Is never serializable isolation.

Specified by:
isSerializableIsolation in class Locker

isReadCommittedIsolation

public boolean isReadCommittedIsolation()
Is never read-committed isolation.

Specified by:
isReadCommittedIsolation in class Locker

getTxnLocker

public Txn getTxnLocker()
No transactional locker is available.

Specified by:
getTxnLocker in class Locker

newNonTxnLocker

public Locker newNonTxnLocker()
                       throws DatabaseException
Creates a new instance of this txn for the same environment. No transactional locks are held by this object, so no locks are retained.

Specified by:
newNonTxnLocker in class Locker
Throws:
DatabaseException

releaseNonTxnLocks

public void releaseNonTxnLocks()
                        throws DatabaseException
Releases all locks, since all locks held by this locker are non-transactional.

Specified by:
releaseNonTxnLocks in class Locker
Throws:
DatabaseException

operationEnd

public void operationEnd()
                  throws DatabaseException
Release locks at the end of the transaction.

Specified by:
operationEnd in class Locker
Throws:
DatabaseException

operationEnd

public void operationEnd(boolean operationOK)
                  throws DatabaseException
Release locks at the end of the transaction.

Specified by:
operationEnd in class Locker
Parameters:
operationOK - is whether the operation succeeded, since that may impact ending behavior. (i.e for AutoTxn)
Throws:
DatabaseException

setHandleLockOwner

public void setHandleLockOwner(boolean ignore,
                               Database dbHandle,
                               boolean dbIsClosing)
                        throws DatabaseException
Transfer any MapLN locks to the db handle.

Specified by:
setHandleLockOwner in class Locker
Throws:
DatabaseException

registerCursor

public void registerCursor(CursorImpl cursor)
                    throws DatabaseException
This txn doesn't store cursors.

Specified by:
registerCursor in class Locker
Throws:
DatabaseException

unRegisterCursor

public void unRegisterCursor(CursorImpl cursor)
                      throws DatabaseException
This txn doesn't store cursors.

Specified by:
unRegisterCursor in class Locker
Throws:
DatabaseException

getAbortLsn

public long getAbortLsn(long nodeId)
                 throws DatabaseException
Specified by:
getAbortLsn in class Locker
Returns:
the abort LSN for this node.
Throws:
DatabaseException

getAbortKnownDeleted

public boolean getAbortKnownDeleted(long nodeId)
                             throws DatabaseException
Specified by:
getAbortKnownDeleted in class Locker
Returns:
the abort known deleted state for this node.
Throws:
DatabaseException

markDeleteAtTxnEnd

public void markDeleteAtTxnEnd(DatabaseImpl db,
                               boolean deleteAtCommit,
                               MemoryBudget mb)
                        throws DatabaseException
Description copied from class: Locker
Database operations like remove and truncate leave behind residual DatabaseImpls that must be purged at transaction commit or abort.

Specified by:
markDeleteAtTxnEnd in class Locker
Throws:
DatabaseException

addLock

void addLock(Long nodeId,
             Lock lock,
             LockType type,
             LockGrantType grantStatus,
             MemoryBudget mb)
       throws DatabaseException
Add a lock to set owned by this transaction.

Specified by:
addLock in class Locker
Throws:
DatabaseException

removeLock

void removeLock(long nodeId,
                Lock lock)
          throws DatabaseException
Remove a lock from the set owned by this txn.

Specified by:
removeLock in class Locker
Throws:
DatabaseException

createdNode

public boolean createdNode(long nodeId)
                    throws DatabaseException
Always false for this txn.

Specified by:
createdNode in class Locker
Returns:
true if this transaction created this node, for a operation with transactional semantics.
Throws:
DatabaseException

moveWriteToReadLock

void moveWriteToReadLock(long nodeId,
                         Lock lock,
                         MemoryBudget mb)
A lock is being demoted. Move it from the write collection into the read collection.

Specified by:
moveWriteToReadLock in class Locker

collectStats

public LockStats collectStats(LockStats stats)
                       throws DatabaseException
stats

Specified by:
collectStats in class Locker
Throws:
DatabaseException


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