lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1294466 - in /lucene/dev/trunk/solr: core/src/java/org/apache/solr/cloud/ core/src/java/org/apache/solr/update/ core/src/java/org/apache/solr/update/processor/ test-framework/src/java/org/apache/solr/
Date Tue, 28 Feb 2012 05:29:52 GMT
Author: yonik
Date: Tue Feb 28 05:29:52 2012
New Revision: 1294466

URL: http://svn.apache.org/viewvc?rev=1294466&view=rev
Log:
improve logging

Modified:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.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/UpdateLog.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.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
    lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java?rev=1294466&r1=1294465&r2=1294466&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java Tue Feb
28 05:29:52 2012
@@ -45,6 +45,8 @@ import org.apache.solr.handler.Replicati
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrRequestHandler;
+import org.apache.solr.request.SolrRequestInfo;
+import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.update.CommitUpdateCommand;
 import org.apache.solr.update.PeerSync;
 import org.apache.solr.update.UpdateLog;
@@ -186,17 +188,31 @@ public class RecoveryStrategy extends Th
     server.request(prepCmd);
     server.shutdown();
   }
-  
+
   @Override
   public void run() {
-    boolean replayed = false;
-    boolean succesfulRecovery = false;
-    
     SolrCore core = cc.getCore(coreName);
     if (core == null) {
       SolrException.log(log, "SolrCore not found - cannot recover:" + coreName);
       return;
     }
+
+    // set request info for logging
+    SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
+    
+    try {
+      doRecovery(core);
+    } finally {
+      SolrRequestInfo.clearRequestInfo();
+    }
+  }
+  
+  public void doRecovery(SolrCore core) {
+    boolean replayed = false;
+    boolean succesfulRecovery = false;
+
     UpdateLog ulog;
     try {
       ulog = core.getUpdateHandler().getUpdateLog();

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1294466&r1=1294465&r2=1294466&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java Tue Feb 28
05:29:52 2012
@@ -610,6 +610,8 @@ public final class ZkController {
             // minutes or more!
             // TODO: public as recovering in the mean time?
             // TODO: in the future we could do peerync in parallel with recoverFromLog
+          } else {
+            log.info("No LogReplay needed for core="+core.getName() + " baseURL=" + baseUrl);
           }
         }
         

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=1294466&r1=1294465&r2=1294466&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 Tue Feb
28 05:29:52 2012
@@ -117,7 +117,7 @@ public class AddUpdateCommand extends Up
    @Override
   public String toString() {
      StringBuilder sb = new StringBuilder(super.toString());
-     if (indexedId != null) sb.append(",id=").append(indexedId);
+     sb.append(",id=").append(getPrintableId());
      if (!overwrite) sb.append(",overwrite=").append(overwrite);
      if (commitWithin != -1) sb.append(",commitWithin=").append(commitWithin);
      sb.append('}');

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/UpdateLog.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/UpdateLog.java?rev=1294466&r1=1294465&r2=1294466&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/UpdateLog.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/UpdateLog.java Tue Feb 28 05:29:52
2012
@@ -624,6 +624,7 @@ public class UpdateLog implements Plugin
       if (tlog != null) {
         if (committed) {
           // record a commit
+          log.info("Recording current log as closed for " + uhandler.core);
           CommitUpdateCommand cmd = new CommitUpdateCommand(new LocalSolrQueryRequest(uhandler.core,
new ModifiableSolrParams((SolrParams)null)), false);
           tlog.writeCommit(cmd);
         }

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java?rev=1294466&r1=1294465&r2=1294466&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
Tue Feb 28 05:29:52 2012
@@ -61,10 +61,14 @@ import org.apache.solr.update.UpdateLog;
 import org.apache.solr.update.VersionBucket;
 import org.apache.solr.update.VersionInfo;
 import org.apache.zookeeper.KeeperException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 // NOT mt-safe... create a new processor for each add thread
 // TODO: we really should not wait for distrib after local? unless a certain replication
factor is asked for
 public class DistributedUpdateProcessor extends UpdateRequestProcessor {
+  public final static Logger log = LoggerFactory.getLogger(DistributedUpdateProcessor.class);
+
   public static final String SEEN_LEADER = "leader";
   public static final String COMMIT_END_POINT = "commit_end_point";
   public static final String DELETE_BY_QUERY_LEVEL = "dbq_level";

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java?rev=1294466&r1=1294465&r2=1294466&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java
Tue Feb 28 05:29:52 2012
@@ -40,6 +40,8 @@ import org.apache.solr.schema.FieldType;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.update.AddUpdateCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Reusable base class for UpdateProcessors that will consider 
@@ -57,7 +59,8 @@ import org.apache.solr.update.AddUpdateC
  */
 public abstract class FieldMutatingUpdateProcessor 
   extends UpdateRequestProcessor {
-  
+  public final static Logger log = LoggerFactory.getLogger(FieldMutatingUpdateProcessor.class);
+
   private final FieldNameSelector selector;
   public FieldMutatingUpdateProcessor(FieldNameSelector selector,
                                       UpdateRequestProcessor next) {

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=1294466&r1=1294465&r2=1294466&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
Tue Feb 28 05:29:52 2012
@@ -56,20 +56,13 @@ public class LogUpdateProcessorFactory e
 
   @Override
   public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp,
UpdateRequestProcessor next) {
-    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
-      final LogUpdateProcessor processor = new LogUpdateProcessor(req, rsp, this, next);
-      assert processor.log == logger;
-      return processor;
-    }
-    return null;
+    return LogUpdateProcessor.log.isInfoEnabled() ? new LogUpdateProcessor(req, rsp, this,
next) : null;
   }
 }
 
 class LogUpdateProcessor extends UpdateRequestProcessor {
+  public final static Logger log = LoggerFactory.getLogger(UpdateRequestProcessor.class);
+
   private final SolrQueryRequest req;
   private final SolrQueryResponse rsp;
   private final NamedList<Object> toLog;
@@ -98,7 +91,7 @@ class LogUpdateProcessor extends UpdateR
   
   @Override
   public void processAdd(AddUpdateCommand cmd) throws IOException {
-    if (logDebug) { log.debug(cmd.toString()); }
+    if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString()); }
 
     // call delegate first so we can log things like the version that get set later
     if (next != null) next.processAdd(cmd);
@@ -121,7 +114,7 @@ class LogUpdateProcessor extends UpdateR
 
   @Override
   public void processDelete( DeleteUpdateCommand cmd ) throws IOException {
-    if (logDebug) { log.debug(cmd.toString()); }
+    if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString()); }
     if (next != null) next.processDelete(cmd);
 
     if (cmd.isDeleteById()) {
@@ -149,7 +142,7 @@ class LogUpdateProcessor extends UpdateR
 
   @Override
   public void processMergeIndexes(MergeIndexesCommand cmd) throws IOException {
-    if (logDebug) { log.debug(cmd.toString()); }
+    if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString()); }
     if (next != null) next.processMergeIndexes(cmd);
 
     toLog.add("mergeIndexes", cmd.toString());
@@ -157,7 +150,7 @@ class LogUpdateProcessor extends UpdateR
 
   @Override
   public void processCommit( CommitUpdateCommand cmd ) throws IOException {
-    if (logDebug) { log.debug(cmd.toString()); }
+    if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString()); }
     if (next != null) next.processCommit(cmd);
 
 
@@ -170,7 +163,7 @@ class LogUpdateProcessor extends UpdateR
    */
   @Override
   public void processRollback( RollbackUpdateCommand cmd ) throws IOException {
-    if (logDebug) { log.debug(cmd.toString()); }
+    if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString()); }
     if (next != null) next.processRollback(cmd);
 
     toLog.add("rollback", "");
