lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1145198 - in /lucene/dev/trunk/solr: ./ core/src/java/org/apache/solr/core/ core/src/java/org/apache/solr/update/ core/src/java/org/apache/solr/update/processor/
Date Mon, 11 Jul 2011 15:02:43 GMT
Author: yonik
Date: Mon Jul 11 15:02:43 2011
New Revision: 1145198

URL: http://svn.apache.org/viewvc?rev=1145198&view=rev
Log:
SOLR-2615: log individual updates at DEBUG level, fix NPE when no unique key

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessor.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1145198&r1=1145197&r2=1145198&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Mon Jul 11 15:02:43 2011
@@ -317,6 +317,11 @@ New Features
   handler, as long as you also provide a XSL to transform them to a valid
   Solr input document.  (Upayavira, Uwe Schindler)
 
+* SOLR-2615: Log individual updates (adds and deletes) at the FINE level
+  before adding to the index.  Fix a null pointer exception in logging
+  when there was no unique key. (David Smiley via yonik)
+
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java?rev=1145198&r1=1145197&r2=1145198&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java Mon Jul 11 15:02:43
2011
@@ -659,8 +659,8 @@ public final class SolrCore implements S
     if (def == null) {
       // construct the default chain
       UpdateRequestProcessorFactory[] factories = new UpdateRequestProcessorFactory[]{
-              new RunUpdateProcessorFactory(),
-              new LogUpdateProcessorFactory()
+              new LogUpdateProcessorFactory(),
+              new RunUpdateProcessorFactory()
       };
       def = new UpdateRequestProcessorChain(factories, this);
     }

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java?rev=1145198&r1=1145197&r2=1145198&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java Mon Jul
11 15:02:43 2011
@@ -90,15 +90,15 @@ public class AddUpdateCommand extends Up
 
    public String getPrintableId(IndexSchema schema) {
      SchemaField sf = schema.getUniqueKeyField();
-     if (indexedId != null) {
-       return schema.getUniqueKeyField().getType().indexedToReadable(indexedId);
+     if (indexedId != null && sf != null) {
+       return sf.getType().indexedToReadable(indexedId);
      }
 
      if (doc != null) {
        return schema.printableUniqueKey(doc);
      }
 
-     if (solrDoc != null) {
+     if (solrDoc != null && sf != null) {
        SolrInputField field = solrDoc.getField(sf.getName());
        if (field != null) {
          return field.getFirstValue().toString();

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java?rev=1145198&r1=1145197&r2=1145198&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
Mon Jul 11 15:02:43 2011
@@ -31,12 +31,15 @@ import org.apache.solr.update.CommitUpda
 import org.apache.solr.update.DeleteUpdateCommand;
 import org.apache.solr.update.MergeIndexesCommand;
 import org.apache.solr.update.RollbackUpdateCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A logging processor.  This keeps track of all commands that have passed through
- * the chain and prints them on finish();
+ * the chain and prints them on finish().  At the Debug (FINE) level, a message
+ * will be logged for each command prior to the next stage in the chain.
  * 
- * If the Log level is not INFO the processor will not be created or added to the chain
+ * If the Log level is not >= INFO the processor will not be created or added to the chain.
  * 
  * @since solr 1.3
  */
@@ -54,11 +57,14 @@ public class LogUpdateProcessorFactory e
 
   @Override
   public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp,
UpdateRequestProcessor next) {
-    boolean doLog = LogUpdateProcessor.log.isInfoEnabled();
+    final Logger logger = LoggerFactory.getLogger(LogUpdateProcessor.class);
+    boolean doLog = logger.isInfoEnabled();
     // LogUpdateProcessor.log.error("Will Log=" + doLog);
     if( doLog ) {
       // only create the log processor if we will use it
-      return new LogUpdateProcessor(req, rsp, this, next);
+      final LogUpdateProcessor processor = new LogUpdateProcessor(req, rsp, this, next);
+      assert processor.log == logger;
+      return processor;
     }
     return null;
   }
@@ -78,6 +84,8 @@ class LogUpdateProcessor extends UpdateR
 
   private final int maxNumToLog;
 
+  private final boolean logDebug = log.isDebugEnabled();//cache to avoid volatile-read
+
   public LogUpdateProcessor(SolrQueryRequest req, SolrQueryResponse rsp, LogUpdateProcessorFactory
factory, UpdateRequestProcessor next) {
     super( next );
     this.req = req;
@@ -91,8 +99,6 @@ class LogUpdateProcessor extends UpdateR
   
   @Override
   public void processAdd(AddUpdateCommand cmd) throws IOException {
-    if (next != null) next.processAdd(cmd);
-
     // Add a list of added id's to the response
     if (adds == null) {
       adds = new ArrayList<String>();
@@ -102,14 +108,15 @@ class LogUpdateProcessor extends UpdateR
     if (adds.size() < maxNumToLog) {
       adds.add(cmd.getPrintableId(req.getSchema()));
     }
+    if (logDebug) { log.debug("add {}", cmd.getPrintableId(req.getSchema())); }
 
     numAdds++;
+
+    if (next != null) next.processAdd(cmd);
   }
 
   @Override
   public void processDelete( DeleteUpdateCommand cmd ) throws IOException {
-    if (next != null) next.processDelete(cmd);
-
     if (cmd.id != null) {
       if (deletes == null) {
         deletes = new ArrayList<String>();
@@ -118,26 +125,33 @@ class LogUpdateProcessor extends UpdateR
       if (deletes.size() < maxNumToLog) {
         deletes.add(cmd.id);
       }
+      if (logDebug) { log.debug("delete {}", cmd.id); }
     } else {
       if (toLog.size() < maxNumToLog) {
         toLog.add("deleteByQuery", cmd.query);
       }
+      if (logDebug) { log.debug("deleteByQuery {}", cmd.query); }
     }
     numDeletes++;
+
+    if (next != null) next.processDelete(cmd);
   }
 
   @Override
   public void processMergeIndexes(MergeIndexesCommand cmd) throws IOException {
-    if (next != null) next.processMergeIndexes(cmd);
-
     toLog.add("mergeIndexes", cmd.toString());
+    if (logDebug) { log.debug("mergeIndexes {}",cmd.toString()); }
+
+    if (next != null) next.processMergeIndexes(cmd);
   }
 
   @Override
   public void processCommit( CommitUpdateCommand cmd ) throws IOException {
+    final String msg = cmd.optimize ? "optimize" : "commit";
+    toLog.add(msg, "");
+    if (logDebug) { log.debug(msg); }
+
     if (next != null) next.processCommit(cmd);
-    
-    toLog.add(cmd.optimize ? "optimize" : "commit", "");
   }
 
   /**
@@ -145,15 +159,18 @@ class LogUpdateProcessor extends UpdateR
    */
   @Override
   public void processRollback( RollbackUpdateCommand cmd ) throws IOException {
-    if (next != null) next.processRollback(cmd);
-    
     toLog.add("rollback", "");
+    if (logDebug) { log.debug("rollback"); }
+
+    if (next != null) next.processRollback(cmd);
   }
 
 
   @Override
   public void finish() throws IOException {
     if (next != null) next.finish();
+
+    // LOG A SUMMARY WHEN ALL DONE (INFO LEVEL)
     
     // TODO: right now, update requests are logged twice...
     // this will slow down things compared to Solr 1.2

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessor.java?rev=1145198&r1=1145197&r2=1145198&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessor.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessor.java
Mon Jul 11 15:02:43 2011
@@ -41,7 +41,7 @@ import org.apache.solr.update.RollbackUp
  * @since solr 1.3
  */
 public abstract class UpdateRequestProcessor {
-  protected static Logger log = LoggerFactory.getLogger(UpdateRequestProcessor.class);
+  protected final Logger log = LoggerFactory.getLogger(getClass());
 
   protected final UpdateRequestProcessor next;
 



Mime
View raw message