java.lang.Object | |
↳ | org.apache.lucene.store.Lock |
An interprocess mutex lock.
Typical use might look like:
new Lock.With(directory.makeLock("my.lock")) { public Object doBody() { ... code to execute while locked ... } }.run();
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Lock.With | Utility class for executing code with exclusive access. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
long | LOCK_OBTAIN_WAIT_FOREVER | Pass this value to obtain(long) to try
forever to obtain the lock. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
LOCK_POLL_INTERVAL | How long obtain(long) waits, in milliseconds,
in between attempts to acquire the lock. |
||||||||||
failureReason | If a lock obtain called, this failureReason may be set with the "root cause" Exception as to why the lock was not obtained. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns true if the resource is currently locked.
| |||||||||||
Attempts to obtain exclusive access and immediately return
upon success or failure.
| |||||||||||
Attempts to obtain an exclusive lock within amount of
time given.
| |||||||||||
Releases exclusive access.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Pass this value to obtain(long)
to try
forever to obtain the lock.
How long obtain(long)
waits, in milliseconds,
in between attempts to acquire the lock.
If a lock obtain called, this failureReason may be set with the "root cause" Exception as to why the lock was not obtained.
Returns true if the resource is currently locked. Note that one must
still call obtain()
before using the resource.
IOException |
---|
Attempts to obtain exclusive access and immediately return upon success or failure.
IOException |
---|
Attempts to obtain an exclusive lock within amount of
time given. Polls once per LOCK_POLL_INTERVAL
(currently 1000) milliseconds until lockWaitTimeout is
passed.
lockWaitTimeout | length of time to wait in
milliseconds or LOCK_OBTAIN_WAIT_FOREVER to retry forever |
---|
LockObtainFailedException | if lock wait times out |
---|---|
IllegalArgumentException | if lockWaitTimeout is out of bounds |
IOException | if obtain() throws IOException |