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.
 
Method Summary
protected  void addLock(Long nodeId, LockType type, LockGrantType grantStatus)
          Add a lock to set owned by this transaction.
protected  void checkState(boolean ignoreCalledByAbort)
           
 StatGroup collectStats()
          stats
static BasicLocker createBasicLocker(EnvironmentImpl env)
           
static BasicLocker createBasicLocker(EnvironmentImpl env, boolean noWait)
           
 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.
 boolean lockingRequired()
          Returns true if locking is required for this Locker.
protected  LockResult lockInternal(long nodeId, LockType lockType, boolean noWait, DatabaseImpl database)
          Abstract method to a blocking or non-blocking lock of the given type on the given nodeId.
 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.
(package private)  void moveWriteToReadLock(long nodeId, Lock lock)
          A lock is being demoted.
 Locker newNonTxnLocker()
          Throws EnvironmentFailureException 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.
(package private)  void removeLock(long nodeId)
          Remove a lock from the set owned by this txn.
 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
addBuddy, addDeleteInfo, addToHandleMaps, checkPreempted, close, demoteLock, dumpLockTable, getDefaultNoWait, getId, getImportunate, getInitialLockTimeout, getLockTimeout, getPreemptable, getTxnStartMillis, getTxnTimeout, getWaitingFor, isHandleLockTransferrable, isPreempted, isReadUncommittedDefault, isReplicationDefined, isRolledBack, isTimedOut, lock, nonBlockingLock, openCursorHook, operationEnd, operationEnd, releaseLock, removeBuddy, setClosingLocker, setImportunate, setLockTimeout, setOnlyAbortable, setPreemptable, setPreempted, setTxnTimeout, setWaitingFor, sharesLocksWith, throwIfPreempted, toString, transferHandleLock, transferHandleLockToHandle, unregisterHandle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicLocker

protected BasicLocker(EnvironmentImpl env)
Creates a BasicLocker.


BasicLocker

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

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

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)
Specified by:
checkState in class Locker

lockInternal

protected LockResult lockInternal(long nodeId,
                                  LockType lockType,
                                  boolean noWait,
                                  DatabaseImpl database)
                           throws DatabaseException
Description copied from class: Locker
Abstract method to a blocking or non-blocking lock of the given type on the given nodeId. Unlike the lock() method, this method does not throw LockNotAvailableException and can therefore be used by nonBlockingLock to probe for a lock without the overhead of an exception stack trace.

Specified by:
lockInternal in class Locker
Parameters:
nodeId - is the node to lock.
lockType - is the type of lock to request.
noWait - is true to override the defaultNoWait setting. If true, or if defaultNoWait is true, throws LockNotAvailableException if the lock cannot be granted without waiting.
database - is the database containing nodeId.
Throws:
LockConflictException - if a blocking lock could not be acquired.
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 EnvironmentFailureException 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 - from subclasses.

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)
This txn doesn't store cursors.

Specified by:
registerCursor in class Locker
Throws:
DatabaseException - in subclasses.

unRegisterCursor

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

Specified by:
unRegisterCursor in class Locker

lockingRequired

public boolean lockingRequired()
Description copied from class: Locker
Returns true if locking is required for this Locker. All Txnal lockers require it; most BasicLockers do not, but BasicLockers on internal dbs do.

Specified by:
lockingRequired in class Locker

getAbortLsn

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

getWriteLockInfo

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

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(Long nodeId,
                       LockType type,
                       LockGrantType grantStatus)
Add a lock to set owned by this transaction.

Specified by:
addLock in class Locker

removeLock

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

Specified by:
removeLock in class Locker

createdNode

public boolean createdNode(long nodeId)
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.

moveWriteToReadLock

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

Specified by:
moveWriteToReadLock in class Locker

collectStats

public StatGroup collectStats()
                       throws DatabaseException
stats

Specified by:
collectStats in class Locker
Throws:
DatabaseException


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