Ejemplo n.º 1
0
  protected LockAttemptResult stealLockInternal(
      Long nodeId, Locker locker, LockType lockType, MemoryBudget mb, int lockTableIndex)
      throws DatabaseException {

    Lock entry = lockTables[lockTableIndex].get(nodeId);
    assert entry != null;

    /*
     * Note that flushWaiter may do nothing, because the lock may have been
     * granted to our locker after the prior call to attemptLock and before
     * the call to this method.
     */
    entry.flushWaiter(locker, mb, lockTableIndex);

    /* Remove all owners except for our owner. */
    entry.stealLock(locker, mb, lockTableIndex);

    /*
     * The lock attempt normally succeeds, but can fail if the lock holder
     * is non-preemptable.
     */
    return attemptLockInternal(
        nodeId, locker, lockType, false /*nonBlockingRequest*/, lockTableIndex);
  }