Home » lucene-3.0.1-src » org.apache » lucene » store » [javadoc | source]
org.apache.lucene.store
abstract public class: Lock [javadoc | source]
java.lang.Object
   org.apache.lucene.store.Lock

Direct Known Subclasses:
    SingleInstanceLock, NoLock, CheckedLock, DbLock, SimpleFSLock, NativeFSLock, JELock

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 Class Summary:
abstract public static class  Lock.With  Utility class for executing code with exclusive access. 
Field Summary
public static  long LOCK_POLL_INTERVAL    How long #obtain(long) waits, in milliseconds, in between attempts to acquire the lock. 
public static final  long LOCK_OBTAIN_WAIT_FOREVER    Pass this value to #obtain(long) to try forever to obtain the lock. 
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. 
Method from org.apache.lucene.store.Lock Summary:
isLocked,   obtain,   obtain,   release
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.lucene.store.Lock Detail:
 abstract public boolean isLocked() throws IOException
    Returns true if the resource is currently locked. Note that one must still call #obtain() before using the resource.
 abstract public boolean obtain() throws IOException
    Attempts to obtain exclusive access and immediately return upon success or failure.
 public boolean obtain(long lockWaitTimeout) throws LockObtainFailedException, 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.
 abstract public  void release() throws IOException
    Releases exclusive access.