public interface SegmentReadLocker
SegmentReadLocker implementations have to make sure that segments are not deleted while they are being used by an IndexReader.
When an InfinispanIndexInput
is opened on a file which is split in smaller chunks,
acquireReadLock(String)
is invoked; then the deleteOrReleaseReadLock(String)
is
invoked when the stream is closed.
The same deleteOrReleaseReadLock(String)
is invoked when a file is deleted, so if this invocation is not balancing
a lock acquire this implementation must delete all segment chunks and the associated metadata.
Note that if you can use and tune the LogByteSizeMergePolicy
you could avoid the need
for readlocks by setting a maximum segment size to equal the chunk size used by the InfinispanDirectory; readlocks
will be skipped automatically when not needed, so it's advisable to still configure an appropriate SegmentReadLocker
for the cases you might want to tune the chunk size.
Modifier and Type | Method and Description |
---|---|
boolean |
acquireReadLock(String filename)
Acquires a readlock, in order to prevent other invocations to
deleteOrReleaseReadLock(String)
from deleting the file. |
void |
deleteOrReleaseReadLock(String fileName)
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.
|
void deleteOrReleaseReadLock(String fileName)
fileName
- of the file to release or deleteDirectory#deleteFile(String)
boolean acquireReadLock(String filename)
deleteOrReleaseReadLock(String)
from deleting the file.filename
- Directory#openInput(String)
Copyright © 2014 JBoss, a division of Red Hat. All Rights Reserved.