com.sleepycat.je.txn
Class ReadCommittedLocker

java.lang.Object
  extended by com.sleepycat.je.txn.Locker
      extended by com.sleepycat.je.txn.BasicLocker
          extended by com.sleepycat.je.txn.BuddyLocker
              extended by com.sleepycat.je.txn.ReadCommittedLocker

public class ReadCommittedLocker
extends BuddyLocker

Extends BuddyLocker to acquire write locks using the buddy locker (the transaction locker). This is used for ReadCommitted (Degree 2) isolation.


Field Summary
 
Fields inherited from class com.sleepycat.je.txn.Locker
defaultNoWait, deleteInfo, envImpl, handleLockToHandleMap, handleToHandleLockMap, id, lockManager, readUncommittedDefault, thread
 
Method Summary
 void addDeleteInfo(BIN bin, Key deletedKey)
          Forwards this method to the transactional buddy.
 boolean createdNode(long nodeId)
          Forwards this method to the transactional buddy.
static ReadCommittedLocker createReadCommittedLocker(EnvironmentImpl env, Locker buddy)
           
 long getAbortLsn(long nodeId)
          Forwards this method to the transactional buddy.
 WriteLockInfo getWriteLockInfo(long nodeId)
           
 boolean isReadCommittedIsolation()
          Is always read-committed isolation.
 boolean isTransactional()
          Is always transactional because the buddy locker is transactional.
 boolean lockingRequired()
          ReadCommittedLockers always require locking.
protected  LockResult lockInternal(long nodeId, LockType lockType, boolean noWait, DatabaseImpl database)
          Forwards write locks to the buddy locker (the transaction locker).
 Locker newNonTxnLocker()
          Returns a new ReadCommittedLocker that shares locks with this locker by virtue of both lockers only holding READ locks.
 void registerCursor(CursorImpl cursor)
          Forwards this method to the transactional buddy.
 boolean releaseLock(long nodeId)
          Releases the lock from this locker, or if not owned by this locker then releases it from the buddy locker.
 void unRegisterCursor(CursorImpl cursor)
          Forwards this method to the transactional buddy.
 
Methods inherited from class com.sleepycat.je.txn.BuddyLocker
checkPreempted, close, createBuddyLocker, getBuddy, getLockTimeout, getTxnLocker, getTxnTimeout, isReplicationDefined, isTimedOut, releaseNonTxnLocks, setLockTimeout, setOnlyAbortable, setTxnTimeout, sharesLocksWith
 
Methods inherited from class com.sleepycat.je.txn.BasicLocker
addLock, checkState, collectStats, createBasicLocker, createBasicLocker, generateId, getWriteOwnerLocker, isSerializableIsolation, markDeleteAtTxnEnd, moveWriteToReadLock, nonTxnOperationEnd, operationEnd, removeLock, setHandleLockOwner
 
Methods inherited from class com.sleepycat.je.txn.Locker
addBuddy, addToHandleMaps, demoteLock, dumpLockTable, getDefaultNoWait, getId, getImportunate, getInitialLockTimeout, getPreemptable, getTxnStartMillis, getWaitingFor, isHandleLockTransferrable, isPreempted, isReadUncommittedDefault, isRolledBack, lock, nonBlockingLock, openCursorHook, operationEnd, operationEnd, removeBuddy, setClosingLocker, setImportunate, setPreemptable, setPreempted, setWaitingFor, throwIfPreempted, toString, transferHandleLock, transferHandleLockToHandle, unregisterHandle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

createReadCommittedLocker

public static ReadCommittedLocker createReadCommittedLocker(EnvironmentImpl env,
                                                            Locker buddy)
                                                     throws DatabaseException
Throws:
DatabaseException

newNonTxnLocker

public Locker newNonTxnLocker()
                       throws DatabaseException
Returns a new ReadCommittedLocker that shares locks with this locker by virtue of both lockers only holding READ locks. The buddy locker underlying both ReadCommittedLocker lockers is the same transactional locker, so WRITE locks are also shared.

Overrides:
newNonTxnLocker in class BasicLocker
Throws:
DatabaseException - from subclasses.

lockInternal

protected LockResult lockInternal(long nodeId,
                                  LockType lockType,
                                  boolean noWait,
                                  DatabaseImpl database)
                           throws DatabaseException
Forwards write locks to the buddy locker (the transaction locker).

Overrides:
lockInternal in class BasicLocker
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
See Also:
Locker.lockInternal(long, com.sleepycat.je.txn.LockType, boolean, com.sleepycat.je.dbi.DatabaseImpl)

releaseLock

public boolean releaseLock(long nodeId)
                    throws DatabaseException
Releases the lock from this locker, or if not owned by this locker then releases it from the buddy locker.

Overrides:
releaseLock in class Locker
Throws:
DatabaseException

createdNode

public boolean createdNode(long nodeId)
Forwards this method to the transactional buddy. Since the buddy handles write locks, it knows whether this transaction created the node.

Overrides:
createdNode in class BasicLocker
Returns:
true if this transaction created this node, for a operation with transactional semantics.

getAbortLsn

public long getAbortLsn(long nodeId)
Forwards this method to the transactional buddy. The buddy handles write locks and therefore handles abort information.

Overrides:
getAbortLsn in class BasicLocker
Returns:
the abort LSN for this node.

getWriteLockInfo

public WriteLockInfo getWriteLockInfo(long nodeId)
Overrides:
getWriteLockInfo in class BasicLocker
Returns:
the WriteLockInfo for this node.

addDeleteInfo

public void addDeleteInfo(BIN bin,
                          Key deletedKey)
Forwards this method to the transactional buddy. The buddy handles write locks and therefore handles delete information.

Overrides:
addDeleteInfo in class Locker

registerCursor

public void registerCursor(CursorImpl cursor)
Forwards this method to the transactional buddy. The buddy Txn tracks cursors.

Overrides:
registerCursor in class BasicLocker

unRegisterCursor

public void unRegisterCursor(CursorImpl cursor)
Forwards this method to the transactional buddy. The buddy Txn tracks cursors.

Overrides:
unRegisterCursor in class BasicLocker

lockingRequired

public boolean lockingRequired()
ReadCommittedLockers always require locking.

Overrides:
lockingRequired in class BasicLocker

isTransactional

public boolean isTransactional()
Is always transactional because the buddy locker is transactional.

Overrides:
isTransactional in class BasicLocker

isReadCommittedIsolation

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

Overrides:
isReadCommittedIsolation in class BasicLocker


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