com.sleepycat.je.dbi
Class CursorImpl

java.lang.Object
  extended by com.sleepycat.je.dbi.CursorImpl
All Implemented Interfaces:
Cloneable

public class CursorImpl
extends Object
implements Cloneable

A CursorImpl is the internal implementation of the cursor.


Nested Class Summary
static class CursorImpl.LockStanding
          Holds the result of a lockLN operation.
static class CursorImpl.SearchMode
           
static interface CursorImpl.WithCursor
          Callback object for traverseDbWithCursor.
 
Field Summary
static int EXACT_KEY
           
static int FOUND
           
static int FOUND_LAST
           
 
Constructor Summary
CursorImpl(DatabaseImpl database, Locker locker)
          Creates a cursor with retainNonTxnLocks=true.
CursorImpl(DatabaseImpl databaseImpl, Locker locker, boolean retainNonTxnLocks)
          Creates a cursor.
 
Method Summary
(package private)  void addCursor()
          Add to the current cursor.
(package private)  void addCursor(BIN bin)
           
 boolean advanceCursor(DatabaseEntry key, DatabaseEntry data)
          Advance a cursor.
 void checkCursorState(boolean mustBeInitialized)
          Check that the cursor is open and optionally if it is initialized.
 void checkEnv()
           
 void clearClosingLocker()
          Called when a cursor move operation is complete.
 CursorImpl cloneCursor(boolean addCursor, CacheMode cacheMode)
          Shallow copy.
 CursorImpl cloneCursor(boolean addCursor, CacheMode cacheMode, CursorImpl usePosition)
          Performs a shallow copy.
 void close()
           
 void close(CursorImpl newCursor)
          Close a cursor.
 void criticalEviction()
           
 OperationStatus delete(ReplicationContext repContext)
          Delete the item pointed to by the cursor.
 void dump()
          dump the cursor for debugging purposes.
 void dump(boolean verbose)
          Dump the cursor for debugging purposes.
 String dumpToString(boolean verbose)
           
 void dumpTree()
           
 CursorImpl dup(boolean samePosition)
          Return a new copy of the cursor.
 void evict()
          Evict the LN node at the cursor position.
 void evict(boolean alreadyLatched)
          Evict the LN node at the cursor position.
 BIN getBIN()
           
 BIN getBINToBeRemoved()
           
 CacheMode getCacheMode()
           
 OperationStatus getCurrent(DatabaseEntry foundKey, DatabaseEntry foundData, LockType lockType)
          Retrieve the current record.
 OperationStatus getCurrentAlreadyLatched(DatabaseEntry foundKey, DatabaseEntry foundData, LockType lockType)
          Retrieve the current record.
 byte[] getCurrentKey()
          Returns the key at the current position, regardless of whether the record is deleted.
 LN getCurrentLN(LockType lockType)
          Retrieve the current LN, return with the target bin unlatched.
 LN getCurrentLNAlreadyLatched(LockType lockType)
          Retrieve the current LN, assuming the BIN is already latched.
 RecordVersion getCurrentVersion(boolean allowFetch)
          Returns the VLSN and LSN for the record at the current position.
 int getIndex()
           
 Locker getLocker()
           
 StatGroup getLockStats()
           
 OperationStatus getNext(DatabaseEntry foundKey, DatabaseEntry foundData, LockType lockType, boolean forward, boolean alreadyLatched, RangeConstraint rangeConstraint)
          Move the cursor forward and return the next record.
 int hashCode()
           
 void incrementLNCount()
           
 boolean isClosed()
           
 boolean isInternalDbCursor()
           
 boolean isNotInitialized()
           
 BIN latchBIN()
           
