コード例 #1
0
ファイル: LockManager.java プロジェクト: lzimm/qluster
  /*
   * 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;
  }
コード例 #2
0
ファイル: LockManager.java プロジェクト: lzimm/qluster
  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);
  }