"Chris Lu" <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]