コード例 #1
0
ファイル: LockManager.java プロジェクト: lzimm/qluster
  /** Do the real work of releaseAndFindNotifyTargets */
  Set<Locker> releaseAndFindNotifyTargetsInternal(long nodeId, Locker locker, int lockTableIndex) {
    Map<Long, Lock> lockTable = lockTables[lockTableIndex];
    Lock useLock = lockTable.get(nodeId);
    if (useLock == null) {
      useLock = lockTable.get(Long.valueOf(nodeId));
    }

    if (useLock == null) {
      /* Lock doesn't exist. */
      return null;
    }

    Set<Locker> lockersToNotify = useLock.release(locker, memoryBudget, lockTableIndex);
    if (lockersToNotify == null) {
      /* Not owner. */
      return null;
    }

    /* If it's not in use at all, remove it from the lock table. */
    if ((useLock.nWaiters() == 0) && (useLock.nOwners() == 0)) {
      lockTables[lockTableIndex].remove(nodeId);
      if (useLock.isThin()) {
        memoryBudget.updateLockMemoryUsage(REMOVE_TOTAL_THINLOCKIMPL_OVERHEAD, lockTableIndex);
      } else {
        memoryBudget.updateLockMemoryUsage(REMOVE_TOTAL_LOCKIMPL_OVERHEAD, lockTableIndex);
      }
    }

    return lockersToNotify;
  }
コード例 #2
0
ファイル: LockManager.java プロジェクト: lzimm/qluster
  /** Do the real work of dumpLockTableInternal. */
  void dumpLockTableInternal(StatGroup tableStats, int i, boolean clear) {
    StatGroup oneTable = new StatGroup("Single lock table", "Temporary stat group");

    IntStat totalLocks = new IntStat(oneTable, LOCK_TOTAL);
    IntStat waiters = new IntStat(oneTable, LOCK_WAITERS);
    IntStat owners = new IntStat(oneTable, LOCK_OWNERS);
    IntStat readLocks = new IntStat(oneTable, LOCK_READ_LOCKS);
    IntStat writeLocks = new IntStat(oneTable, LOCK_WRITE_LOCKS);

    Map<Long, Lock> lockTable = lockTables[i];
    totalLocks.add(lockTable.size());

    for (Lock lock : lockTable.values()) {
      waiters.add(lock.nWaiters());
      owners.add(lock.nOwners());

      /* Go through all the owners for a lock. */
      for (LockInfo info : lock.getOwnersClone()) {
        if (info.getLockType().isWriteLock()) {
          writeLocks.increment();
        } else {
          readLocks.increment();
        }
      }
    }
    tableStats.addAll(oneTable);
  }
コード例 #3
0
ファイル: LockManager.java プロジェクト: lzimm/qluster
  /** Do the real work of nWaiters. */
  int nWaitersInternal(Long nodeId, int lockTableIndex) {

    Map<Long, Lock> lockTable = lockTables[lockTableIndex];
    Lock entry = lockTable.get(nodeId);
    if (entry == null) {
      return -1;
    }

    return entry.nWaiters();
  }