|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.lucene.store.Lock
public abstract class 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();
Directory.makeLock(String)| Nested Class Summary | |
|---|---|
static class |
Lock.With
Utility class for executing code with exclusive access. |
| Field Summary | |
|---|---|
protected Throwable |
failureReason
If a lock obtain called, this failureReason may be set with the "root cause" Exception as to why the lock was not obtained. |
static long |
LOCK_OBTAIN_WAIT_FOREVER
Pass this value to obtain(long) to try
forever to obtain the lock. |
static long |
LOCK_POLL_INTERVAL
How long obtain(long) waits, in milliseconds,
in between attempts to acquire the lock. |
| Constructor Summary | |
|---|---|
Lock()
|
|
| Method Summary | |
|---|---|
abstract boolean |
isLocked()
Returns true if the resource is currently locked. |
abstract boolean |
obtain()
Attempts to obtain exclusive access and immediately return upon success or failure. |
boolean |
obtain(long lockWaitTimeout)
Attempts to obtain an exclusive lock within amount of time given. |
abstract void |
release()
Releases exclusive access. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static long LOCK_POLL_INTERVAL
obtain(long) waits, in milliseconds,
in between attempts to acquire the lock.
public static final long LOCK_OBTAIN_WAIT_FOREVER
obtain(long) to try
forever to obtain the lock.
protected Throwable failureReason
| Constructor Detail |
|---|
public Lock()
| Method Detail |
|---|
public abstract boolean obtain()
throws IOException
IOException
public boolean obtain(long lockWaitTimeout)
throws LockObtainFailedException,
IOException
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
public abstract void release()
throws IOException
IOException
public abstract boolean isLocked()
throws IOException
obtain() before using the resource.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||