Package org.infinispan.lucene.readlocks
Class DistributedSegmentReadLocker
- java.lang.Object
-
- org.infinispan.lucene.readlocks.DistributedSegmentReadLocker
-
- All Implemented Interfaces:
SegmentReadLocker
public class DistributedSegmentReadLocker extends Object implements SegmentReadLocker
DistributedSegmentReadLocker stores reference counters in the cache to keep track of the number of clients still needing to be able to read a segment. It makes extensive usage of Infinispan's atomic operations.
Locks stored this way are not optimally performing as it might spin on remote invocations, and might fail to cleanup some garbage in case a node is disconnected without having released the readlock.
- Since:
- 4.1
- Author:
- Sanne Grinovero
-
-
Constructor Summary
Constructors Constructor Description DistributedSegmentReadLocker(Cache<?,?> cache, String indexName, int affinitySegmentId)
DistributedSegmentReadLocker(Cache<Object,Integer> locksCache, Cache<?,?> chunksCache, Cache<?,?> metadataCache, String indexName, int affinitySegmentId)
DistributedSegmentReadLocker(Cache<Object,Integer> locksCache, Cache<?,?> chunksCache, Cache<?,?> metadataCache, String indexName, int affinitySegmentId, boolean forceSynchronousDeletes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acquireReadLock(String filename)
Acquires a readlock on all chunks for this file, to make sure chunks are not deleted while iterating on the group.void
deleteOrReleaseReadLock(String filename)
Deletes or releases a read-lock for the specified filename, so that if it was marked as deleted and no otherInfinispanIndexInput
instances are reading from it, then it will be effectively deleted.
-
-
-
Constructor Detail
-
DistributedSegmentReadLocker
public DistributedSegmentReadLocker(Cache<Object,Integer> locksCache, Cache<?,?> chunksCache, Cache<?,?> metadataCache, String indexName, int affinitySegmentId)
-
DistributedSegmentReadLocker
public DistributedSegmentReadLocker(Cache<Object,Integer> locksCache, Cache<?,?> chunksCache, Cache<?,?> metadataCache, String indexName, int affinitySegmentId, boolean forceSynchronousDeletes)
-
-
Method Detail
-
deleteOrReleaseReadLock
public void deleteOrReleaseReadLock(String filename)
Deletes or releases a read-lock for the specified filename, so that if it was marked as deleted and no otherInfinispanIndexInput
instances are reading from it, then it will be effectively deleted.- Specified by:
deleteOrReleaseReadLock
in interfaceSegmentReadLocker
- Parameters:
filename
- of the file to release or delete- See Also:
acquireReadLock(String)
,Directory.deleteFile(String)
-
acquireReadLock
public boolean acquireReadLock(String filename)
Acquires a readlock on all chunks for this file, to make sure chunks are not deleted while iterating on the group. This is needed to avoid an eager lock on all elements. If no value is found in the cache, a disambiguation procedure is needed: not value might mean both "existing, no readlocks, no deletions in progress", but also "not existent file". The first possibility is coded as no value to avoid storing readlocks in a permanent store, which would unnecessarily slow down and provide unwanted long term storage of the lock; so the value is treated as one if not found, but obviously it's also not found for non-existent or concurrently deleted files.- Specified by:
acquireReadLock
in interfaceSegmentReadLocker
- Parameters:
filename
- the name of the "file" for which a readlock is requested- 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:
deleteOrReleaseReadLock(String)
-
-