static void lockAfterLsnChange(DatabaseImpl dbImpl, long oldLsn, long newLsn, Locker excludeLocker)
          After logging a deferred-write LN during eviction/checkpoint or a migrated LN during cleaning, for every existing lock on the old LSN held by another locker, we must lock the new LSN on behalf of that locker.
 boolean lockCurrent(LockType lockType)
           
 void lockEof(LockType lockType)
          Locks the logical EOF node for the databaseImpl.
 CursorImpl.LockStanding lockLN(LockType lockType)
          Does not allow uncontended locks.
 CursorImpl.LockStanding lockLN(LockType lockType, boolean allowUncontended)
          Locks the LN at the cursor position.
 void lockNextKeyForInsert(DatabaseEntry key)
          Search for the next key following the given key, and acquire a range insert lock on it.
 boolean positionFirstOrLast(boolean first)
          Position the cursor at the first or last record of the databaseImpl.
 OperationStatus put(DatabaseEntry key, DatabaseEntry data, LN ln, PutMode putMode, DatabaseEntry returnOldData, DatabaseEntry returnNewData, ReplicationContext repContext)
          Performs all put operations except for CURRENT (use putCurrent instead).
 OperationStatus putCurrent(byte[] key, DatabaseEntry data, DatabaseEntry foundKey, DatabaseEntry foundData, DatabaseEntry returnNewData, ReplicationContext repContext)
          Modify the current record with the given data, and optionally replace the key.
 OperationStatus putLN(byte[] key, LN ln, DatabaseEntry returnNewData, ReplicationContext repContext)
          Insert the given LN in the tree or return KEYEXIST if the key is already present.
 void releaseBIN()
           
 void reset()
          Reset a cursor to an uninitialized state, but unlike close(), allow it to be used further.
 int searchAndPosition(DatabaseEntry matchKey, CursorImpl.SearchMode searchMode, LockType lockType)
           
 int searchAndPosition(DatabaseEntry matchKey, CursorImpl.SearchMode searchMode, LockType lockType, Comparator<byte[]> searchComparator)
          Position the cursor at the key.
 void setAllowEviction(boolean allowed)
          Disables or enables eviction during cursor operations.
 void setBIN(BIN newBin)
           
 void setCacheMode(CacheMode mode)
          Sets the effective cache mode to use for the next operation.
 void setClosingLocker(CursorImpl closingCursor)
          Called when a cursor has been duplicated prior to being moved.
 void setIndex(int idx)
           
 void setTestHook(TestHook hook)
           
 void setTreeStatsAccumulator(TreeWalkerStatsAccumulator tSA)
           
 long skip(boolean forward, long maxCount, RangeConstraint rangeConstraint)
          Skips over entries until a boundary condition is satisfied, either because maxCount is reached or RangeConstraint.inBounds returns false.
static void traverseDbWithCursor(DatabaseImpl db, LockType lockType, boolean allowEviction, CursorImpl.WithCursor withCursor)
          Enumerates all records in a databaseImpl non-transactionally and calls the withCursor method for each record.
 void updateBin(int index)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOUND

public static final int FOUND
See Also:
Constant Field Values

EXACT_KEY

public static final int EXACT_KEY
See Also:
Constant Field Values

FOUND_LAST

public static final int FOUND_LAST
See Also:
Constant Field Values
Constructor Detail

CursorImpl

public CursorImpl(DatabaseImpl database,
                  Locker locker)
Creates a cursor with retainNonTxnLocks=true.


CursorImpl

public CursorImpl(DatabaseImpl databaseImpl,
                  Locker locker,
                  boolean retainNonTxnLocks)
Creates a cursor. A cursor always retains transactional locks when it is reset or closed. Non-transaction locks may be retained or not, depending on the retainNonTxnLocks parameter value. Normally a user-created non-transactional Cursor releases locks on reset and close, and a ThreadLocker is normally used. However, by passing true for retainNonTxnLocks a ThreadLocker can be made to retain locks; this capability is used by SecondaryCursor.readPrimaryAfterGet. For internal (non-user) cursors, a BasicLocker is often used and locks are retained. BasicLocker does not currently support releasing locks per cursor operation, so true must be passed for retainNonTxnLocks. In addition, in these internal use cases the caller explicitly calls BasicLocker.operationEnd, and retainNonTxnLocks is set to true to prevent operationEnd from being called when the cursor is closed. BasicLocker is also used for NameLN operations while opening a Database handle. Database handle locks must be retained, even if the Database is opened non-transactionally.

