jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r799595 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene: MultiIndex.java directory/FSDirectoryManager.java
Date Fri, 31 Jul 2009 13:06:34 GMT
Author: mreutegg
Date: Fri Jul 31 13:06:34 2009
New Revision: 799595

URL: http://svn.apache.org/viewvc?rev=799595&view=rev
Log:
JCR-2229: Improve behaviour when 'too many open files' occurs

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/directory/FSDirectoryManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=799595&r1=799594&r2=799595&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
Fri Jul 31 13:06:34 2009
@@ -404,7 +404,12 @@
             throws IOException {
         // make sure a reader is available during long updates
         if (add.size() > handler.getBufferSize()) {
-            getIndexReader().release();
+            try {
+                getIndexReader().release();
+            } catch (IOException e) {
+                // do not fail if an exception is thrown here
+                log.warn("unable to prepare index reader for queries during update", e);
+            }
         }
 
         synchronized (updateMonitor) {
@@ -574,9 +579,18 @@
                 indexName = indexNames.newName();
             } while (directoryManager.hasDirectory(indexName));
         }
-        PersistentIndex index = new PersistentIndex(indexName,
-                handler.getTextAnalyzer(), handler.getSimilarity(),
-                cache, indexingQueue, directoryManager);
+        PersistentIndex index;
+        try {
+            index = new PersistentIndex(indexName,
+                    handler.getTextAnalyzer(), handler.getSimilarity(),
+                    cache, indexingQueue, directoryManager);
+        } catch (IOException e) {
+            // do some clean up
+            if (!directoryManager.delete(indexName)) {
+                deletable.add(indexName);
+            }
+            throw e;
+        }
         index.setMaxFieldLength(handler.getMaxFieldLength());
         index.setUseCompoundFile(handler.getUseCompoundFile());
         index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/directory/FSDirectoryManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/directory/FSDirectoryManager.java?rev=799595&r1=799594&r2=799595&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/directory/FSDirectoryManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/directory/FSDirectoryManager.java
Fri Jul 31 13:06:34 2009
@@ -73,11 +73,15 @@
                 return pathname.isDirectory();
             }
         });
-        String[] names = new String[dirs.length];
-        for (int i = 0; i < dirs.length; i++) {
-            names[i] = dirs[i].getName();
+        if (dirs != null) {
+            String[] names = new String[dirs.length];
+            for (int i = 0; i < dirs.length; i++) {
+                names[i] = dirs[i].getName();
+            }
+            return names;
+        } else {
+            throw new IOException("listFiles for " + baseDir.getPath() + " returned null");
         }
-        return names;
     }
 
     /**
@@ -90,10 +94,15 @@
             return true;
         }
         // delete files first
-        for (File file : directory.listFiles()) {
-            if (!file.delete()) {
-                return false;
+        File[] files = directory.listFiles();
+        if (files != null) {
+            for (File file : files) {
+                if (!file.delete()) {
+                    return false;
+                }
             }
+        } else {
+            return false;
         }
         // now delete directory itself
         return directory.delete();



Mime
View raw message