Package org.apache.lucene.store
Class Lock
- java.lang.Object
-
- org.apache.lucene.store.Lock
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
NativeFSLockFactory.NativeFSLock,NoLockFactory.NoLock,SimpleFSLockFactory.SimpleFSLock,SingleInstanceLockFactory.SingleInstanceLock,VerifyingLockFactory.CheckedLock
public abstract class Lock extends java.lang.Object implements java.io.CloseableAn interprocess mutex lock.Typical use might look like:
try (final Lock lock = directory.obtainLock("my.lock")) { // ... code to execute while locked ... }- See Also:
Directory.obtainLock(String)
-
-
Constructor Summary
Constructors Constructor Description Lock()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract voidclose()Releases exclusive access.abstract voidensureValid()Best effort check that this lock is still valid.
-
-
-
Method Detail
-
close
public abstract void close() throws java.io.IOExceptionReleases exclusive access.Note that exceptions thrown from close may require human intervention, as it may mean the lock was no longer valid, or that fs permissions prevent removal of the lock file, or other reasons.
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
LockReleaseFailedException- optional specific exception) if the lock could not be properly released.java.io.IOException
-
ensureValid
public abstract void ensureValid() throws java.io.IOExceptionBest effort check that this lock is still valid. Locks could become invalidated externally for a number of reasons, for example if a user deletes the lock file manually or when a network filesystem is in use.- Throws:
java.io.IOException- if the lock is no longer valid.
-
-