public final class SimpleFSLockFactory extends FSLockFactory
Implements LockFactory
using Files.createFile(java.nio.file.Path, java.nio.file.attribute.FileAttribute<?>...)
.
NOTE: the javadocs
for File.createNewFile()
contain a vague
yet spooky warning about not using the API for file
locking. This warning was added due to this
bug, and in fact the only known problem with using
this API for locking is that the Lucene write lock may
not be released when the JVM exits abnormally.
When this happens, a LockObtainFailedException
is hit when trying to create a writer, in which case you
need to explicitly clear the lock file first by
manually removing the file. But, first be certain that
no writer is in fact writing to the index otherwise you
can easily corrupt your index.
Special care needs to be taken if you change the locking implementation: First be certain that no writer is in fact writing to the index otherwise you can easily corrupt your index. Be sure to do the LockFactory change all Lucene instances and clean up all leftover lock files before starting the new configuration for the first time. Different implementations can not work together!
If you suspect that this or any other LockFactory is
not working properly in your environment, you can easily
test it by using VerifyingLockFactory
, LockVerifyServer
and LockStressTest
.
This is a singleton, you have to use INSTANCE
.
LockFactory
Modifier and Type | Field and Description |
---|---|
static SimpleFSLockFactory |
INSTANCE
Singleton instance
|
Modifier and Type | Method and Description |
---|---|
protected Lock |
makeFSLock(FSDirectory dir,
String lockName)
Implement this method to create a lock for a FSDirectory instance.
|
getDefault, makeLock
public static final SimpleFSLockFactory INSTANCE
protected Lock makeFSLock(FSDirectory dir, String lockName)
FSLockFactory
makeFSLock
in class FSLockFactory
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.