boolean hasWaiters() { return latch.hasQueuedThreads(); }
if(lock.hasQueuedThreads()){
public void run() { final HashLockManager<T> mgr = ref.get(); if (mgr == null) { // if the corresponding HashLockManager was garbage collected we can cancel the scheduled execution of cleanup task future.cancel(true); return; } try { for (final Iterator<Entry<T, ReentrantReadWriteLock>> it = mgr.locksByKey.entrySet().iterator(); it.hasNext();) { final ReentrantReadWriteLock lock = it.next().getValue(); synchronized (lock) { // exclusive access to the lock object final boolean isLockInUse = lock.isWriteLocked() || lock.getReadLockCount() > 0 || lock.hasQueuedThreads(); if (!isLockInUse) { it.remove(); } } } } catch (final Exception ex) { LOG.error(ex, "Unexpected exception occured while cleaning lock objects."); } } }
assertFalse(nn1.getNamesystem().getFsLockForTests().hasQueuedThreads()); assertFalse(nn1.getNamesystem().getFsLockForTests().isWriteLocked()); assertTrue(nn1.getNamesystem().getCpLockForTests().hasQueuedThreads());