SOLR-269 -- removing incremental time logging. This now has a single log statement for all processed commands.

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@552986 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2007-07-03 21:25:21 +00:00
parent 4406ef88af
commit aa2135f34f
2 changed files with 23 additions and 40 deletions

View File

@ -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 UpdateRequestProcessor
public 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 SolrDocument
public 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 UpdateRequestProcessor
id = 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)+"]");
}
}

View File

@ -153,7 +153,7 @@ public class XmlUpdateRequestHandler extends RequestHandlerBase
switch (event) {
case XMLStreamConstants.END_DOCUMENT:
parser.close();
return processor.getResponse();
return processor.finish();
case XMLStreamConstants.START_ELEMENT:
String currTag = parser.getLocalName();