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 non-transactional Locker that simply tracks locks and releases them when releaseNonTxnLocks or operationEnd is called.


Field Summary
 
Fields inherited from class com.sleepycat.je.txn.Locker
defaultNoWait, deleteInfo, envImpl, handleLockToHandleMap, handleToHandleLockMap, id, lockManager, readUncommittedDefault, thread
 
Constructor Summary
protected BasicLocker(EnvironmentImpl env)
          Creates a BasicLocker.
protected BasicLocker(EnvironmentImpl env, boolean noWait)
          Creates a BasicLocker with a noWait argument.
protected BasicLocker(EnvironmentImpl env, boolean noWait, boolean noAPIReadLock)
          Creates a BasicLocker with the noWait and noAPIReadLock arguments.
 
Method Summary
protected  void addLock(java.lang.Long nodeId, LockType type, LockGrantType grantStatus)
          Add a lock to set owned by this transaction.
protected  void checkState(boolean ignoreCalledByAbort)
           
 LockStats collectStats(LockStats stats)
          stats
static BasicLocker createBasicLocker(EnvironmentImpl env)
           
static BasicLocker createBasicLocker(EnvironmentImpl env, boolean noWait)
           
static BasicLocker createBasicLocker(EnvironmentImpl env, boolean noWait, boolean noAPIReadLock)
           
 boolean createdNode(long nodeId)
          Always false for this txn.
protected  long generateId(TxnManager txnManager, long ignore)
          BasicLockers always have a fixed id, because they are never used for recovery.
 long getAbortLsn(long nodeId)
           
 Txn getTxnLocker()
          No transactional locker is available.
 WriteLockInfo getWriteLockInfo(long nodeId)
           
 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.
 void markDeleteAtTxnEnd(DatabaseImpl db, boolean deleteAtCommit)
          Database operations like remove and truncate leave behind residual DatabaseImpls that must be purged at transaction commit or abort.
 Locker newNonTxnLocker()
          Throws UnsupportedOperationException unconditionally.
 void nonTxnOperationEnd()
          Release locks and close the cursor at the end of the operation.
 void operationEnd(boolean operationOK)
          Release locks and close the cursor at the end of the operation.
 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.
 void setHandleLockOwner(boolean operationOK, 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, getDefaultNoWait, getId, getLockTimeout, getTxnTimeout, initApiReadLock, isHandleLockTransferrable, isReadUncommittedDefault, isTimedOut, lock, nonBlockingLock, operationEnd, operationEnd, releaseLock, setLockTimeout, setOnlyAbortable, setTxnTimeout, sharesLocksWith, toString, transferHandleLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicLocker

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

Throws:
DatabaseException

BasicLocker

protected BasicLocker(EnvironmentImpl env,
                      boolean noWait)
               throws DatabaseException
Creates a BasicLocker with a noWait argument.

Throws:
DatabaseException

BasicLocker

protected BasicLocker(EnvironmentImpl env,
                      boolean noWait,
                      boolean noAPIReadLock)
               throws DatabaseException
Creates a BasicLocker with the noWait and noAPIReadLock arguments.

Throws:
DatabaseException
Method Detail

createBasicLocker

public static BasicLocker createBasicLocker(EnvironmentImpl env)
                                     throws DatabaseException
Throws:
DatabaseException

createBasicLocker

public static BasicLocker createBasicLocker(EnvironmentImpl env,
                                            boolean noWait)
                                     throws DatabaseException
Throws:
DatabaseException

createBasicLocker

public static BasicLocker createBasicLocker(EnvironmentImpl env,
                                            boolean noWait,
                                            boolean noAPIReadLock)
                                     throws DatabaseException
Throws:
DatabaseException

generateId

protected long generateId(TxnManager txnManager,
                          long ignore)
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

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

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
Throws UnsupportedOperationException unconditionally. If we were to create a new BasicLocker here, it would not share locks with this locker, which violates the definition of this method. This method is not currently called in direct uses of BasicLocker and is overridden by subclasses where it is allowed (e.g., ThreadLocker and ReadCommittedLocker).

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

nonTxnOperationEnd

public void nonTxnOperationEnd()
                        throws DatabaseException
Release locks and close the cursor at the end of the operation.

Specified by:
nonTxnOperationEnd in class Locker
Throws:
DatabaseException

operationEnd

public void operationEnd(boolean operationOK)
                  throws DatabaseException
Release locks and close the cursor at the end of the operation.

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

setHandleLockOwner

public void setHandleLockOwner(boolean operationOK,
                               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

getWriteLockInfo

public WriteLockInfo getWriteLockInfo(long nodeId)
                               throws DatabaseException
Specified by:
getWriteLockInfo in class Locker
Returns:
a dummy WriteLockInfo for this node.
Throws:
DatabaseException

markDeleteAtTxnEnd

public void markDeleteAtTxnEnd(DatabaseImpl db,
                               boolean deleteAtCommit)
                        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

protected void addLock(java.lang.Long nodeId,
                       LockType type,
                       LockGrantType grantStatus)
                throws DatabaseException
Add a lock to set owned by this transaction.

Specified by:
addLock 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

collectStats

public LockStats collectStats(LockStats stats)
                       throws DatabaseException
stats

Specified by:
collectStats in class Locker
Throws:
DatabaseException