otis 2004/03/18 11:44:46 Modified: src/java/org/apache/lucene/store FSDirectory.java Lock.java Log: - Changed FSDirectory to use a lock dir specified by org.apache.lucene.lockDir system property or java.io.temp fall-back one Revision Changes Path 1.24 +21 -14 jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java Index: FSDirectory.java =================================================================== RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- FSDirectory.java 10 Mar 2004 00:50:41 -0000 1.23 +++ FSDirectory.java 18 Mar 2004 19:44:45 -0000 1.24 @@ -86,8 +86,12 @@ private static final boolean DISABLE_LOCKS = Boolean.getBoolean("disableLuceneLocks") || Constants.JAVA_1_1; + private static final String LOCK_DIR = + System.getProperty("org.apache.lucene.lockdir", + System.getProperty("java.io.tmpdir")); + private static MessageDigest DIGESTER; - + static { try { DIGESTER = MessageDigest.getInstance("MD5"); @@ -143,10 +147,15 @@ private File directory = null; private int refCount; + private File lockDir; private FSDirectory(File path, boolean create) throws IOException { directory = path; + lockDir = new File(LOCK_DIR); + if (!lockDir.isAbsolute()) { + lockDir = new File(directory, LOCK_DIR); + } if (create) create(); @@ -165,15 +174,14 @@ if (!file.delete()) throw new IOException("couldn't delete " + files[i]); } - + String lockPrefix = getLockPrefix().toString(); // clear old locks - File tmpdir = new File(System.getProperty("java.io.tmpdir")); - files = tmpdir.list(); - for (int i = 0; i < files.length; i++) { + files = lockDir.list(); + for (int i = 0; i < files.length; i++) { if (!files[i].startsWith(lockPrefix)) continue; - File file = new File(tmpdir, files[i]); - if (!file.delete()) + File lockFile = new File(lockDir, files[i]); + if (!lockFile.delete()) throw new IOException("couldn't delete " + files[i]); } } @@ -313,9 +321,8 @@ buf.append("-"); buf.append(name); - // make the lock file in tmp, where anyone can create files. - final File lockFile = new File(System.getProperty("java.io.tmpdir"), - buf.toString()); + // create a lock file + final File lockFile = new File(lockDir, buf.toString()); return new Lock() { public boolean obtain() throws IOException { @@ -347,7 +354,7 @@ } catch (IOException e) { throw new RuntimeException(e.toString()); } - + byte digest[]; synchronized (DIGESTER) { digest = DIGESTER.digest(dirName.getBytes()); @@ -396,7 +403,7 @@ //debug_printInfo("OPEN"); /* DEBUG */ } - + /* DEBUG */ //public void close() throws IOException { // debug_printInfo("CLOSE"); @@ -404,7 +411,7 @@ //} // //private void debug_printInfo(String op) { - // try { throw new Exception(op + " <" + name + ">"); + // try { throw new Exception(op + " <" + name + ">"); // } catch (Exception e) { // java.io.StringWriter sw = new java.io.StringWriter(); // java.io.PrintWriter pw = new java.io.PrintWriter(sw); @@ -461,7 +468,7 @@ clone.isClone = true; return clone; } - + /** Method used for testing. Returns true if the underlying * file descriptor is valid. */ 1.7 +1 -5 jakarta-lucene/src/java/org/apache/lucene/store/Lock.java Index: Lock.java =================================================================== RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/Lock.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Lock.java 18 Mar 2004 19:05:18 -0000 1.6 +++ Lock.java 18 Mar 2004 19:44:45 -0000 1.7 @@ -73,10 +73,6 @@ */ public abstract class Lock { public static long LOCK_POLL_INTERVAL = 1000; - - private static final String LOCK_DIR = - System.getProperty("org.apache.lucene.lockdir", - System.getProperty("java.io.tmpdir")); /** Attempts to obtain exclusive access and immediately return * upon success or failure.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]