You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by mi...@apache.org on 2010/10/07 11:11:30 UTC
svn commit: r1005375 - in /lucene/java/branches/lucene_2_9: CHANGES.txt
src/java/org/apache/lucene/store/NativeFSLockFactory.java
Author: mikemccand
Date: Thu Oct 7 09:11:30 2010
New Revision: 1005375
URL: http://svn.apache.org/viewvc?rev=1005375&view=rev
Log:
LUCENE-2689: don't attempt to acquire a test lock in NativeFSLockFactory
Modified:
lucene/java/branches/lucene_2_9/CHANGES.txt
lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/store/NativeFSLockFactory.java
Modified: lucene/java/branches/lucene_2_9/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/CHANGES.txt?rev=1005375&r1=1005374&r2=1005375&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/CHANGES.txt (original)
+++ lucene/java/branches/lucene_2_9/CHANGES.txt Thu Oct 7 09:11:30 2010
@@ -3,6 +3,12 @@ $Id$
======================= 2.9 branch (not yet released) ==================
+Changes in runtime behavior
+
+* LUCENE-2689: NativeFSLockFactory no longer attempts to acquire a
+ test lock just before the real lock is acquired. (Surinder Pal
+ Singh Bindra via Mike McCandless)
+
Bug fixes
* LUCENE-2142 (correct fix): FieldCacheImpl.getStringIndex no longer
Modified: lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/store/NativeFSLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/store/NativeFSLockFactory.java?rev=1005375&r1=1005374&r2=1005375&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/store/NativeFSLockFactory.java (original)
+++ lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/store/NativeFSLockFactory.java Thu Oct 7 09:11:30 2010
@@ -23,7 +23,6 @@ import java.io.File;
import java.io.RandomAccessFile;
import java.io.IOException;
import java.util.HashSet;
-import java.util.Random;
/**
* <p>Implements {@link LockFactory} using native OS file
@@ -57,51 +56,6 @@ import java.util.Random;
public class NativeFSLockFactory extends FSLockFactory {
- private volatile boolean tested = false;
-
- // Simple test to verify locking system is "working". On
- // NFS, if it's misconfigured, you can hit long (35
- // second) timeouts which cause Lock.obtain to take far
- // too long (it assumes the obtain() call takes zero
- // time).
- private synchronized void acquireTestLock() {
- if (tested) return;
- tested = true;
-
- // Ensure that lockDir exists and is a directory.
- if (!lockDir.exists()) {
- if (!lockDir.mkdirs())
- throw new RuntimeException("Cannot create directory: " +
- lockDir.getAbsolutePath());
- } else if (!lockDir.isDirectory()) {
- throw new RuntimeException("Found regular file where directory expected: " +
- lockDir.getAbsolutePath());
- }
-
- // add the RuntimeMXBean's name to the lock file, to reduce the chance for
- // name collisions when this code is invoked by multiple JVMs (such as in
- // our tests). On most systems, the name includes the process Id.
- // Also, remove any non-alphanumeric characters, so that the lock file will
- // be created for sure on all systems.
- String randomLockName = "lucene-" + Long.toString(new Random().nextInt(), Character.MAX_RADIX) + "-test.lock";
-
- Lock l = makeLock(randomLockName);
- try {
- l.obtain();
- l.release();
- // If the test lock failed to delete after all the attempts, attempt a
- // delete when the JVM exits.
- File lockFile = new File(lockDir, randomLockName);
- if (lockFile.exists()) {
- lockFile.deleteOnExit();
- }
- } catch (IOException e) {
- RuntimeException e2 = new RuntimeException("Failed to acquire random test lock; please verify filesystem for lock directory '" + lockDir + "' supports locking");
- e2.initCause(e);
- throw e2;
- }
- }
-
/**
* Create a NativeFSLockFactory instance, with null (unset)
* lock directory. When you pass this factory to a {@link FSDirectory}
@@ -134,7 +88,6 @@ public class NativeFSLockFactory extends
}
public synchronized Lock makeLock(String lockName) {
- acquireTestLock();
if (lockPrefix != null)
lockName = lockPrefix + "-" + lockName;
return new NativeFSLock(lockDir, lockName);