Parameters:
retainNonTxnLocks - is true if non-transactional locks should be retained (not released automatically) when the cursor is reset or closed.
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class Object

incrementLNCount

public void incrementLNCount()

setAllowEviction

public void setAllowEviction(boolean allowed)
Disables or enables eviction during cursor operations. For example, a cursor used to implement eviction (e.g., in some UtilizationProfile and most DbTree and VLSNIndex methods) should not itself perform eviction, but eviction should be enabled for user cursors. Eviction is disabled by default.


criticalEviction

public void criticalEviction()

cloneCursor

public CursorImpl cloneCursor(boolean addCursor,
                              CacheMode cacheMode)
                       throws DatabaseException
Shallow copy. addCursor() is optionally called.

Throws:
DatabaseException

cloneCursor

public CursorImpl cloneCursor(boolean addCursor,
                              CacheMode cacheMode,
                              CursorImpl usePosition)
                       throws DatabaseException
Performs a shallow copy.

Parameters:
addCursor - If true, addCursor() is called to register the new cursor with the BINs. This is done after the usePosition parameter is applied, if any. There are two cases where you may not want addCursor() to be called: 1) When creating a fresh uninitialized cursor as in when Cursor.dup(false) is called, or 2) when the caller will call addCursor() as part of a larger operation.
usePosition - Is null to duplicate the position of this cursor, or non-null to duplicate the position of the given cursor.
Throws:
DatabaseException

setClosingLocker

