FileDocCategorySizeDatePackage
SimpleFSLockFactory.javaAPI DocApache Lucene 2.1.03490Wed Feb 14 10:46:40 GMT 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
public SimpleFSLockFactory(File lockDir)
Instantiate using the provided directory (as a File instance).

param
lockDir where lock files should be created.

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

param
lockDirName where lock files should be created.

    lockDir = new File(lockDirName);
    init(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);
      }
    }
  
protected voidinit(java.io.File lockDir)

    this.lockDir = lockDir;
  
public org.apache.lucene.store.LockmakeLock(java.lang.String lockName)

    if (lockPrefix != null) {
      lockName = lockPrefix + "-" + lockName;
    }
    return new SimpleFSLock(lockDir, lockName);