org.apache.lucene.store

## Class FSLockFactory

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

- Direct Known Subclasses:
    NativeFSLockFactory, SimpleFSLockFactory

      public abstract class FSLockFactory
      extends LockFactory

  Base class for file system based locking implementation. This class is explicitly checking that the passed `Directory` is an `FSDirectory`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FSLockFactory()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static FSLockFactory` | `getDefault()` Returns the default locking implementation for this platform.
    `protected abstract Lock` | `obtainFSLock(FSDirectory dir, String lockName)` Implement this method to obtain a lock for a FSDirectory instance.
    `Lock` | `obtainLock(Directory dir, String lockName)` Return a new obtained Lock instance identified by lockName.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FSLockFactory

          public FSLockFactory()

  - ### Method Detail

    - #### getDefault

          public static final FSLockFactory getDefault()

      Returns the default locking implementation for this platform. This method currently returns always `NativeFSLockFactory`.

    - #### obtainLock

          public final Lock obtainLock(Directory dir,
                                       String lockName)
                                throws IOException

      Description copied from class: `LockFactory`
      Return a new obtained Lock instance identified by lockName.
      Specified by:
        `obtainLock` in class `LockFactory`
        `lockName` - name of the lock to be created.
      Throws:
        `LockObtainFailedException` - (optional specific exception) if the lock could not be obtained because it is currently held elsewhere.
        `IOException` - if any i/o error occurs attempting to gain the lock

    - #### obtainFSLock

          protected abstract Lock obtainFSLock(FSDirectory dir,
                                               String lockName)
                                        throws IOException

      Implement this method to obtain a lock for a FSDirectory instance.
      Throws:
        `IOException` - if the lock could not be obtained.

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.