SOLR-832 -- Rows parameter is not honored in non-debug mode and can abort a running import in debug mode.

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@709352 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2008-10-31 05:32:03 +00:00
parent 9071230c73
commit 96b0ebc980
3 changed files with 13 additions and 10 deletions

View File

@ -43,6 +43,9 @@ Bug Fixes
4. SOLR-742: Add ability to create dynamic fields with custom DataImportHandler transformers
(Wojtek Piaseczny, Noble Paul, shalin)
5. SOLR-832: Rows parameter is not honored in non-debug mode and can abort a running import in debug mode.
(Akshay Ukey, shalin)
Documentation
----------------------

View File

@ -74,8 +74,6 @@ public class DataImportHandler extends RequestHandlerBase implements
private Map<String, Properties> dataSources = new HashMap<String, Properties>();
private DataImporter.RequestParams requestParams;
private List<SolrInputDocument> debugDocuments;
private boolean debugEnabled = true;
@ -119,7 +117,7 @@ public class DataImportHandler extends RequestHandlerBase implements
throws Exception {
rsp.setHttpCaching(false);
SolrParams params = req.getParams();
requestParams = new DataImporter.RequestParams(getParamsMap(params));
DataImporter.RequestParams requestParams = new DataImporter.RequestParams(getParamsMap(params));
String command = requestParams.command;
if (DataImporter.SHOW_CONF_CMD.equals(command)) {
@ -178,7 +176,7 @@ public class DataImportHandler extends RequestHandlerBase implements
req.getCore().getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR));
UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp);
SolrResourceLoader loader = req.getCore().getResourceLoader();
SolrWriter sw = getSolrWriter(processor, loader);
SolrWriter sw = getSolrWriter(processor, loader, requestParams);
if (requestParams.debug) {
if (debugEnabled) {
@ -261,7 +259,7 @@ public class DataImportHandler extends RequestHandlerBase implements
}
private SolrWriter getSolrWriter(final UpdateRequestProcessor processor,
final SolrResourceLoader loader) {
final SolrResourceLoader loader, final DataImporter.RequestParams requestParams) {
return new SolrWriter(processor, loader.getConfigDir()) {
@ -272,10 +270,11 @@ public class DataImportHandler extends RequestHandlerBase implements
if (debugDocuments == null)
debugDocuments = new ArrayList<SolrInputDocument>();
debugDocuments.add(document);
if (debugDocuments.size() >= requestParams.rows) {
// Abort this operation now
importer.getDocBuilder().abort();
}
}
if (importer.getDocBuilder().importStatistics.docCount.get() >= requestParams.rows) {
// Abort this operation now
importer.getDocBuilder().abort();
LOG.info("Indexing stopped at docCount = " + importer.getDocBuilder().importStatistics.docCount);
}
return super.upload(document);
} catch (RuntimeException e) {

View File

@ -474,7 +474,7 @@ public class DataImporter {
public int start = 0;
public int rows = 10;
public int rows = Integer.MAX_VALUE;
public boolean clean = true;
@ -493,6 +493,7 @@ public class DataImporter {
if ("on".equals(requestParams.get("debug"))) {
debug = true;
rows = 10;
// Set default values suitable for debug mode
commit = false;
clean = false;