lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1005371 - in /lucene/java/branches/lucene_3_0: CHANGES.txt src/java/org/apache/lucene/store/NativeFSLockFactory.java
Date Thu, 07 Oct 2010 09:06:46 GMT
Author: mikemccand
Date: Thu Oct  7 09:06:46 2010
New Revision: 1005371

URL: http://svn.apache.org/viewvc?rev=1005371&view=rev
Log:
LUCENE-2689: don't attempt to acquire a test lock in NativeFSLockFactory

Modified:
    lucene/java/branches/lucene_3_0/CHANGES.txt
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/store/NativeFSLockFactory.java

Modified: lucene/java/branches/lucene_3_0/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/CHANGES.txt?rev=1005371&r1=1005370&r2=1005371&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/CHANGES.txt (original)
+++ lucene/java/branches/lucene_3_0/CHANGES.txt Thu Oct  7 09:06:46 2010
@@ -3,6 +3,12 @@ $Id$
 
 ======================= 3.0 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_3_0/src/java/org/apache/lucene/store/NativeFSLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/store/NativeFSLockFactory.java?rev=1005371&r1=1005370&r2=1005371&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/store/NativeFSLockFactory.java
(original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/store/NativeFSLockFactory.java
Thu Oct  7 09:06:46 2010
@@ -58,54 +58,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-"
-        + ManagementFactory.getRuntimeMXBean().getName().replaceAll("[^a..zA..Z0..9]+","")
+ "-"
-        + 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}
@@ -139,7 +91,6 @@ public class NativeFSLockFactory extends
 
   @Override
   public synchronized Lock makeLock(String lockName) {
-    acquireTestLock();
     if (lockPrefix != null)
       lockName = lockPrefix + "-" + lockName;
     return new NativeFSLock(lockDir, lockName);



Mime
View raw message