code: public void validate() {
      synchronized (mSharedMapsLock) {
        // Compute block lock reference counts based off of lock records
        ConcurrentMap<Long, AtomicInteger> blockLockReferenceCounts = new ConcurrentHashMap<>();
        for (LockRecord record : mLockIdToRecordMap.values()) {
          blockLockReferenceCounts.putIfAbsent(record.getBlockId(), new AtomicInteger(0));
          blockLockReferenceCounts.get(record.getBlockId()).incrementAndGet();
        }
  
        // Check that the reference count for each block lock matches the lock record counts.
        for (Entry<Long, ClientRWLock> entry : mLocks.entrySet()) {
          long blockId = entry.getKey();
          ClientRWLock lock = entry.getValue();
          Integer recordCount = blockLockReferenceCounts.get(blockId).get();
          Integer referenceCount = lock.getReferenceCount();
          if (!Objects.equal(recordCount, referenceCount)) {
            throw new IllegalStateException("There are " + recordCount + " lock records for block"
                + " id " + blockId + ", but the reference count is " + referenceCount);
          }
        }
  
        // Check that if a lock id is mapped to by a session id, the lock record for that lock id
        // contains that session id.
        for (Entry<Long, Set<Long>> entry : mSessionIdToLockIdsMap.entrySet()) {
          for (Long lockId : entry.getValue()) {
            LockRecord record = mLockIdToRecordMap.get(lockId);
            if (record.getSessionId() != entry.getKey()) {
              throw new IllegalStateException("The session id map contains lock id " + lockId
                  + "under session id " + entry.getKey() + ", but the record for that lock id ("
                  + record + ")" + " doesn't contain that session id");
            }
          }
        }
      }
    }
docs: Checks the internal state of the manager to make sure invariants hold.
  
  This method is intended for testing purposes. A runtime exception will be thrown if invalid
  state is encountered.