int (final ReadWriteLock lock) { if (!(lock instanceof ReentrantReadWriteLock)) { throw new IllegalStateException("index.lock (" + lock + ") is not ReentrantReadWriteLock -- can't sample queue length"); } //RC: worth to add StorageLockContext.defaultContextLock().getQueueLength() into // the equation: if storages are intensively used outside of indexes, it is better to // keep hands off the indexes flush also -- since the index flush will also compete for the // storage lock final int storageLockQueueLength = StorageLockContext.defaultContextLock().getQueueLength(); return ((ReentrantReadWriteLock)lock).getQueueLength() + storageLockQueueLength; }