SOLR-2382 - regression . debug not working

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1152692 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2011-08-01 06:01:35 +00:00
parent 31e3b272c5
commit 5fca7fc938
4 changed files with 27 additions and 17 deletions

View File

@ -74,8 +74,6 @@ public class DataImportHandler extends RequestHandlerBase implements
private Map<String, Properties> dataSources = new HashMap<String, Properties>();
private List<SolrInputDocument> debugDocuments;
private boolean debugEnabled = true;
private String myName = "dataimport";
@ -197,16 +195,18 @@ public class DataImportHandler extends RequestHandlerBase implements
UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp);
SolrResourceLoader loader = req.getCore().getResourceLoader();
SolrWriter sw = getSolrWriter(processor, loader, requestParams, req);
if (requestParams.debug) {
if (debugEnabled) {
// Synchronous request for the debug mode
importer.runCmd(requestParams, sw);
rsp.add("mode", "debug");
rsp.add("documents", debugDocuments);
if (sw.debugLogger != null)
rsp.add("verbose-output", sw.debugLogger.output);
debugDocuments = null;
rsp.add("documents", requestParams.debugDocuments);
if (requestParams.debugVerboseOutput != null) {
rsp.add("verbose-output", requestParams.debugVerboseOutput);
}
requestParams.debugDocuments = new ArrayList<SolrInputDocument>(0);
requestParams.debugVerboseOutput = null;
} else {
message = DataImporter.MSG.DEBUG_NOT_ENABLED;
}
@ -215,7 +215,7 @@ public class DataImportHandler extends RequestHandlerBase implements
if(requestParams.contentStream == null && !requestParams.syncMode){
importer.runAsync(requestParams, sw);
} else {
importer.runCmd(requestParams, sw);
importer.runCmd(requestParams, sw);
}
}
} else if (DataImporter.RELOAD_CONF_CMD.equals(command)) {
@ -285,11 +285,6 @@ public class DataImportHandler extends RequestHandlerBase implements
@Override
public boolean upload(SolrInputDocument document) {
try {
if (requestParams.debug) {
if (debugDocuments == null)
debugDocuments = new ArrayList<SolrInputDocument>();
debugDocuments.add(document);
}
return super.upload(document);
} catch (RuntimeException e) {
LOG.error( "Exception while adding: " + document, e);

View File

@ -18,11 +18,13 @@
package org.apache.solr.handler.dataimport;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrCore;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.SystemIdResolver;
import org.apache.solr.common.util.XMLErrorLogger;
@ -515,7 +517,7 @@ public class DataImporter {
public String command = null;
public boolean debug = false;
public boolean verbose = false;
public boolean syncMode = false;
@ -537,6 +539,10 @@ public class DataImporter {
public String dataConfig;
public ContentStream contentStream;
public List<SolrInputDocument> debugDocuments = new ArrayList<SolrInputDocument>(0);
public NamedList debugVerboseOutput = null;
public RequestParams() {
}

View File

@ -72,11 +72,13 @@ public class DocBuilder {
private static final String PARAM_WRITER_IMPL = "writerImpl";
private static final String DEFAULT_WRITER_NAME = "SolrWriter";
private DebugLogger debugLogger;
private DataImporter.RequestParams reqParams;
@SuppressWarnings("unchecked")
public DocBuilder(DataImporter dataImporter, SolrWriter solrWriter, DIHPropertiesWriter propWriter, DataImporter.RequestParams reqParams) {
INSTANCE.set(this);
this.dataImporter = dataImporter;
this.reqParams = reqParams;
this.propWriter = propWriter;
DataImporter.QUERY_COUNT.set(importStatistics.queryCount);
requestParameters = reqParams;
@ -262,6 +264,9 @@ public class DocBuilder {
if (writer != null) {
writer.close();
}
if(requestParameters.debug) {
requestParameters.debugVerboseOutput = getDebugLogger().output;
}
}
}
@ -514,6 +519,9 @@ public class DocBuilder {
LOG.debug("adding a doc "+docWrapper);
}
boolean result = writer.upload(docWrapper);
if(reqParams.debug) {
reqParams.debugDocuments.add(docWrapper);
}
docWrapper = null;
if (result){
importStatistics.docCount.incrementAndGet();
@ -672,6 +680,9 @@ public class DocBuilder {
return;
if (!doc.isEmpty()) {
boolean result = writer.upload(doc);
if(reqParams.debug) {
reqParams.debugDocuments.add(doc);
}
doc = null;
if (result){
importStatistics.docCount.incrementAndGet();

View File

@ -44,8 +44,6 @@ public class SolrWriter implements DIHWriter {
private final UpdateRequestProcessor processor;
DebugLogger debugLogger;
SolrQueryRequest req;
public SolrWriter(UpdateRequestProcessor processor, SolrQueryRequest req) {