Apache Solr open-source search software
SOLR-269 -- removing incremental time logging. This now has a single log statement for all processed commands.
Ryan McKinleyaa2135f34f19
diff --git a/src/java/org/apache/solr/handler/UpdateRequestProcessor.java b/src/java/org/apache/solr/handler/UpdateRequestProcessor.javaindex 1de403af208..3f2e0d12a7f 100644--- a/src/java/org/apache/solr/handler/UpdateRequestProcessor.java+++ b/src/java/org/apache/solr/handler/UpdateRequestProcessor.java@@ -18,12 +18,13 @@package org.apache.solr.handler;import java.io.IOException;+import java.util.ArrayList;+import java.util.List;import java.util.logging.Logger;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.SolrInputField;import org.apache.solr.common.util.NamedList;-import org.apache.solr.core.SolrCore;import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.schema.IndexSchema;import org.apache.solr.schema.SchemaField;@@ -45,7 +46,6 @@ import org.apache.solr.update.UpdateHandler;* This implementation (the default) passes the request command (as is) to the updateHandler* and adds debug info to the response.*- * @author ryan* @since solr 1.3*/public class UpdateRequestProcessor@@ -53,53 +53,40 @@ public class UpdateRequestProcessorpublic static Logger log = Logger.getLogger(UpdateRequestProcessor.class.getName());protected final SolrQueryRequest req;- protected final SolrCore core;- protected final IndexSchema schema;protected final UpdateHandler updateHandler;- protected final SchemaField uniqueKeyField;protected final long startTime;protected final NamedList<Object> response;+ // hold on to the added list for logging and the response+ protected List<Object> addedIds;+public UpdateRequestProcessor( SolrQueryRequest req ){this.req = req;-- core = req.getCore();- schema = core.getSchema();- updateHandler = core.getUpdateHandler();- uniqueKeyField = schema.getUniqueKeyField();- startTime = System.currentTimeMillis();-- // A place to put our output- response = new NamedList<Object>();+ this.updateHandler = req.getCore().getUpdateHandler();+ this.startTime = System.currentTimeMillis();+ this.response = new NamedList<Object>();}/*** @return The response information*/- public NamedList<Object> getResponse()+ public NamedList<Object> finish(){+ long elapsed = System.currentTimeMillis() - startTime;+ log.info( "update"+response+" 0 " + (elapsed) );return response;}public void processDelete( DeleteUpdateCommand cmd ) throws IOException{- long start = System.currentTimeMillis();if( cmd.id != null ) {updateHandler.delete( cmd );- long now = System.currentTimeMillis();- log.info("delete(id " + cmd.id + ") 0 " + (now - start) + " ["+(now-startTime)+"]");-response.add( "delete", cmd.id );}else {- // TODO? if cmd.query == "*:* it should do something special-updateHandler.deleteByQuery( cmd );- long now = System.currentTimeMillis();- log.info("deleteByQuery(id " + cmd.query + ") 0 " + (now - start) + " ["+(now-startTime)+"]");-- response.add( "deleteByQuery", cmd.id );+ response.add( "deleteByQuery", cmd.query );}}@@ -107,20 +94,18 @@ public class UpdateRequestProcessor{updateHandler.commit(cmd);response.add(cmd.optimize ? "optimize" : "commit", "");- long now = System.currentTimeMillis();-- if (cmd.optimize) {- log.info("optimize 0 " + (now - startTime)+ " ["+(now-startTime)+"]");- }- else {- log.info("commit 0 " + (now - startTime)+ " ["+(now-startTime)+"]");- }}- // TODO -- in the future, the update command should just hold onto a SolrDocumentpublic void processAdd( AddUpdateCommand cmd, SolrInputDocument doc ) throws IOException{- long start = System.currentTimeMillis();+ // Add a list of added id's to the response+ if( addedIds == null ) {+ addedIds = new ArrayList<Object>();+ response.add( "added", addedIds );+ }++ IndexSchema schema = req.getSchema();+ SchemaField uniqueKeyField = schema.getUniqueKeyField();Object id = null;if (uniqueKeyField != null) {SolrInputField f = doc.getField( uniqueKeyField.getName() );@@ -128,11 +113,9 @@ public class UpdateRequestProcessorid = f.getFirstValue();}}+ addedIds.add( id );+cmd.doc = DocumentBuilder.toDocument( doc, schema );updateHandler.addDoc(cmd);- response.add( "added", id );-- long now = System.currentTimeMillis();- log.info("added id={" + id + "} in " + (now - start) + "ms ["+(now-startTime)+"]");}}diff --git a/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java b/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.javaindex 317f6791632..a55ee780239 100644--- a/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java+++ b/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java@@ -153,7 +153,7 @@ public class XmlUpdateRequestHandler extends RequestHandlerBaseswitch (event) {case XMLStreamConstants.END_DOCUMENT:parser.close();- return processor.getResponse();+ return processor.finish();case XMLStreamConstants.START_ELEMENT:String currTag = parser.getLocalName();