com.sleepycat.je.txn
Class BuddyLocker

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

public class BuddyLocker
extends BasicLocker

Extends BasicLocker to share locks with another specific locker.

In general, a BuddyLocker can be used whenever the primary (API) locker is in use, and we need to lock a node and release that lock before the primary locker transaction ends. In other words, for this particular lock we don't want to use two-phase locking. To accomplish that we use a separate BuddyLocker instance to hold the lock, while sharing locks with the primary locker. The BuddyLocker can be closed to release this particular lock, without releasing the other locks held by the primary locker.

In particular, a BuddyLocker is used when acquiring a RANGE_INSERT lock. RANGE_INSERT only needs to be held until the point we have inserted the new node into the BIN. A separate locker is therefore used so we can release that lock separately when the insertion into the BIN is complete. But the RANGE_INSERT lock must not conflict with locks held by the primary locker. So a BuddyLocker is used that shares locks with the primary locker.


Field Summary
 
Fields inherited from class com.sleepycat.je.txn.Locker
defaultNoWait, deleteInfo, envImpl, handleLockToHandleMap, handleToHandleLockMap, id, lockManager, lockTimeOutMillis, readUncommittedDefault, thread
 
Constructor Summary
BuddyLocker(EnvironmentImpl env, Locker buddy)
          Creates a BuddyLocker.
 
Method Summary
(package private)  Locker getBuddy()
          Returns the buddy locker.
 Txn getTxnLocker()
          Forwards this call to the buddy locker.
 Locker newNonTxnLocker()
          Creates a new instance of this txn for the same environment.
 void releaseNonTxnLocks()
          Forwards this call to the base class and to the buddy locker.
 boolean sharesLocksWith(Locker other)
          Returns whether this locker can share locks with the given locker.
 
Methods inherited from class com.sleepycat.je.txn.BasicLocker
addLock, checkState, collectStats, createdNode, generateId, getAbortKnownDeleted, getAbortLsn, getOwnerAbortLsn, getWriteOwnerLocker, isReadCommittedIsolation, isSerializableIsolation, isTransactional, lock, markDeleteAtTxnEnd, moveWriteToReadLock, nonBlockingReadLock, operationEnd, operationEnd, registerCursor, removeLock, setHandleLockOwner, unRegisterCursor
 
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, toString, transferHandleLock, transferHandleLockToHandle, unregisterHandle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BuddyLocker

public BuddyLocker(EnvironmentImpl env,
                   Locker buddy)
            throws DatabaseException
Creates a BuddyLocker.

Throws:
DatabaseException
Method Detail

getBuddy

Locker getBuddy()
Returns the buddy locker.


getTxnLocker

public Txn getTxnLocker()
Forwards this call to the buddy locker.

Overrides:
getTxnLocker in class BasicLocker

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. newNonTxnLocker is also called for the BuddyLocker.

Overrides:
newNonTxnLocker in class BasicLocker
Throws:
DatabaseException

releaseNonTxnLocks

public void releaseNonTxnLocks()
                        throws DatabaseException
Forwards this call to the base class and to the buddy locker.

Overrides:
releaseNonTxnLocks in class BasicLocker
Throws:
DatabaseException

sharesLocksWith

public boolean sharesLocksWith(Locker other)
Returns whether this locker can share locks with the given locker.

Overrides:
sharesLocksWith in class Locker


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