lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r911216 - in /lucene/solr/trunk: CHANGES.txt src/java/org/apache/solr/core/SolrCore.java
Date Wed, 17 Feb 2010 23:09:13 GMT
Author: hossman
Date: Wed Feb 17 23:09:12 2010
New Revision: 911216

URL: http://svn.apache.org/viewvc?rev=911216&view=rev
Log:
SOLR-1679: make SolrCore.execute pay attention to log level before building up big log message
strings

Modified:
    lucene/solr/trunk/CHANGES.txt
    lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java

Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=911216&r1=911215&r2=911216&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Wed Feb 17 23:09:12 2010
@@ -91,6 +91,10 @@
 Optimizations
 ----------------------
 
+* SOLR-1679: Don't build up string messages in SolrCore.execute unless they
+  are necessary for the current log level.
+  (Fuad Efendi and hossman)
+
 Bug Fixes
 ----------------------
 

Modified: lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?rev=911216&r1=911215&r2=911216&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java Wed Feb 17 23:09:12 2010
@@ -1299,29 +1299,38 @@
 
   public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse
rsp) {
     if (handler==null) {
-      log.warn(logid+"Null Request Handler '" + req.getParams().get(CommonParams.QT) +"'
:" + req);
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Null Request Handler '"
+ req.getParams().get(CommonParams.QT) + "'", true);
+      String msg = "Null Request Handler '" +
+        req.getParams().get(CommonParams.QT) + "'";
+      
+      if (log.isWarnEnabled()) log.warn(logid + msg + ":" + req);
+      
+      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, msg, true);
     }
     // setup response header and handle request
     final NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
     rsp.add("responseHeader", responseHeader);
+
+    // toLog is a local ref to the same NamedList used by the request
     NamedList toLog = rsp.getToLog();
-    //toLog.add("core", getName());
+    // for back compat, we set these now just in case other code
+    // are expecting them during handleRequest
     toLog.add("webapp", req.getContext().get("webapp"));
     toLog.add("path", req.getContext().get("path"));
     toLog.add("params", "{" + req.getParamString() + "}");
+    
     handler.handleRequest(req,rsp);
     setResponseHeaderValues(handler,req,rsp);
-    StringBuilder sb = new StringBuilder();
-    for (int i=0; i<toLog.size(); i++) {
-     	String name = toLog.getName(i);
-     	Object val = toLog.getVal(i);
-     	sb.append(name).append("=").append(val).append(" ");
-    }
-    log.info(logid +  sb.toString());
-    /*log.info(logid+"" + req.getContext().get("path") + " "
-            + req.getParamString()+ " 0 "+
-       (int)(rsp.getEndTime() - req.getStartTime()));*/
+    
+    if (log.isInfoEnabled()) {
+      StringBuilder sb = new StringBuilder(logid);
+      for (int i=0; i<toLog.size(); i++) {
+        String name = toLog.getName(i);
+        Object val = toLog.getVal(i);
+        sb.append(name).append("=").append(val).append(" ");
+      }
+      log.info(sb.toString());
+    }
+
   }
 
   /**



Mime
View raw message