예제 #1
0
  /** Do the real work of transfer */
  void transferInternal(
      long nodeId, Locker owningLocker, Locker destLocker, boolean demoteToRead, int lockTableIndex)
      throws DatabaseException {

    Map<Long, Lock> lockTable = lockTables[lockTableIndex];
    Lock useLock = lockTable.get(Long.valueOf(nodeId));

    assert useLock != null : "Transfer, lock " + nodeId + " was null";
    if (demoteToRead) {
      useLock.demote(owningLocker);
    }
    Lock newLock = useLock.transfer(nodeId, owningLocker, destLocker, memoryBudget, lockTableIndex);
    if (newLock != useLock) {
      /* The lock mutated from ThinLockImpl to LockImpl. */
      lockTable.put(nodeId, newLock);
      /* We still have the overhead of the hashtable (locktable). */
      memoryBudget.updateLockMemoryUsage(THINLOCK_MUTATE_OVERHEAD, lockTableIndex);
    }
    owningLocker.removeLock(nodeId);
  }
예제 #2
0
 /** Do the real work of demote. */
 void demoteInternal(long nodeId, Locker locker, int lockTableIndex) {
   Map<Long, Lock> lockTable = lockTables[lockTableIndex];
   Lock useLock = lockTable.get(Long.valueOf(nodeId));
   useLock.demote(locker);
   locker.moveWriteToReadLock(nodeId, useLock);
 }