36.SOLR-1234: Multiple DIH does not work because all of them write to dataimport.properties. Use the handler name as the properties file name

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@787205 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2009-06-22 11:27:53 +00:00
parent ef46688646
commit b33d055a08
3 changed files with 31 additions and 7 deletions

View File

@ -1,4 +1,4 @@
Apache Solr - DataImportHandler Version 1.3-dev
Apache Solr - DataImportHandler Version 1.4-dev
Release Notes
Introduction
@ -150,6 +150,8 @@ New Features
35.SOLR-1235: disallow period (.) in entity names (noble)
36.SOLR-1234: Multiple DIH does not work because all of them write to dataimport.properties. Use the handler name as the properties file name (noble)
Optimizations
----------------------
1. SOLR-846: Reduce memory consumption during delta import by removing keys when used

View File

@ -34,6 +34,7 @@ import org.apache.solr.handler.RequestHandlerUtils;
import org.apache.solr.request.RawResponseWriter;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryResponse;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.update.processor.UpdateRequestProcessor;
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
import org.apache.solr.util.plugin.SolrCoreAware;
@ -74,6 +75,8 @@ public class DataImportHandler extends RequestHandlerBase implements
private boolean debugEnabled = true;
private String myName = "dataimport";
private Map<String , Object> coreScopeSession = new HashMap<String, Object>();
@Override
@ -85,6 +88,17 @@ public class DataImportHandler extends RequestHandlerBase implements
@SuppressWarnings("unchecked")
public void inform(SolrCore core) {
try {
//hack to get the name of this handler
for (Map.Entry<String, SolrRequestHandler> e : core.getRequestHandlers().entrySet()) {
SolrRequestHandler handler = e.getValue();
//this will not work if startup=lazy is set
if( this == handler) {
String name= e.getKey();
if(name.startsWith("/")){
myName = name.substring(1);
}
}
}
String debug = (String) initArgs.get(ENABLE_DEBUG);
if (debug != null && "no".equals(debug))
debugEnabled = false;
@ -263,7 +277,7 @@ public class DataImportHandler extends RequestHandlerBase implements
private SolrWriter getSolrWriter(final UpdateRequestProcessor processor,
final SolrResourceLoader loader, final DataImporter.RequestParams requestParams) {
return new SolrWriter(processor, loader.getConfigDir()) {
return new SolrWriter(processor, loader.getConfigDir(), myName) {
@Override
public boolean upload(SolrInputDocument document) {

View File

@ -49,12 +49,20 @@ public class SolrWriter {
private final String configDir;
private String persistFilename = IMPORTER_PROPERTIES;
DebugLogger debugLogger;
public SolrWriter(UpdateRequestProcessor processor, String confDir) {
this.processor = processor;
configDir = confDir;
}
public SolrWriter(UpdateRequestProcessor processor, String confDir, String filePrefix) {
this.processor = processor;
configDir = confDir;
if(filePrefix != null){
persistFilename = filePrefix+".properties";
}
}
public boolean upload(SolrInputDocument d) {
@ -126,11 +134,11 @@ public class SolrWriter {
try {
propInput = new FileInputStream(configDir
+ SolrWriter.IMPORTER_PROPERTIES);
+ persistFilename);
props.load(propInput);
log.info("Read " + SolrWriter.IMPORTER_PROPERTIES);
log.info("Read " + persistFilename);
} catch (Exception e) {
log.warn("Unable to read: " + SolrWriter.IMPORTER_PROPERTIES);
log.warn("Unable to read: " + persistFilename);
} finally {
try {
if (propInput != null)
@ -225,7 +233,7 @@ public class SolrWriter {
} catch (ParseException e) {
throw new DataImportHandlerException(DataImportHandlerException.WARN,
"Unable to read last indexed time from: "
+ SolrWriter.IMPORTER_PROPERTIES, e);
+ persistFilename, e);
}
return null;
}