Class 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 Detail

      • 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 long DEFAULT_POLL_INTERVAL
        How long obtainLock(java.lang.String) waits, in milliseconds, in between attempts to acquire the lock.
    • Constructor Detail

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