org.infinispan.lucene.readlocks
Class DistributedSegmentReadLocker

java.lang.Object
  extended by 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
DistributedSegmentReadLocker(Cache cache, String indexName)
           
 
Method Summary
 boolean aquireReadLock(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributedSegmentReadLocker

public DistributedSegmentReadLocker(Cache cache,
                                    String indexName)
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 other InfinispanIndexInput instances are reading from it, then it will be effectively deleted. For removal of readLockKey the SKIP_CACHE_STORE is not used to make sure even values eventually stored by a rehash are cleaned up.

Specified by:
deleteOrReleaseReadLock in interface SegmentReadLocker
Parameters:
filename - of the file to release or delete
See Also:
aquireReadLock(String), InfinispanDirectory.deleteFile(String)

aquireReadLock

public boolean aquireReadLock(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:
aquireReadLock in interface SegmentReadLocker
Parameters:
name - 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)

Google Analytics

Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.