lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1045306 - in /lucene/dev/branches/branch_3x/solr: ./ src/java/org/apache/solr/core/ src/test/org/apache/solr/core/ src/test/test-files/solr/conf/
Date Mon, 13 Dec 2010 19:02:43 GMT
Author: hossman
Date: Mon Dec 13 19:02:42 2010
New Revision: 1045306

URL: http://svn.apache.org/viewvc?rev=1045306&view=rev
Log:
SOLR-2219: merge 1045302 from trunk

Modified:
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/CHANGES.txt
    lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/RequestHandlers.java
    lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java
    lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/RequestHandlersTest.java
    lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig.xml

Modified: lucene/dev/branches/branch_3x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/CHANGES.txt?rev=1045306&r1=1045305&r2=1045306&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Mon Dec 13 19:02:42 2010
@@ -473,6 +473,9 @@ Bug Fixes
 * SOLR-2252: When a child entity in nested entities is rootEntity="true", delta-import doesn't
work.
   (koji)
 
+* SOLR-2219: The init() method of every SolrRequestHandler was being
+  called twice. (ambikeshwar singh and hossman)
+
 Other Changes
 ----------------------
 

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/RequestHandlers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/RequestHandlers.java?rev=1045306&r1=1045305&r2=1045306&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/RequestHandlers.java
(original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/RequestHandlers.java
Mon Dec 13 19:02:42 2010
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
 import java.net.URL;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -136,7 +137,8 @@ final class RequestHandlers {
    */
 
   void initHandlersFromConfig(SolrConfig config ){
-    Map<PluginInfo,SolrRequestHandler> handlers = new HashMap<PluginInfo,SolrRequestHandler>();
+    // use link map so we iterate in the same order
+    Map<PluginInfo,SolrRequestHandler> handlers = new LinkedHashMap<PluginInfo,SolrRequestHandler>();
     for (PluginInfo info : config.getPluginInfos(SolrRequestHandler.class.getName())) {
       try {
         SolrRequestHandler requestHandler;
@@ -152,11 +154,6 @@ final class RequestHandlers {
           requestHandler = core.createRequestHandler(info.className);
         }
         handlers.put(info,requestHandler);
-        if (requestHandler instanceof PluginInfoInitialized) {
-          ((PluginInfoInitialized) requestHandler).init(info);
-        } else{
-          requestHandler.init(info.initArgs);
-        }
         SolrRequestHandler old = register(info.name, requestHandler);
         if(old != null) {
           log.warn("Multiple requestHandler registered to the same name: " + info.name +
" ignoring: " + old.getClass().getName());
@@ -172,8 +169,16 @@ final class RequestHandlers {
           SolrException.logOnce(log,null,e);
       }
     }
+
+    // we've now registered all handlers, time ot init them in the same order
     for (Map.Entry<PluginInfo,SolrRequestHandler> entry : handlers.entrySet()) {
-      entry.getValue().init(entry.getKey().initArgs);
+      PluginInfo info = entry.getKey();
+      SolrRequestHandler requestHandler = entry.getValue();
+      if (requestHandler instanceof PluginInfoInitialized) {
+        ((PluginInfoInitialized) requestHandler).init(info);
+      } else{
+        requestHandler.init(info.initArgs);
+      }
     }
 
     if(get("") == null) register("", get(DEFAULT_HANDLER_NAME));

Modified: lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java?rev=1045306&r1=1045305&r2=1045306&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java
(original)
+++ lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/MockQuerySenderListenerReqHandler.java
Mon Dec 13 19:02:42 2010
@@ -19,6 +19,9 @@ package org.apache.solr.core;
 import org.apache.solr.handler.RequestHandlerBase;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.common.util.NamedList;
+
+import java.util.concurrent.atomic.AtomicInteger;
 
 
 /**
@@ -29,6 +32,13 @@ public class MockQuerySenderListenerReqH
   public SolrQueryRequest req;
   public SolrQueryResponse rsp;
 
+  AtomicInteger initCounter = new AtomicInteger(0);
+
+  public void init(NamedList args) {
+    initCounter.incrementAndGet();
+    super.init(args);
+  }
+
   public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
{
     this.req = req;
     this.rsp = rsp;
@@ -53,4 +63,11 @@ public class MockQuerySenderListenerReqH
     String result = null;
     return result;
   }
+
+  public NamedList<Object> getStatistics() {
+    NamedList<Object> lst = super.getStatistics();
+    lst.add("initCount", initCounter.intValue());
+    return lst;
+  }
+ 
 }

Modified: lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/RequestHandlersTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/RequestHandlersTest.java?rev=1045306&r1=1045305&r2=1045306&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/RequestHandlersTest.java
(original)
+++ lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/RequestHandlersTest.java
Mon Dec 13 19:02:42 2010
@@ -30,6 +30,14 @@ public class RequestHandlersTest extends
   }
 
   @Test
+  public void testInitCount() {
+    SolrCore core = h.getCore();
+    SolrRequestHandler handler = core.getRequestHandler( "mock" );
+    assertEquals("Incorrect init count",
+                 1, handler.getStatistics().get("initCount"));
+  }
+
+  @Test
   public void testLazyLoading() {
     SolrCore core = h.getCore();
     SolrRequestHandler handler = core.getRequestHandler( "lazy" );

Modified: lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig.xml?rev=1045306&r1=1045305&r2=1045306&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig.xml (original)
+++ lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig.xml Mon Dec
13 19:02:42 2010
@@ -304,6 +304,7 @@
     <lst name="lst1"> <str name="op">sqrt</str> <int name="val">2</int>
</lst>
     <lst name="lst2"> <str name="op">log</str> <float name="val">10</float>
</lst>
   </requestHandler>
+  <requestHandler name="mock" class="org.apache.solr.core.MockQuerySenderListenerReqHandler"/>
 
   <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
 



Mime
View raw message