lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject svn commit: r787205 - in /lucene/solr/trunk/contrib/dataimporthandler: CHANGES.txt src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java src/main/java/org/apache/solr/handler/dataimport/SolrWriter.java
Date Mon, 22 Jun 2009 11:27:53 GMT
Author: noble
Date: Mon Jun 22 11:27:53 2009
New Revision: 787205

URL: http://svn.apache.org/viewvc?rev=787205&view=rev
Log:
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

Modified:
    lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/SolrWriter.java

Modified: lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt?rev=787205&r1=787204&r2=787205&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt (original)
+++ lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt Mon Jun 22 11:27:53 2009
@@ -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 @@
               
 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

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java?rev=787205&r1=787204&r2=787205&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java
Mon Jun 22 11:27:53 2009
@@ -34,6 +34,7 @@
 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 @@
 
   private boolean debugEnabled = true;
 
+  private String myName = "dataimport";
+
   private Map<String , Object> coreScopeSession = new HashMap<String, Object>();
 
   @Override
@@ -85,6 +88,17 @@
   @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 @@
   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) {

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/SolrWriter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/SolrWriter.java?rev=787205&r1=787204&r2=787205&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/SolrWriter.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/SolrWriter.java
Mon Jun 22 11:27:53 2009
@@ -49,12 +49,20 @@
 
   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 @@
 
     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 @@
     } catch (ParseException e) {
       throw new DataImportHandlerException(DataImportHandlerException.WARN,
               "Unable to read last indexed time from: "
-                      + SolrWriter.IMPORTER_PROPERTIES, e);
+                      + persistFilename, e);
     }
     return null;
   }



Mime
View raw message