org.infinispan.lucene.readlocks
Class LocalLockMergingSegmentReadLocker

java.lang.Object
  extended by org.infinispan.lucene.readlocks.LocalLockMergingSegmentReadLocker
All Implemented Interfaces:
SegmentReadLocker

public class LocalLockMergingSegmentReadLocker
extends Object
implements SegmentReadLocker

LocalLockMergingSegmentReadLocker decorates the DistributedSegmentReadLocker to minimize remote operations in case several IndexReaders are opened on the same InfinispanDirectory. 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
LocalLockMergingSegmentReadLocker(Cache cache, String indexName)
          Create a new LocalLockMergingSegmentReadLocker for specified cache and index name.
 
Method Summary
 boolean aquireReadLock(String name)
          Acquires a readlock, in order to prevent other invocations to SegmentReadLocker.deleteOrReleaseReadLock(String) from deleting the file.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalLockMergingSegmentReadLocker

public LocalLockMergingSegmentReadLocker(Cache cache,
                                         String indexName)
Create a new LocalLockMergingSegmentReadLocker for specified cache and index name.

Parameters:
cache -
indexName -
Method Detail

aquireReadLock

public boolean aquireReadLock(String name)
Acquires a readlock, in order to prevent other invocations to SegmentReadLocker.deleteOrReleaseReadLock(String) from deleting the file.

Specified by:
aquireReadLock in interface SegmentReadLocker
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:
InfinispanDirectory.openInput(String)

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:
deleteOrReleaseReadLock in interface SegmentReadLocker
Parameters:
name - of the file to release or delete
See Also:
InfinispanDirectory.deleteFile(String)

Google Analytics

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