com.sleepycat.je.txn
Class BuddyLocker

java.lang.Object
  extended bycom.sleepycat.je.txn.Locker
      extended bycom.sleepycat.je.txn.BasicLocker
          extended bycom.sleepycat.je.txn.BuddyLocker

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, dirtyReadDefault, envImpl, handleLockToHandleMap, handleToHandleLockMap, id, lockManager, lockTimeOutMillis, thread
 
Constructor Summary
BuddyLocker(EnvironmentImpl env, Locker buddy)
          Creates a BuddyLocker.
 
Method Summary
(package private)  Locker getBuddy()
          Returns the buddy locker.
 Locker newInstance()
          Creates a new instance of this locker for the same environment.
 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, 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, isDirtyReadDefault, isHandleLockTransferrable, 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.

Method Detail

getBuddy

Locker getBuddy()
Returns the buddy locker.


newInstance

public Locker newInstance()
                   throws DatabaseException
Creates a new instance of this locker for the same environment.

Overrides:
newInstance 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 Sleepycat, Inc. All Rights Reserved.