[dna-commits] DNA SVN: r1591 - in trunk: extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene and 1 other directory.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Sun Jan 10 21:18:28 EST 2010


Author: rhauch
Date: 2010-01-10 21:18:28 -0500 (Sun, 10 Jan 2010)
New Revision: 1591

Modified:
   trunk/dna-jcr/src/test/resources/log4j.properties
   trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/AbstractLuceneSearchEngine.java
   trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchProcessor.java
   trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchSession.java
Log:
DNA-644 Added TRACE-level logging to several dna-search-lucene classes to help debug what content is being added to and removed from the Lucene indexes. I tried to make the message very easy to read, especially as there is one line per add, per delete, and per commit or rollback. Also added a fragment to the 'dna-jcr' project's log4j.properties file used in the test cases that will turn on this logging, though this is commented out by default.

Modified: trunk/dna-jcr/src/test/resources/log4j.properties
===================================================================
--- trunk/dna-jcr/src/test/resources/log4j.properties	2010-01-11 01:21:32 UTC (rev 1590)
+++ trunk/dna-jcr/src/test/resources/log4j.properties	2010-01-11 02:18:28 UTC (rev 1591)
@@ -10,3 +10,6 @@
 # Set up the default logging to be INFO level, then override specific units
 log4j.logger.org.jboss.dna=INFO
 
+# This line turns on TRACING messages in the LuceneSearchIndex, which show which
+# operations are being performed on the index (including the data going into the index) ...
+#log4j.logger.org.jboss.dna.search.lucene=TRACE

Modified: trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/AbstractLuceneSearchEngine.java
===================================================================
--- trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/AbstractLuceneSearchEngine.java	2010-01-11 01:21:32 UTC (rev 1590)
+++ trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/AbstractLuceneSearchEngine.java	2010-01-11 02:18:28 UTC (rev 1591)
@@ -42,6 +42,7 @@
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.jboss.dna.common.collection.SimpleProblems;
+import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.graph.DnaLexicon;
 import org.jboss.dna.graph.ExecutionContext;
 import org.jboss.dna.graph.GraphI18n;
@@ -151,6 +152,7 @@
         protected final TypeSystem typeSystem;
         protected final PropertyFactory propertyFactory;
         protected final Workspaces<WorkspaceType> workspaces;
+        protected final Logger logger = Logger.getLogger(getClass());
 
         protected AbstractLuceneProcessor( String sourceName,
                                            ExecutionContext context,

Modified: trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchProcessor.java
===================================================================
--- trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchProcessor.java	2010-01-11 01:21:32 UTC (rev 1590)
+++ trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchProcessor.java	2010-01-11 02:18:28 UTC (rev 1591)
@@ -68,6 +68,7 @@
 public class LuceneSearchProcessor extends AbstractLuceneProcessor<LuceneSearchWorkspace, LuceneSearchSession> {
 
     protected static final Columns FULL_TEXT_RESULT_COLUMNS = new FullTextSearchResultColumns();
+    private final Logger logger = Logger.getLogger(getClass());
 
     protected LuceneSearchProcessor( String sourceName,
                                      ExecutionContext context,
@@ -165,13 +166,6 @@
         Location location = request.getActualLocationOfNode();
         assert location != null;
 
-        Logger logger = Logger.getLogger(getClass());
-        if (logger.isTraceEnabled()) {
-            logger.trace("indexing {0} in workspace \"{1}\"",
-                         location.getString(getExecutionContext().getNamespaceRegistry()),
-                         request.inWorkspace());
-        }
-
         try {
             session.setOrReplaceProperties(location, request.properties());
             session.recordChange();
@@ -218,6 +212,9 @@
         assert !readOnly;
         try {
             // Create a query to find all the nodes at or below the specified path (this efficiently handles the root path) ...
+            if (logger.isTraceEnabled()) {
+                logger.trace("index for \"{0}\" workspace: DEL '{1}' branch", request.inWorkspace(), stringFactory.create(path));
+            }
             Query query = session.findAllNodesAtOrBelow(path);
             // Now delete the documents from each index using this query, which we can reuse ...
             session.getContentWriter().deleteDocuments(query);

Modified: trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchSession.java
===================================================================
--- trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchSession.java	2010-01-11 01:21:32 UTC (rev 1590)
+++ trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchSession.java	2010-01-11 02:18:28 UTC (rev 1591)
@@ -57,6 +57,7 @@
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.Version;
+import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.graph.DnaLexicon;
 import org.jboss.dna.graph.JcrLexicon;
 import org.jboss.dna.graph.Location;
@@ -120,6 +121,7 @@
     private IndexWriter contentWriter;
     private IndexSearcher contentSearcher;
     private int numChanges;
+    private final Logger logger = Logger.getLogger(getClass());
 
     protected LuceneSearchSession( LuceneSearchWorkspace workspace,
                                    LuceneSearchProcessor processor ) {
@@ -205,6 +207,10 @@
      * @see org.jboss.dna.search.lucene.AbstractLuceneSearchEngine.WorkspaceSession#commit()
      */
     public void commit() {
+        if (logger.isTraceEnabled() && numChanges > 0) {
+            logger.trace("index for \"{0}\" workspace: COMMIT", workspace.getWorkspaceName());
+        }
+
         // Is optimization required ...
         final boolean optimize = workspace.isOptimizationRequired(numChanges);
         numChanges = 0;
@@ -256,6 +262,9 @@
      * @see org.jboss.dna.search.lucene.AbstractLuceneSearchEngine.WorkspaceSession#rollback()
      */
     public void rollback() {
+        if (logger.isTraceEnabled() && numChanges > 0) {
+            logger.trace("index for \"{0}\" workspace: ROLLBACK", workspace.getWorkspaceName());
+        }
         numChanges = 0;
         IOException ioError = null;
         RuntimeException runtimeError = null;
@@ -461,6 +470,7 @@
         if (fullTextSearchValue.length() != 0) {
             doc.add(new Field(ContentIndex.FULL_TEXT, fullTextSearchValue.toString(), Field.Store.NO, Field.Index.ANALYZED));
         }
+        logger.trace("index for \"{0}\" workspace: ADD {1}", workspace.getWorkspaceName(), doc);
         getContentWriter().updateDocument(new Term(ContentIndex.PATH, pathStr), doc);
     }
 



More information about the dna-commits mailing list