roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r993154 - in /roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search: IndexManagerImpl.java operations/RebuildWebsiteIndexOperation.java
Date Mon, 06 Sep 2010 21:12:03 GMT
Author: snoopdave
Date: Mon Sep  6 21:12:03 2010
New Revision: 993154

URL: http://svn.apache.org/viewvc?rev=993154&view=rev
Log:
Fix for https://issues.apache.org/jira/browse/ROL-1876
Shouldn't have to delete search index dir to cause re-index

Modified:
    roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java
    roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java

Modified: roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java?rev=993154&r1=993153&r2=993154&view=diff
==============================================================================
--- roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java
(original)
+++ roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java
Mon Sep  6 21:12:03 2010
@@ -131,12 +131,14 @@ public class IndexManagerImpl implements
             if (indexConsistencyMarker.exists()) {
                 getFSDirectory(true);
                 inconsistentAtStartup = true;
+                mLogger.debug("Index inconsistent: marker exists");
             } else {
                 try {
                     File makeIndexDir = new File(indexDir);
                     if (!makeIndexDir.exists()) {
                         makeIndexDir.mkdirs();
                         inconsistentAtStartup = true;
+                        mLogger.debug("Index inconsistent: new");
                     }
                     indexConsistencyMarker.createNewFile();
                 } catch (IOException e) {
@@ -146,8 +148,7 @@ public class IndexManagerImpl implements
             
             if (indexExists()) {
                 if (useRAMIndex) {
-                    Directory filesystem = getFSDirectory(false);
-                    
+                    Directory filesystem = getFSDirectory(false);                    
                     try {
                         fRAMindex = new RAMDirectory(filesystem);
                     } catch (IOException e) {
@@ -155,6 +156,8 @@ public class IndexManagerImpl implements
                     }
                 }
             } else {
+                mLogger.debug("Creating index");
+                inconsistentAtStartup = true;
                 if (useRAMIndex) {
                     fRAMindex = new RAMDirectory();
                     createIndex(fRAMindex);
@@ -165,12 +168,14 @@ public class IndexManagerImpl implements
             
             if (isInconsistentAtStartup()) {
                 mLogger.info(
-                        "Index was inconsistent. Rebuilding index in the background...");
+                    "Index was inconsistent. Rebuilding index in the background...");
                 try {
                     rebuildWebsiteIndex();
                 } catch (WebloggerException e) {
                     mLogger.error("ERROR: scheduling re-index operation");
                 }
+            } else {
+                mLogger.info("Index initialized and ready for use.");
             }
         }
         

Modified: roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java?rev=993154&r1=993153&r2=993154&view=diff
==============================================================================
--- roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java
(original)
+++ roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java
Mon Sep  6 21:12:03 2010
@@ -34,9 +34,7 @@ import org.apache.roller.weblogger.busin
 import org.apache.roller.weblogger.business.search.FieldConstants;
 import org.apache.roller.weblogger.business.search.IndexUtil;
 import org.apache.roller.weblogger.business.Weblogger;
-import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
-import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.pojos.Weblog;
 
@@ -72,20 +70,24 @@ public class RebuildWebsiteIndexOperatio
     //~ Methods ================================================================
     
     public void doRun() {
+
         Date start = new Date();
         
         // since this operation can be run on a separate thread we must treat
         // the weblog object passed in as a detached object which is proned to
         // lazy initialization problems, so requery for the object now
-        if(this.website != null) {
+        if ( this.website != null) {
+            mLogger.debug("Reindexining weblog " + website.getHandle());
             try {
                 this.website = roller.getWeblogManager().getWeblog(this.website.getId());
             } catch (WebloggerException ex) {
                 mLogger.error("Error getting website object", ex);
                 return;
             }
+        } else {
+            mLogger.debug("Reindexining entire site");
         }
-        
+
         IndexReader reader = beginDeleting();
         
         try {
@@ -115,10 +117,7 @@ public class RebuildWebsiteIndexOperatio
         try {
             if (writer != null) {
                 WeblogEntryManager weblogManager = roller.getWeblogEntryManager();
-                
-                
-                List entries = weblogManager .getWeblogEntries(
-                        
+                List entries = weblogManager .getWeblogEntries(                        
                         website,                   // website            
                         null,
                         null,                      // startDate
@@ -130,6 +129,7 @@ public class RebuildWebsiteIndexOperatio
                         null, 
                         null,
                         0, -1);     // offset, length, locale
+                mLogger.debug("Entries to index: " + entries.size());
                 for (Iterator wbItr = entries.iterator(); wbItr.hasNext();) {
                     WeblogEntry entry = (WeblogEntry) wbItr.next();
                     writer.addDocument(getDocument(entry));



Mime
View raw message