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.
Constructor and Description |
---|
DistributedSegmentReadLocker(Cache<?,?> cache,
String indexName) |
DistributedSegmentReadLocker(Cache<Object,Integer> locksCache,
Cache<?,?> chunksCache,
Cache<?,?> metadataCache,
String indexName) |
Modifier and Type | Method and 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 other
InfinispanIndexInput instances are reading from it, then it will
be effectively deleted. |
public DistributedSegmentReadLocker(Cache<Object,Integer> locksCache, Cache<?,?> chunksCache, Cache<?,?> metadataCache, String indexName)
public void deleteOrReleaseReadLock(String filename)
InfinispanIndexInput
instances are reading from it, then it will
be effectively deleted.deleteOrReleaseReadLock
in interface SegmentReadLocker
filename
- of the file to release or deleteacquireReadLock(String)
,
Directory#deleteFile(String)
public boolean acquireReadLock(String filename)
acquireReadLock
in interface SegmentReadLocker
filename
- the name of the "file" for which a readlock is requesteddeleteOrReleaseReadLock(String)
Copyright © 2014 JBoss, a division of Red Hat. All Rights Reserved.