jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r154158 - incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
Date Thu, 17 Feb 2005 15:02:48 GMT
Author: mreutegg
Date: Thu Feb 17 07:02:45 2005
New Revision: 154158

URL: http://svn.apache.org/viewcvs?view=rev&rev=154158
Log:
Changed query handler to remove a possible write.lock on startup.

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java?view=diff&r1=154157&r2=154158
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
Thu Feb 17 07:02:45 2005
@@ -51,6 +51,9 @@
 
     private static final Logger log = Logger.getLogger(SearchIndex.class);
 
+    /** Name of the write lock file */
+    private static final String WRITE_LOCK = "write.lock";
+
     /** Name of the file to persist search internal namespace mappings */
     private static final String NS_MAPPING_FILE = "ns_mappings.properties";
 
@@ -84,9 +87,19 @@
      * @throws IOException if an error occurs while initializing this handler.
      */
     protected void doInit() throws IOException {
-        boolean create;
         try {
-            create = !getFileSystem().exists("segments");
+            // check if index is locked, probably from an unclean repository
+            // shutdown
+            if (getFileSystem().exists(WRITE_LOCK)) {
+                log.warn("Removing write lock on search index.");
+                try {
+                    getFileSystem().deleteFile(WRITE_LOCK);
+                } catch (FileSystemException e) {
+                    log.error("Unable to remove write lock on search index.");
+                }
+            }
+
+            boolean create = !getFileSystem().exists("segments");
             persistentIndex = new PersistentIndex(getFileSystem(), create, analyzer);
             persistentIndex.setUseCompoundFile(true);
             FileSystemResource mapFile = new FileSystemResource(getFileSystem(), NS_MAPPING_FILE);



Mime
View raw message