public void setClosingLocker(CursorImpl closingCursor)
Called when a cursor has been duplicated prior to being moved. The new locker is informed of the old locker, so that a preempted lock taken by the old locker can be ignored. [#16513]

Parameters:
closingCursor - the old cursor that will be closed if the new cursor is moved successfully.

clearClosingLocker

public void clearClosingLocker()
Called when a cursor move operation is complete. Clears the closingLocker so that a reference to the old closed locker is not held.


getIndex

public int getIndex()

setIndex

public void setIndex(int idx)

getBIN

public BIN getBIN()

setBIN

public void setBIN(BIN newBin)

getBINToBeRemoved

public BIN getBINToBeRemoved()

getCacheMode

public CacheMode getCacheMode()

setCacheMode

public void setCacheMode(CacheMode mode)
Sets the effective cache mode to use for the next operation. The cacheMode field will never be set to null or DYNAMIC, and can be passed directly to latching methods.

See Also:
performCacheEviction(com.sleepycat.je.dbi.CursorImpl)

setTreeStatsAccumulator

public void setTreeStatsAccumulator(TreeWalkerStatsAccumulator tSA)

advanceCursor

public boolean advanceCursor(DatabaseEntry key,
                             DatabaseEntry data)
Advance a cursor. Used so that verify can advance a cursor even in the face of an exception [12932].

Parameters:
key - on return contains the key if available, or null.
data - on return contains the data if available, or null.

latchBIN

public BIN latchBIN()
             throws DatabaseException
Throws:
DatabaseException

releaseBIN

public void releaseBIN()

getLocker

public Locker getLocker()

addCursor

void addCursor(BIN bin)

addCursor

void addCursor()
Add to the current cursor.


updateBin

public void updateBin(int index)
               throws DatabaseException
Throws:
DatabaseException

dumpTree

public void dumpTree()

isClosed

public boolean isClosed()
Returns:
true if this cursor is closed

isNotInitialized

public boolean isNotInitialized()
Returns:
true if this cursor is not initialized

isInternalDbCursor

public boolean isInternalDbCursor()

reset

public void reset()
           throws DatabaseException
Reset a cursor to an uninitialized state, but unlike close(), allow it to be used further.

Throws:
DatabaseException

close

public void close()
           throws DatabaseException
Throws:
DatabaseException

close

public void close(CursorImpl newCursor)
           throws DatabaseException
Close a cursor.

Parameters:
newCursor - is another cursor that is kept open by the parent Cursor object, or null if no other cursor is kept open.
Throws:
DatabaseException - if the cursor was previously closed.

dup

public CursorImpl dup(boolean samePosition)
               throws DatabaseException
Return a new copy of the cursor.

Parameters:
samePosition - If true, position the returned cursor at the same position as this cursor; if false, return a new uninitialized cursor.
Throws:
DatabaseException

evict

public void evict()
           throws DatabaseException
Evict the LN node at the cursor position.

Throws:
DatabaseException

evict

public void evict(boolean alreadyLatched)
           throws DatabaseException
Evict the LN node at the cursor position.

Throws:
DatabaseException

put

public OperationStatus put(DatabaseEntry key,
                           DatabaseEntry data,
                           LN ln,
                           PutMode putMode,
                           DatabaseEntry returnOldData,
                           DatabaseEntry returnNewData,
                           ReplicationContext repContext)
Performs all put operations except for CURRENT (use putCurrent instead).


putLN

public OperationStatus putLN(byte[] key,
                             LN ln,
                             DatabaseEntry returnNewData,
                             ReplicationContext repContext)
                      throws DatabaseException
Insert the given LN in the tree or return KEYEXIST if the key is already present.

This method is called directly internally for putting tree map LNs and file summary LNs. It should not be used otherwise, and in the future we should find a way to remove this special case.

Parameters:
returnNewData - if non-null, is used to return a complete copy of the resulting data after any partial data has been resolved.
Throws:
DatabaseException

putCurrent

public OperationStatus putCurrent(byte[] key,
                                  DatabaseEntry data,
                                  DatabaseEntry foundKey,
                                  DatabaseEntry foundData,
                                  DatabaseEntry returnNewData,
                                  ReplicationContext repContext)
Modify the current record with the given data, and optionally replace the key.

Parameters:
key - to overwrite, may be null. If non-null, must be previously determined to be equal to the current key, according to the comparator.
data - to overwrite, may be partial.
foundKey - if non-null, is used to return a copy of the existing key, may be partial.
foundData - if non-null, is used to return a copy of the existing data, may be partial.
returnNewData - if non-null, is used to return a complete copy of the resulting data after any partial data has been resolved.

delete

public OperationStatus delete(ReplicationContext repContext)
                       throws DatabaseException
Delete the item pointed to by the cursor. If cursor is not initialized or item is already deleted, return appropriate codes. Returns with nothing latched.

Returns:
0 on success, appropriate error code otherwise.
Throws:
DatabaseException

getCurrent

public OperationStatus getCurrent(DatabaseEntry foundKey,
                                  DatabaseEntry foundData,
                                  LockType lockType)
                           throws DatabaseException
Retrieve the current record.

Throws:
DatabaseException

getCurrentAlreadyLatched

public OperationStatus getCurrentAlreadyLatched(DatabaseEntry foundKey,
                                                DatabaseEntry foundData,
                                                LockType lockType)
                                         throws DatabaseException
Retrieve the current record. Assume the bin is already latched. Return with the target bin unlatched.

Throws:
DatabaseException

getCurrentLN

public LN getCurrentLN(LockType lockType)
                throws DatabaseException
Retrieve the current LN, return with the target bin unlatched.

Throws:
DatabaseException

getCurrentLNAlreadyLatched

public LN getCurrentLNAlreadyLatched(LockType lockType)
                              throws DatabaseException
Retrieve the current LN, assuming the BIN is already latched. Return with the target BIN unlatched.

Throws:
DatabaseException

getCurrentVersion

public RecordVersion getCurrentVersion(boolean allowFetch)
Returns the VLSN and LSN for the record at the current position. Must be called when the cursor is positioned on a record.

Parameters:
allowFetch - is true to fetch the LN to get the VLSN, or false to return -1 for the VLSN if both the LN and VLSN are not cached.

getNext

public OperationStatus getNext(DatabaseEntry foundKey,
                               DatabaseEntry foundData,
                               LockType lockType,
                               boolean forward,
                               boolean alreadyLatched,
                               RangeConstraint rangeConstraint)
                        throws DatabaseException
Move the cursor forward and return the next record. This will cross BIN boundaries.

Parameters:
foundKey - DatabaseEntry to use for returning key
foundData - DatabaseEntry to use for returning data
forward - if true, move forward, else move backwards
alreadyLatched - if true, the bin that we're on is already latched.
rangeConstraint - if non-null, is called to determine whether a key is out of range.
Returns:
the status.
Throws:
DatabaseException

skip

public long skip(boolean forward,
                 long maxCount,
                 RangeConstraint rangeConstraint)
Skips over entries until a boundary condition is satisfied, either because maxCount is reached or RangeConstraint.inBounds returns false. If a maxCount is passed, this allows advancing the cursor quickly by N entries. If a rangeConstraint is passed, this allows returning the entry count after advancing until the predicate returns false, e.g., the number of entries in a key range. In either case, the number of entries advanced is returned. Optimized to scan using level two of the tree when possible, to avoid calling getNextBin/getPrevBin for every BIN of the database. All BINs beneath a level two IN can be skipped quickly, with the level two parent IN latched, when all of its children BINs are resident and can be latched without waiting. When a child BIN is not resident or latching waits, we revert to the getNextBin/getPrevBin approach, to avoid keeping the parent IN latched for long time periods. Although this method positions the cursor on the last non-deleted entry seen (before the boundary condition is satisfied), because it does not lock the LN it is possible that it is deleted by another thread after the BIN is unlatched.

Parameters:
forward - is true to skip forward, false to skip backward.
maxCount - is the maximum number of non-deleted entries to skip, and may be LTE zero if no maximum is enforced.
rangeConstraint - is a predicate that returns false at a position where advancement should stop, or null if no predicate is enforced.
Returns:
the number of non-deleted entries that were skipped.

positionFirstOrLast

public boolean positionFirstOrLast(boolean first)
                            throws DatabaseException
Position the cursor at the first or last record of the databaseImpl. It's okay if this record is deleted. Returns with the target BIN latched!

Returns:
true if a first or last position is found, false if the tree being searched is empty.
Throws:
DatabaseException

searchAndPosition

public int searchAndPosition(DatabaseEntry matchKey,
                             CursorImpl.SearchMode searchMode,
                             LockType lockType)

searchAndPosition

public int searchAndPosition(DatabaseEntry matchKey,
                             CursorImpl.SearchMode searchMode,
                             LockType lockType,
                             Comparator<byte[]> searchComparator)
Position the cursor at the key. This returns a three part value that's bitwise or'ed into the int. We find out if there was any kind of match and if the match was exact. Note that this match focuses on whether the searching criteria (key, or key and data, depending on the search type) is met.

Note this returns with the BIN latched!

If this method returns without the FOUND bit set, the caller can assume that no match is possible. Otherwise, if the FOUND bit is set, the caller should check the EXACT_KEY bit. If EXACT_KEY is not set, an approximate match was found. In an approximate match, the cursor is always positioned before the target key/data. This allows the caller to perform a 'next' operation to advance to the value that is equal or higher than the target key/data.

Even if the search returns an exact result, the record may be deleted. The caller must therefore check for both an approximate match and for whether the cursor is positioned on a deleted record.

If SET is specified, the FOUND bit will only be returned if an exact match is found. However, the record found may be deleted.

There is one special case where this method may be called without checking the EXACT_KEY bit and without checking for a deleted record: If SearchMode.SET is specified then only the FOUND bit need be checked. When SET is specified and FOUND is returned, it is guaranteed to be an exact match on a non-deleted record. It is for this case only that this method is public.

If FOUND is set, FOUND_LAST may also be set if the cursor is positioned on the last record in the databaseImpl. Note that this state can only be counted on as long as the BIN is latched, so it is not set if this method must release the latch to lock the record. Therefore, it should only be used for optimizations. If FOUND_LAST is set, the cursor is positioned on the last record and the BIN is latched. If FOUND_LAST is not set, the cursor may or may not be positioned on the last record. Note that exact searches always perform an unlatch and a lock, so FOUND_LAST will only be set for inexact (range) searches.

Be aware that when an approximate match is returned, the index may be set to -1. This is done intentionally so that a 'next' operation will increment it.

Parameters:
searchMode - SearchMode.SET (position on a key EQ matchKey) or SearchMode.SET_RANGE (position on a key LTE matchKey).

getCurrentKey

public byte[] getCurrentKey()
Returns the key at the current position, regardless of whether the record is deleted. Does not lock. The key returned is not a copy and may not be returned directly to the user without copying it first. Returns null if the cursor is not initialized.


lockNextKeyForInsert

public void lockNextKeyForInsert(DatabaseEntry key)
                          throws DatabaseException
Search for the next key following the given key, and acquire a range insert lock on it. If there are no more records following the given key, lock the special EOF node for the databaseImpl.

Throws:
DatabaseException

lockLN

public CursorImpl.LockStanding lockLN(LockType lockType)
                               throws LockConflictException
Does not allow uncontended locks. See lockLN(LockType).

Throws:
LockConflictException

lockLN

public CursorImpl.LockStanding lockLN(LockType lockType,
                                      boolean allowUncontended)
                               throws LockConflictException
Locks the LN at the cursor position. Attempts to use a non-blocking lock to avoid unlatching/relatching. Retries if necessary, to handle the case where the LSN is changed while the BIN is unlatched. Because it re-latches the BIN to check the LSN, this serializes access to the LSN for locking, guaranteeing that two lockers cannot obtain conflicting locks on the old and new LSNs. Preconditions: The BIN must be latched. Postconditions: The BIN is latched. LN Locking Rules ---------------- The lock ID for an LN is its LSN in the parent BIN slot. Because the LSN changes when logging the LN, only two methods of locking an LN may be used to support concurrent access: 1. This method may be called to lock the old LSN. For read operations, that is all that is necessary. For write operations, the new LSN must be locked after logging it, which is done by all the LN logging methods. Be sure to pass a non-null locker to the LN logging method to lock the LN, unless locking is not desired. 2. A non-blocking lock may be obtained on the old LSN (using Locker.nonBlockingLock rather than this method), as long as the lock is released before the BIN latch is released. In this case a non-null locker is not passed to the LN logging method; locking the new LSN is unnecessary because no other thread can access the new LSN until the BIN latch is released. The first method is used for all user operations. The second method is used by the cleaner, when flushing dirty deferred-write LNs, and by certain btree operations. Uncontended Lock Optimization ----------------------------- The allowUncontended param is passed as true for update and delete operations as an optimization for the case where no lock on the old LSN is held by any locker. In this case we don't need to lock the old LSN at all, as long as we log the new LSN before releasing the BIN latch. 1. Latch BIN 2. Determine that no lock/waiter exists for oldLsn 3. Log LN and get newLsn 4. Lock newLsn 5. Update BIN 6. Release BIN latch The oldLsn is never locked, saving operations on the lock table. The assumption is that another locker will first have to latch the BIN to get oldLsn, before requesting a lock. A potential problem is that the other locker may release the BIN latch before requesting the lock. This Operation Another Operation -------------- ----------------- Latch BIN, get oldLsn, release BIN latch Step 1 and 2 Request lock for oldLsn, granted Step 3 and 4 Both operations now believe they have an exclusive lock, but they have locks on different LSNs. However, this problem is handled as long as the other lock is performed using a lockLN method in this class, which will release the lock and retry if the LSN changes while acquiring the lock. Because it re-latches the BIN to check the LSN, this will serialize access to the LSN for locking, guaranteeing that two conflicting locks cannot be granted on the old and new LSNs. Deferred-Write Locking ---------------------- When one of the LN optionalLog methods is called, a deferred-write LN is dirtied but not actually logged. In order to lock an LN that has been inserted but not yet assigned a true LSN, a transient LSNs is assigned. These LSNs serve to lock the LN but never appear in the log. See LN.assignTransientLsn. A deferred-write LN is logged when its parent BIN is logged, or when the LN is evicted. This will replace transient LSNs with durable LSNs. If a lock is held by a cursor on a deferred-write LN when it is logged, the same lock is acquired on the new LSN by the cursor. See lockAfterLsnChange. Cleaner Migration Locking ------------------------- The cleaner takes a non-blocking read lock on the old LSN before migrating/logging the LN, while holding the BIN latch. It does not take a lock on the new LSN, since it does not need to retain a lock after releasing the BIN latch. Because a read, not write, lock is taken, other read locks may be held during migration. After logging, the cleaner calls lockAfterLsnChange to lock the new LSN on behalf of other lockers. For more info on migration locking, see HandleLocker. Historical Notes ---------------- In JE 4.1 and earlier, each LN had a node ID that was used for locking, rather than using the LSN. The node ID changed only if a deleted slot was reused. The node ID was stored in the LN, requiring that the LN be fetched when locking the LN. With LSN locking a fetch is not needed. When LN node IDs were used, deferred-write LNs were not assigned an LSN until they were actually logged. Deferred-write LNs were initially assigned a null LSN and transient LSNs were not needed.

Parameters:
lockType - the type of lock requested.
allowUncontended - is true to return immediately (no lock is taken) when no locker holds or waits for the lock.
Returns:
all information about the lock; see LockStanding.
Throws:
LockConflictException - if the lsn is non-null, the lock is contended, and a lock could not be obtained by blocking.

lockCurrent

public boolean lockCurrent(LockType lockType)

lockAfterLsnChange

public static void lockAfterLsnChange(DatabaseImpl dbImpl,
                                      long oldLsn,
                                      long newLsn,
                                      Locker excludeLocker)
After logging a deferred-write LN during eviction/checkpoint or a migrated LN during cleaning, for every existing lock on the old LSN held by another locker, we must lock the new LSN on behalf of that locker. This is done while holding the BIN latch so that the new LSN does not change during the locking process. The BIN must be latched on entry and is left latched by this method. We release the lock on the oldLsn to prevent locks from accumulating over time on a HandleLocker, as the cleaner migrates LNs, because Database handle locks are legitmately very long-lived. It is important to first acquire all newLsn locks and then release the oldLsn locks. Releasing an oldLsn lock might allow another locker to acquire it, and then acquiring another newLsn lock may encounter a conflict. [#20617]

See Also:
HandleLocker, lockLN(com.sleepycat.je.txn.LockType)

checkCursorState

public void checkCursorState(boolean mustBeInitialized)
Check that the cursor is open and optionally if it is initialized.

Throws:
IllegalStateException - via all Cursor methods that call Cursor.checkState (all get and put methods, plus more).

lockEof

public void lockEof(LockType lockType)
             throws DatabaseException
Locks the logical EOF node for the databaseImpl.

Throws:
DatabaseException

checkEnv

public void checkEnv()
Throws:
EnvironmentFailureException - if the underlying environment is invalid.

traverseDbWithCursor

public static void traverseDbWithCursor(DatabaseImpl db,
                                        LockType lockType,
                                        boolean allowEviction,
                                        CursorImpl.WithCursor withCursor)
                                 throws DatabaseException
Enumerates all records in a databaseImpl non-transactionally and calls the withCursor method for each record. Stops the enumeration if the callback returns false.

Parameters:
db - DatabaseImpl to traverse.
lockType - non-null LockType for reading records.
allowEviction - should normally be true to evict when performing multiple operations, but may be false if eviction is disallowed in a particular context.
withCursor - callback object.
Throws:
DatabaseException

dump

public void dump(boolean verbose)
Dump the cursor for debugging purposes. Dump the bin that the cursor refers to if verbose is true.


dump

public void dump()
dump the cursor for debugging purposes.


dumpToString

public String dumpToString(boolean verbose)

getLockStats

public StatGroup getLockStats()
                       throws DatabaseException
Throws:
DatabaseException

setTestHook

public void setTestHook(TestHook hook)


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