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, HandleLocker, 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, 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 lsn, 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 lsn)
          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.
 Txn getTxnLocker()
          No transactional locker is available.
 WriteLockInfo getWriteLockInfo(long lsn)
           
 Locker getWriteOwnerLocker(long lsn)
          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 lsn, LockType lockType, boolean noWait, boolean jumpAheadOfWaiters, DatabaseImpl database)
          Abstract method to a blocking or non-blocking lock of the given type on the given LSN.
 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 lsn, 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 preLogWithoutLock(DatabaseImpl database)
          In the case where logging occurs before locking, we must ensure that we're prepared to undo if logging succeeds but locking fails.
 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 lsn)
          Remove a lock from the set owned by this txn.
 void unRegisterCursor(CursorImpl cursor)
          This txn doesn't store cursors.
 
Methods inherited from class com.sleepycat.je.txn.Locker
addBuddy, addDeleteInfo, addOpenedDatabase, allowReleaseLockAfterLsnChange, checkPreempted, close, demoteLock, disallowReplicaWrite, dumpLockTable, getDefaultNoWait, getEnvironment, getId, getImportunate, getInitialLockTimeout, getLockTimeout, getPreemptable, getTransaction, getTxnStartMillis, getTxnTimeout, getWaitingFor, isPreempted, isReadUncommittedDefault, isReplicationDefined, isRolledBack, isTimedOut, isValid, lock, lockAfterLsnChange, nonBlockingLock, openCursorHook, operationEnd, operationEnd, releaseLock, removeBuddy, setAllowMultithreadedAccess, setClosingLocker, setImportunate, setLockTimeout, setOnlyAbortable, setPreemptable, setPreempted, setTxnTimeout, setWaitingFor, sharesLocksWith, throwIfPreempted, toString
 
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 lsn,
                                  LockType lockType,
                                  boolean noWait,
                                  boolean jumpAheadOfWaiters,
                                  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 LSN. 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:
lsn - 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.
jumpAheadOfWaiters - grant the lock before other waiters, if any.
database - is the database containing lsn.
Throws:
LockConflictException - if a blocking lock could not be acquired.
DatabaseException

preLogWithoutLock

public void preLogWithoutLock(DatabaseImpl database)
Description copied from class: Locker
In the case where logging occurs before locking, we must ensure that we're prepared to undo if logging succeeds but locking fails.

Specified by:
preLogWithoutLock in class Locker

getWriteOwnerLocker

public Locker getWriteOwnerLocker(long lsn)
                           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

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

getWriteLockInfo

public WriteLockInfo getWriteLockInfo(long lsn)
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 lsn,
                       LockType type,
                       LockGrantType grantStatus)
Add a lock to set owned by this transaction.

Specified by:
addLock in class Locker

removeLock

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

Specified by:
removeLock in class Locker

createdNode

public boolean createdNode(long lsn)
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 lsn,
                         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. Note lack of synchronization while accessing Lock object. Appropriate for unit testing only.

Specified by:
collectStats in class Locker
Throws:
DatabaseException


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