lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless" <luc...@mikemccandless.com>
Subject Re: Clearing locks
Date Mon, 05 Mar 2007 10:57:09 GMT

"Chris Lu" <chris.lu@gmail.com> wrote:
> They are not really unique. Here are my code to unlock the directory.
> Notice there are two locks.
> 
>     public static void unlockDirectory(Directory dir) {
>         Lock dirLock = dir.makeLock(IndexWriter.WRITE_LOCK_NAME);
>         if (dirLock.isLocked()) {
>             logger.debug("unlocking " + dirLock);
>             dirLock.release();
>             logger.info("unlocked directory " + dir);
>         }
>         dirLock = dir.makeLock(IndexWriter.COMMIT_LOCK_NAME);
>         if (dirLock.isLocked()) {
>             logger.debug("unlocking " + dirLock);
>             dirLock.release();
>             logger.info("unlocked directory " + dir);
>         }
>     }

Note that as of 2.1, there is only the write.lock (no more commit
lock), and this means readers are read-only (they don't write to the
write lock).  And the write lock filename is stored in the index
directory and doesn't have the big prefix in front of it (by default).

Also as of 2.1, the locking implementation is decoupled from the
Directory implementation, so you can switch to example "in-process"
locking if you know all writers are in the same JVM, or, native file
locking (better than the default "simple" locks because lock files
will be release by the OS if the JVM crashes).  Look at the
*LockFactory javadocs for details.

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message