there are also the static IndexReder.isLocked(Directory) and IndexReder.unlock(Directory) methods that encapsulate this logic for you ... they've been around since at least 1.4.3.
: Date: Sun, 4 Mar 2007 21:34:52 -0800 : From: Chris Lu <[EMAIL PROTECTED]> : Reply-To: java-user@lucene.apache.org : To: java-user@lucene.apache.org : Subject: Re: Clearing locks : : 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); : } : } : : -- : Chris Lu : ------------------------- : Instant Full-Text Search On Any Database/Application : site: http://www.dbsight.net : demo: http://search.dbsight.com : : On 3/4/07, MC Moisei <[EMAIL PROTECTED]> wrote: : > How do I clear the locks ? THey have unique names and the name changes : > everytime... : > : > Chris Lu wrote: : > > A safe way to do this is to clear the locks just before starting your : > > war file. : > > : > : > : > --------------------------------------------------------------------- : > To unsubscribe, e-mail: [EMAIL PROTECTED] : > For additional commands, e-mail: [EMAIL PROTECTED] : > : > : : --------------------------------------------------------------------- : To unsubscribe, e-mail: [EMAIL PROTECTED] : For additional commands, e-mail: [EMAIL PROTECTED] : -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]