From b7fa7354fcea63e56bcc16e522becbc8312defac Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Fri, 24 Feb 2012 01:40:10 +0000 Subject: [PATCH] logging: log versions of update commands, improve toString of solr docs git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1293055 13f79535-47bb-0310-9956-ffa450edef68 --- .../processor/LogUpdateProcessorFactory.java | 38 ++++++++++--------- .../org/apache/solr/common/SolrDocument.java | 2 +- .../apache/solr/common/SolrInputDocument.java | 2 +- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java index 37b381328c3..76fc6f1a8c3 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java +++ b/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java @@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory; */ public class LogUpdateProcessorFactory extends UpdateRequestProcessorFactory { - int maxNumToLog = 8; + int maxNumToLog = 10; @Override public void init( final NamedList args ) { @@ -99,6 +99,11 @@ class LogUpdateProcessor extends UpdateRequestProcessor { @Override public void processAdd(AddUpdateCommand cmd) throws IOException { + if (logDebug) { log.debug(cmd.toString()); } + + // call delegate first so we can log things like the version that get set later + if (next != null) next.processAdd(cmd); + // Add a list of added id's to the response if (adds == null) { adds = new ArrayList(); @@ -111,15 +116,15 @@ class LogUpdateProcessor extends UpdateRequestProcessor { if (version != 0) msg = msg + " (" + version + ')'; adds.add(msg); } - if (logDebug) { log.debug("add {}", cmd.getPrintableId()); } numAdds++; - - if (next != null) next.processAdd(cmd); } @Override public void processDelete( DeleteUpdateCommand cmd ) throws IOException { + if (logDebug) { log.debug(cmd.toString()); } + if (next != null) next.processDelete(cmd); + if (cmd.isDeleteById()) { if (deletes == null) { deletes = new ArrayList(); @@ -131,36 +136,34 @@ class LogUpdateProcessor extends UpdateRequestProcessor { if (version != 0) msg = msg + " (" + version + ')'; deletes.add(msg); } - if (logDebug) { log.debug("delete {}", cmd.getId()); } } else { if (toLog.size() < maxNumToLog) { long version = cmd.getVersion(); String msg = cmd.query; if (version != 0) msg = msg + " (" + version + ')'; - toLog.add("deleteByQuery", cmd.query); + toLog.add("deleteByQuery", msg); } - if (logDebug) { log.debug("deleteByQuery {}", cmd.getQuery()); } } numDeletes++; - if (next != null) next.processDelete(cmd); } @Override public void processMergeIndexes(MergeIndexesCommand cmd) throws IOException { - toLog.add("mergeIndexes", cmd.toString()); - if (logDebug) { log.debug("mergeIndexes {}",cmd.toString()); } - + if (logDebug) { log.debug(cmd.toString()); } if (next != null) next.processMergeIndexes(cmd); + + toLog.add("mergeIndexes", cmd.toString()); } @Override public void processCommit( CommitUpdateCommand cmd ) throws IOException { + if (logDebug) { log.debug(cmd.toString()); } + if (next != null) next.processCommit(cmd); + + final String msg = cmd.optimize ? "optimize" : "commit"; toLog.add(msg, ""); - if (logDebug) { log.debug(msg); } - - if (next != null) next.processCommit(cmd); } /** @@ -168,16 +171,17 @@ class LogUpdateProcessor extends UpdateRequestProcessor { */ @Override public void processRollback( RollbackUpdateCommand cmd ) throws IOException { - toLog.add("rollback", ""); - if (logDebug) { log.debug("rollback"); } - + if (logDebug) { log.debug(cmd.toString()); } if (next != null) next.processRollback(cmd); + + toLog.add("rollback", ""); } @Override public void finish() throws IOException { if (next != null) next.finish(); + if (logDebug) { log.debug("finish"); } // LOG A SUMMARY WHEN ALL DONE (INFO LEVEL) diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrDocument.java b/solr/solrj/src/java/org/apache/solr/common/SolrDocument.java index cd2aa5d737e..2eefcd49173 100644 --- a/solr/solrj/src/java/org/apache/solr/common/SolrDocument.java +++ b/solr/solrj/src/java/org/apache/solr/common/SolrDocument.java @@ -187,7 +187,7 @@ public class SolrDocument implements Map, Iterable, Iterable