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
Directory that wraps another, and that sleeps and retries if obtaining the lock fails.
This is not a good idea.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic long
How longobtainLock(java.lang.String)
waits, in milliseconds, in between attempts to acquire the lock.static final long
Pass this lockWaitTimeout to try forever to obtain the lock.Fields inherited from class org.apache.lucene.store.FilterDirectory
in
-
Constructor Summary
ConstructorsConstructorDescriptionSleepingLockWrapper
(Directory delegate, long lockWaitTimeout) Create a new SleepingLockFactorySleepingLockWrapper
(Directory delegate, long lockWaitTimeout, long pollInterval) Create a new SleepingLockFactory -
Method Summary
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
-
Field Details
-
LOCK_OBTAIN_WAIT_FOREVER
public static final long LOCK_OBTAIN_WAIT_FOREVERPass this lockWaitTimeout to try forever to obtain the lock.- See Also:
-
DEFAULT_POLL_INTERVAL
public static long DEFAULT_POLL_INTERVALHow longobtainLock(java.lang.String)
waits, in milliseconds, in between attempts to acquire the lock.
-
-
Constructor Details
-
SleepingLockWrapper
Create a new SleepingLockFactory- Parameters:
delegate
- underlying directory to wraplockWaitTimeout
- length of time to wait in milliseconds orLOCK_OBTAIN_WAIT_FOREVER
to retry forever.
-
SleepingLockWrapper
Create a new SleepingLockFactory- Parameters:
delegate
- underlying directory to wraplockWaitTimeout
- length of time to wait in milliseconds orLOCK_OBTAIN_WAIT_FOREVER
to retry forever.pollInterval
- poll once per this interval in milliseconds untillockWaitTimeout
is exceeded.
-
-
Method Details
-
obtainLock
Description copied from class:Directory
Acquires and returns aLock
for a file with the given name.- Overrides:
obtainLock
in classFilterDirectory
- Parameters:
lockName
- the name of the lock file- 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
-
toString
- Overrides:
toString
in classFilterDirectory
-