Package org.infinispan.lucene.readlocks
Class LocalLockMergingSegmentReadLocker
- java.lang.Object
-
- org.infinispan.lucene.readlocks.LocalLockMergingSegmentReadLocker
-
- All Implemented Interfaces:
SegmentReadLocker
public class LocalLockMergingSegmentReadLocker extends Object implements SegmentReadLocker
LocalLockMergingSegmentReadLocker decorates theDistributedSegmentReadLockerto minimize remote operations in case several IndexReaders are opened on the same Infinispan basedDirectory. It keeps track of locks which where already acquired for a specific filename from another request on the same node and merges the request so that the different clients share the same remote lock.- Since:
- 4.1
- Author:
- Sanne Grinovero
-
-
Constructor Summary
Constructors Constructor Description LocalLockMergingSegmentReadLocker(Cache<?,?> cache, String indexName, int affinitySegmentId)Create a new LocalLockMergingSegmentReadLocker for specified cache and index name.LocalLockMergingSegmentReadLocker(Cache<?,?> locksCache, Cache<?,?> chunksCache, Cache<?,?> metadataCache, String indexName, boolean forceSynchronousDeletes, int affinitySegmentId)LocalLockMergingSegmentReadLocker(Cache<?,?> locksCache, Cache<?,?> chunksCache, Cache<?,?> metadataCache, String indexName, int affinitySegmentId)Create a new LocalLockMergingSegmentReadLocker with special purpose caches
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacquireReadLock(String name)Acquires a readlock, in order to prevent other invocations toSegmentReadLocker.deleteOrReleaseReadLock(String)from deleting the file.voiddeleteOrReleaseReadLock(String name)It will release a previously acquired readLock, or if no readLock was acquired it will mark the file to be deleted as soon as all pending locks are releases.
-
-
-
Constructor Detail
-
LocalLockMergingSegmentReadLocker
public LocalLockMergingSegmentReadLocker(Cache<?,?> cache, String indexName, int affinitySegmentId)
Create a new LocalLockMergingSegmentReadLocker for specified cache and index name.- Parameters:
cache-indexName-
-
LocalLockMergingSegmentReadLocker
public LocalLockMergingSegmentReadLocker(Cache<?,?> locksCache, Cache<?,?> chunksCache, Cache<?,?> metadataCache, String indexName, int affinitySegmentId)
Create a new LocalLockMergingSegmentReadLocker with special purpose caches- Parameters:
locksCache- the cache to be used to store distributed lockschunksCache- the cache containing the chunks, this is where the bulk of data is storedmetadataCache- smaller cache for the metadata of stored elementsindexName-
-
-
Method Detail
-
acquireReadLock
public boolean acquireReadLock(String name)
Acquires a readlock, in order to prevent other invocations toSegmentReadLocker.deleteOrReleaseReadLock(String)from deleting the file.- Specified by:
acquireReadLockin interfaceSegmentReadLocker- Parameters:
name- of the file to acquire the lock at- Returns:
- true if the lock was acquired, false if the implementation detects the file does not exist, or that it's being deleted by some other thread.
- See Also:
Directory.openInput(java.lang.String, org.apache.lucene.store.IOContext)
-
deleteOrReleaseReadLock
public void deleteOrReleaseReadLock(String name)
It will release a previously acquired readLock, or if no readLock was acquired it will mark the file to be deleted as soon as all pending locks are releases. If it's invoked on a file without pending locks the file is deleted.- Specified by:
deleteOrReleaseReadLockin interfaceSegmentReadLocker- Parameters:
name- of the file to release or delete- See Also:
Directory.deleteFile(String)
-
-