@VisibleForTesting public void waitForWaiters(T id, int numWaiters) throws InterruptedException { for (ReentrantReadWriteLock readWriteLock;;) { readWriteLock = lockPool.get(id); if (readWriteLock != null) { synchronized (readWriteLock) { if (readWriteLock.getQueueLength() >= numWaiters) { return; } } } Thread.sleep(50); } }
/** * Returns the QueueLength of waiting threads. * * A larger number indicates greater lock contention. * * @return int - Number of threads waiting on this lock */ public int getQueueLength() { return coarseLock.getQueueLength(); }
/** * @return true if the lock was acquired * @since 0.8.11 moved from DecayingHashSet */ protected boolean getWriteLock() { try { boolean rv = _reorganizeLock.writeLock().tryLock(5000, TimeUnit.MILLISECONDS); if (!rv) _log.error("no lock, size is: " + _reorganizeLock.getQueueLength(), new Exception("rats")); return rv; } catch (InterruptedException ie) {} return false; }
/** @return true if the lock was acquired */ private boolean getWriteLock() { try { boolean rv = _fileLock.writeLock().tryLock(10000, TimeUnit.MILLISECONDS); if ((!rv) && _log.shouldLog(Log.WARN)) _log.warn("no lock, size is: " + _fileLock.getQueueLength(), new Exception("rats")); return rv; } catch (InterruptedException ie) {} return false; }
/** @return true if the lock was acquired */ private boolean getWriteLock() { try { boolean rv = _reorganizeLock.writeLock().tryLock(3000, TimeUnit.MILLISECONDS); if ((!rv) && _log.shouldLog(Log.WARN)) _log.warn("no lock, size is: " + _reorganizeLock.getQueueLength(), new Exception("rats")); return rv; } catch (InterruptedException ie) {} return false; }
/** @return true if the lock was acquired */ private boolean getWriteLock() { try { boolean rv = _bucketsLock.writeLock().tryLock(3000, TimeUnit.MILLISECONDS); if ((!rv) && _log.shouldLog(Log.WARN)) _log.warn("no lock, size is: " + _bucketsLock.getQueueLength(), new Exception("rats")); return rv; } catch (InterruptedException ie) {} return false; }
/** * Returns the QueueLength of waiting threads. * * A larger number indicates greater lock contention. * * @return int - Number of threads waiting on this lock */ public int getQueueLength() { return coarseLock.getQueueLength(); }
/** * Returns the QueueLength of waiting threads. * * A larger number indicates greater lock contention. * * @return int - Number of threads waiting on this lock */ public int getQueueLength() { return coarseLock.getQueueLength(); }
private String getFacetLockStatus() { StringBuilder str = new StringBuilder("Facet lock status for ["); str.append(getResource()); str.append("], is-write-locked=[").append(facetAccessLock.isWriteLocked()); str.append("], is-write-locked-by-current-thread=[").append(facetAccessLock.isWriteLockedByCurrentThread()); str.append("], read-locks=[").append(facetAccessLock.getReadLockCount()); str.append("], waiting-for-lock-queue-size=[").append(facetAccessLock.getQueueLength()); str.append("]"); return str.toString(); }
@VisibleForTesting public void waitForWaiters(long id, int numWaiters) throws InterruptedException { for (ReentrantReadWriteLock readWriteLock;;) { readWriteLock = lockPool.get(id); if (readWriteLock != null) { synchronized (readWriteLock) { if (readWriteLock.getQueueLength() >= numWaiters) { return; } } } Thread.sleep(50); } } }
private String status() { return " read locks:" + rwlock.getReadLockCount() + " writeLocks:" + rwlock.getWriteHoldCount() + " waiting:" + rwlock.getQueueLength() +"\n"; }
ReentrantReadWriteLock lock = CONCURRENT_HASH_MAP.get(employee.getId()); System.out.println("lock object " + lock + "queue length " + lock.getQueueLength());
/** * Returns module info describing the current state of the module. * * @param inInitiatedFlows the set of IDs for the data flows that this * module has initiated * @param inParticipatingFlows the set of IDs for the data flows that this * module is participating in. * * @return the module info. */ final ModuleInfo getModuleInfo(DataFlowID[] inInitiatedFlows, DataFlowID[] inParticipatingFlows) { return new ModuleInfo(getURN(), getState(), inInitiatedFlows, inParticipatingFlows, getCreated(), getStarted(), getStopped(), isAutoStart(), isAutoCreated(), this instanceof DataReceiver, this instanceof DataEmitter, this instanceof DataFlowRequester, getLastStartFailure(), getLastStopFailure(), mLock.getReadLockCount(), mLock.isWriteLocked(), mLock.getQueueLength()); }