private boolean isAlreadyBeingIndexed( String repositoryId ) { Lock lock = getLock( repositoryId ).readLock(); boolean locked = true; try { locked = lock.tryLock(); // if I can't get a read lock means someone else has the write lock (index tasks do write lock) return !locked; } finally { if ( locked ) { lock.unlock(); } } }
private ReadWriteLock getLock( Repository repository ) { return getLock( repository.getId() ); }
public void removeRepositoryIndexContext( String repositoryId, boolean deleteFiles ) throws IOException, NoSuchRepositoryException { Repository repository = repositoryRegistry.getRepository( repositoryId ); Lock lock = getLock( repository ).writeLock(); lock.lock(); try { if ( !isIndexingSupported( repository ) ) { logSkippingRepositoryMessage( repository ); return; } IndexingContext localCtx = getRepositoryLocalIndexContext( repository ); IndexingContext remoteCtx = getRepositoryRemoteIndexContext( repository ); if ( localCtx != null ) { nexusIndexer.removeIndexingContext( localCtx, deleteFiles ); } if ( remoteCtx != null ) { nexusIndexer.removeIndexingContext( remoteCtx, deleteFiles ); } } finally { lock.unlock(); } }
lock = getLock( repositoryId ).readLock(); lock.lock();
lock = getLock( repositoryId ).readLock(); lock.lock();
Lock lock = getLock( repository ).writeLock(); lock.lock();
lock = getLock( repositoryId ).readLock(); lock.lock();
lock = getLock( repositoryId ).readLock(); lock.lock();
lock = getLock( repositoryId ).readLock(); lock.lock();
lock = getLock( repositoryId ).readLock(); lock.lock();
lock = getLock( repositoryId ).readLock(); lock.lock();
Lock lock = getLock( repository.getId() ).writeLock(); lock.lock();
Lock lock = getLock( groupId ).writeLock(); lock.lock(); try
IndexingContext mergedContext = null; Lock lock = getLock( repository.getId() ).readLock(); lock.lock();
Lock lock = getLock( repository ).writeLock(); lock.lock();
Lock lock = getLock( repository.getId() ).writeLock(); lock.lock();