NativeFSLockFactory (Lucene 3.6.2 API)
Keywords: org.apache.lucene.store.NativeFSLockFactory class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.store
Class NativeFSLockFactory

    java.lang.Object
      org.apache.lucene.store.LockFactory
          org.apache.lucene.store.FSLockFactory
              org.apache.lucene.store.NativeFSLockFactory

    public class NativeFSLockFactory

extends FSLockFactory

Implements `LockFactory` using native OS file locks. Note that because this LockFactory relies on java.nio.* APIs for locking, any problems with those APIs will cause locking to fail. Specifically, on certain NFS environments the java.nio.* locks will fail (the lock can incorrectly be double acquired) whereas `SimpleFSLockFactory` worked perfectly in those same environments. For NFS based access to an index, it's recommended that you try `SimpleFSLockFactory` first and work around the one limitation that a lock file could be left when the JVM exits abnormally.

The primary benefit of `NativeFSLockFactory` is that lock files will be properly removed (by the OS) if the JVM has an abnormal exit.

Note that, unlike `SimpleFSLockFactory`, the existence of leftover lock files in the filesystem on exiting the JVM is fine because the OS will free the locks held against these files even though the files still remain.

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`.

See Also:
  `LockFactory`

Field Summary

Fields inherited from class org.apache.lucene.store.FSLockFactory
`lockDir`

Fields inherited from class org.apache.lucene.store.LockFactory
`lockPrefix`

Constructor Summary
`NativeFSLockFactory()` Create a NativeFSLockFactory instance, with null (unset) lock directory.
`NativeFSLockFactory(File lockDir)` Create a NativeFSLockFactory instance, storing lock files into the specified lockDir:
`NativeFSLockFactory(String lockDirName)` Create a NativeFSLockFactory instance, storing lock files into the specified lockDirName:

Method Summary
`void` | `clearLock(String lockName)` Attempt to clear (forcefully unlock and remove) the specified lock.
`Lock` | `makeLock(String lockName)` Return a new Lock instance identified by lockName.

Methods inherited from class org.apache.lucene.store.FSLockFactory
`getLockDir, setLockDir`

Methods inherited from class org.apache.lucene.store.LockFactory
`getLockPrefix, setLockPrefix`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### NativeFSLockFactory

    public NativeFSLockFactory()
                        throws IOException

  Create a NativeFSLockFactory instance, with null (unset) lock directory. When you pass this factory to a `FSDirectory` subclass, the lock directory is automatically set to the directory itself. Be sure to create one instance for each directory your create!

  Throws:
    `IOException`

### NativeFSLockFactory

    public NativeFSLockFactory(String lockDirName)
                        throws IOException

  Create a NativeFSLockFactory instance, storing lock files into the specified lockDirName:

  Parameters:
    `lockDirName` - where lock files are created.
  Throws:
    `IOException`

### NativeFSLockFactory

    public NativeFSLockFactory(File lockDir)
                        throws IOException

  Create a NativeFSLockFactory instance, storing lock files into the specified lockDir:

  Parameters:
    `lockDir` - where lock files are created.
  Throws:
    `IOException`

Method Detail

### makeLock

    public Lock makeLock(String lockName)

  Description copied from class: `LockFactory`
  Return a new Lock instance identified by lockName.

  Specified by:
    `makeLock` in class `LockFactory`
  Parameters:
    `lockName` - name of the lock to be created.

### clearLock

    public void clearLock(String lockName)
                   throws IOException

  Description copied from class: `LockFactory`
  Attempt to clear (forcefully unlock and remove) the specified lock. Only call this at a time when you are certain this lock is no longer in use.

  Specified by:
    `clearLock` in class `LockFactory`
  Parameters:
    `lockName` - name of the lock to be cleared.
  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD