* @return the LockResult containing the LN that was locked.
*/
public LockResult lockDupCountLN(DIN dupRoot, LockType lockType)
throws DatabaseException {
DupCountLN ln = dupRoot.getDupCountLN();
LockResult lockResult;
/*
* Try a non-blocking lock first, to avoid unlatching. If the default
* is no-wait, use the standard lock method so
* LockNotAvailableException is thrown; there is no need to try a
* non-blocking lock twice.
*/
if (locker.getDefaultNoWait()) {
try {
lockResult = locker.lock
(ln.getNodeId(), lockType, true /*noWait*/, databaseImpl);
} catch (LockConflictException e) {
/*
* Release all latches. Note that we catch
* LockConflictException for simplicity but we expect either
* LockNotAvailableException or LockNotGrantedException.
*/
dupRoot.releaseLatch();
releaseBINs();
throw e;
}
} else {
lockResult = locker.nonBlockingLock
(ln.getNodeId(), lockType, databaseImpl);
}
if (lockResult.getLockGrant() == LockGrantType.DENIED) {
/* Release all latches. */
dupRoot.releaseLatch();
releaseBINs();
/* Request a blocking lock. */
lockResult = locker.lock
(ln.getNodeId(), lockType, false /*noWait*/, databaseImpl);
/* Reacquire all latches. */
latchBIN();
dupRoot = (DIN) bin.fetchTarget(index);
dupRoot.latch(cacheMode);
latchDBIN();