Package org.apache.lucene.store

# Class SleepingLockWrapper

java.lang.Object
org.apache.lucene.store.Directory
org.apache.lucene.store.FilterDirectory
org.apache.lucene.store.SleepingLockWrapper

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public final class SleepingLockWrapper extends FilterDirectory
Directory that wraps another, and that sleeps and retries if obtaining the lock fails.

This is not a good idea.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `DEFAULT_POLL_INTERVAL`
  How long `obtainLock(java.lang.String)` waits, in milliseconds, in between attempts to acquire the lock.
  `static final long`
  `LOCK_OBTAIN_WAIT_FOREVER`
  Pass this lockWaitTimeout to try forever to obtain the lock.

  ### Fields inherited from class org.apache.lucene.store.FilterDirectory

  `in`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SleepingLockWrapper(Directory delegate, long lockWaitTimeout)`
  Create a new SleepingLockFactory
  `SleepingLockWrapper(Directory delegate, long lockWaitTimeout, long pollInterval)`
  Create a new SleepingLockFactory

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Lock`
  `obtainLock(String lockName)`
  Acquires and returns a `Lock` for a file with the given name.
  `String`
  `toString()`

  ### Methods inherited from class org.apache.lucene.store.FilterDirectory

  `close, createOutput, createTempOutput, deleteFile, ensureOpen, fileLength, getDelegate, getPendingDeletions, listAll, openInput, rename, sync, syncMetaData, unwrap`

  ### Methods inherited from class org.apache.lucene.store.Directory

  `copyFrom, getTempFileName, openChecksumInput`

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

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

- ## Field Details

  - ### LOCK_OBTAIN_WAIT_FOREVER

    public static final long LOCK_OBTAIN_WAIT_FOREVER
    Pass this lockWaitTimeout to try forever to obtain the lock.
    See Also:
      - Constant Field Values

  - ### DEFAULT_POLL_INTERVAL

    public static final long DEFAULT_POLL_INTERVAL
    How long `obtainLock(java.lang.String)` waits, in milliseconds, in between attempts to acquire the lock.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### SleepingLockWrapper

    public SleepingLockWrapper(Directory delegate, long lockWaitTimeout)
    Create a new SleepingLockFactory
    Parameters:
      `delegate` - underlying directory to wrap
      `lockWaitTimeout` - length of time to wait in milliseconds or `LOCK_OBTAIN_WAIT_FOREVER` to retry forever.

  - ### SleepingLockWrapper

    public SleepingLockWrapper(Directory delegate, long lockWaitTimeout, long pollInterval)
    Create a new SleepingLockFactory
    Parameters:
      `delegate` - underlying directory to wrap
      `lockWaitTimeout` - length of time to wait in milliseconds or `LOCK_OBTAIN_WAIT_FOREVER` to retry forever.
      `pollInterval` - poll once per this interval in milliseconds until `lockWaitTimeout` is exceeded.

- ## Method Details

  - ### obtainLock

    public Lock obtainLock(String lockName) throws IOException
    Description copied from class: `Directory`
    Acquires and returns a `Lock` for a file with the given name.
    Overrides:
      `obtainLock` in class `FilterDirectory`
    Parameters:
      `lockName` - the name of the lock file
    Throws:
      `IOException` - if any i/o error occurs attempting to gain the lock

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `FilterDirectory`