@@ -179,17 +172,12 @@ class LogUpdateProcessor extends UpdateR
 
   @Override
   public void finish() throws IOException {
+    if (logDebug) { log.debug("PRE_UPDATE finish()"); }
     if (next != null) next.finish();
-    if (logDebug) { log.debug("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
-    // we should have extra log info on the SolrQueryResponse, to
-    // be logged by SolrCore
-    
-    // if id lists were truncated, show how many more there were
+
 
     NamedList<Object> stdLog = rsp.getToLog();
 
@@ -205,6 +193,7 @@ class LogUpdateProcessor extends UpdateR
     }
     stdLog.clear();   // make it so SolrCore.exec won't log this again
 
+    // if id lists were truncated, show how many more there were
     if (adds != null && numAdds > maxNumToLog) {
       adds.add("... (" + numAdds + " adds)");
     }

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=1294466&r1=1294465&r2=1294466&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
Tue Feb 28 05:29:52 2012
@@ -41,8 +41,6 @@ import org.apache.solr.update.RollbackUp
  * @since solr 1.3
  */
 public abstract class UpdateRequestProcessor {
-  protected final Logger log = LoggerFactory.getLogger(getClass());
-
   protected final UpdateRequestProcessor next;
 
   public UpdateRequestProcessor( UpdateRequestProcessor next) {

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1294466&r1=1294465&r2=1294466&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Tue
Feb 28 05:29:52 2012
@@ -57,6 +57,9 @@ import java.io.IOException;
 import java.io.StringWriter;
 import java.util.*;
 import java.util.Map.Entry;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
 
 /**
  * A junit4 Solr test harness that extends LuceneTestCaseJ4.
@@ -65,8 +68,10 @@ import java.util.Map.Entry;
  */
 public abstract class SolrTestCaseJ4 extends LuceneTestCase {
 
+
   @BeforeClass
   public static void beforeClassSolrTestCase() throws Exception {
+    setupLogging();
     startTrackingSearchers();
     startTrackingZkClients();
     ignoreException("ignore_exception");
@@ -92,6 +97,32 @@ public abstract class SolrTestCaseJ4 ext
     super.tearDown();
   }
 
+
+  public static void setupLogging() {
+    boolean register = false;
+    Handler[] handlers = java.util.logging.Logger.getLogger("").getHandlers();
+    ConsoleHandler consoleHandler = null;
+    for (Handler handler : handlers) {
+      if (handler instanceof ConsoleHandler) {
+        consoleHandler = (ConsoleHandler)handler;
+        break;
+      }
+    }
+
+    if (consoleHandler == null) {
+      consoleHandler = new ConsoleHandler();
+      register = true;
+    }
+
+    consoleHandler.setLevel(Level.ALL);
+    consoleHandler.setFormatter(new SolrLogFormatter());
+
+    if (register) {
+      java.util.logging.Logger.getLogger("").addHandler(consoleHandler);
+    }
+  }
+
+
   /** Call initCore in @BeforeClass to instantiate a solr core in your test class.
    * deleteCore will be called for you via SolrTestCaseJ4 @AfterClass */
   public static void initCore(String config, String schema) throws Exception {



Mime
View raw message