Ejemplo n.º 1
0
  /*
   * Do the real work of validateOwnershipInternal.
   */
  boolean validateOwnershipInternal(
      Long nodeId,
      Locker locker,
      LockType type,
      boolean flushFromWaiters,
      MemoryBudget mb,
      int lockTableIndex) {
    if (isOwnerInternal(nodeId, locker, type, lockTableIndex)) {
      return true;
    }

    if (flushFromWaiters) {
      Lock entry = lockTables[lockTableIndex].get(nodeId);
      if (entry != null) {
        entry.flushWaiter(locker, mb, lockTableIndex);
      }
    }
    return false;
  }
Ejemplo n.º 2
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);
  }