FileDocCategorySizeDatePackage
SimpleFSLockFactory.javaAPI DocApache Lucene 2.2.04078Sat Jun 16 22:20:36 BST 2007org.apache.lucene.store

SimpleFSLockFactory

public class SimpleFSLockFactory extends LockFactory
Implements {@link LockFactory} using {@link File#createNewFile()}. This is currently the default LockFactory used for {@link FSDirectory} if no LockFactory instance is otherwise provided. Note that there are known problems with this locking implementation on NFS.
see
LockFactory

Fields Summary
private File
lockDir
Directory specified by org.apache.lucene.lockDir system property. If that is not set, then java.io.tmpdir system property is used.
Constructors Summary
SimpleFSLockFactory()
Create a SimpleFSLockFactory instance, with null (unset) lock directory. This is package-private and is only used by FSDirectory when creating this LockFactory via the System property org.apache.lucene.store.FSDirectoryLockFactoryClass.

    this((File) null);
  
public SimpleFSLockFactory(File lockDir)
Instantiate using the provided directory (as a File instance).

param
lockDir where lock files should be created.

    setLockDir(lockDir);
  
public SimpleFSLockFactory(String lockDirName)
Instantiate using the provided directory name (String).

param
lockDirName where lock files should be created.

    lockDir = new File(lockDirName);
    setLockDir(lockDir);
  
Methods Summary
public voidclearLock(java.lang.String lockName)

    if (lockDir.exists()) {
      if (lockPrefix != null) {
        lockName = lockPrefix + "-" + lockName;
      }
      File lockFile = new File(lockDir, lockName);
      if (lockFile.exists() && !lockFile.delete()) {
        throw new IOException("Cannot delete " + lockFile);
      }
    }
  
public org.apache.lucene.store.LockmakeLock(java.lang.String lockName)

    if (lockPrefix != null) {
      lockName = lockPrefix + "-" + lockName;
    }
    return new SimpleFSLock(lockDir, lockName);
  
voidsetLockDir(java.io.File lockDir)
Set the lock directory. This is package-private and is only used externally by FSDirectory when creating this LockFactory via the System property org.apache.lucene.store.FSDirectoryLockFactoryClass.

    this.lockDir = lockDir;