lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1048890 - in /lucene/dev/branches/branch_3x/solr: ./ src/java/org/apache/solr/core/ src/java/org/apache/solr/update/ src/test/org/apache/solr/core/ src/test/test-files/solr/conf/
Date Tue, 14 Dec 2010 01:16:14 GMT
Author: hossman
Date: Tue Dec 14 01:16:13 2010
New Revision: 1048890

URL: http://svn.apache.org/viewvc?rev=1048890&view=rev
Log:
SOLR-2285: merge 1048886 from trunk

Added:
    lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/MockEventListener.java
      - copied unchanged from r1048886, lucene/dev/trunk/solr/src/test/org/apache/solr/core/MockEventListener.java
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/SolrConfig.java
    lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/SolrCore.java
    lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/update/UpdateHandler.java
    lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java
    lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig-querysender.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=1048890&r1=1048889&r2=1048890&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Tue Dec 14 01:16:13 2010
@@ -279,7 +279,6 @@ Optimizations
 
 Bug Fixes
 ----------------------
-
 * SOLR-1432: Make the new ValueSource.getValues(context,reader) delegate
   to the original ValueSource.getValues(reader) so custom sources
   will work. (yonik)
@@ -476,6 +475,8 @@ Bug Fixes
 * SOLR-2219: The init() method of every SolrRequestHandler was being
   called twice. (ambikeshwar singh and hossman)
 
+* SOLR-2285: duplicate SolrEventListeners no longer created (hossman)
+
 Other Changes
 ----------------------
 

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/SolrConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/SolrConfig.java?rev=1048890&r1=1048889&r2=1048890&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/SolrConfig.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/SolrConfig.java Tue Dec
14 01:16:13 2010
@@ -192,7 +192,13 @@ public class SolrConfig extends Config {
      loadPluginInfo(ValueSourceParser.class,"valueSourceParser",true, true);
      loadPluginInfo(SearchComponent.class,"searchComponent",true, true);
      loadPluginInfo(QueryConverter.class,"queryConverter",true, true);
+
+     // this is hackish, since it picks up all SolrEventListeners,
+     // regardless of when/how/why thye are used (or even if they are 
+     // declared outside of the appropriate context) but there's no nice 
+     // way arround that in the PluginInfo framework
      loadPluginInfo(SolrEventListener.class, "//listener",false, true);
+
      loadPluginInfo(DirectoryFactory.class,"directoryFactory",false, true);
      loadPluginInfo(IndexDeletionPolicy.class,"mainIndex/deletionPolicy",false, true);
      loadPluginInfo(IndexReaderFactory.class,"indexReaderFactory",false, true);

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/SolrCore.java?rev=1048890&r1=1048889&r2=1048890&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/core/SolrCore.java Tue Dec
14 01:16:13 2010
@@ -274,15 +274,19 @@ public final class SolrCore implements S
    }
 
   private void initListeners() {
+    final Class<SolrEventListener> clazz = SolrEventListener.class;
+    final String label = "Event Listener";
     for (PluginInfo info : solrConfig.getPluginInfos(SolrEventListener.class.getName()))
{
-      SolrEventListener listener = createInitInstance(info, SolrEventListener.class,"Event
Listener",null);      
       String event = info.attributes.get("event");
       if("firstSearcher".equals(event) ){
-        firstSearcherListeners.add(listener);
+        SolrEventListener obj = createInitInstance(info,clazz,label,null);
+        firstSearcherListeners.add(obj);
+        log.info(logid + "Added SolrEventListener for firstSearcher: " + obj);
       } else if("newSearcher".equals(event) ){
-        newSearcherListeners.add(listener);
+        SolrEventListener obj = createInitInstance(info,clazz,label,null);
+        newSearcherListeners.add(obj);
+        log.info(logid + "Added SolrEventListener for newSearcher: " + obj);
       }
-      log.info(logid + "Added SolrEventListener: " + listener);
     }
   }
 

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/update/UpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/update/UpdateHandler.java?rev=1048890&r1=1048889&r2=1048890&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/update/UpdateHandler.java
(original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/update/UpdateHandler.java
Tue Dec 14 01:16:13 2010
@@ -61,15 +61,18 @@ public abstract class UpdateHandler impl
   protected Vector<SolrEventListener> optimizeCallbacks = new Vector<SolrEventListener>();
 
   private void parseEventListeners() {
-    for (PluginInfo pluginInfo : core.getSolrConfig().getPluginInfos(SolrEventListener.class.getName()))
{
-      String event = pluginInfo.attributes.get("event");
-      SolrEventListener listener = core.createInitInstance(pluginInfo,SolrEventListener.class,"Event
Listener",null);
+    final Class<SolrEventListener> clazz = SolrEventListener.class;
+    final String label = "Event Listener";
+    for (PluginInfo info : core.getSolrConfig().getPluginInfos(SolrEventListener.class.getName()))
{
+      String event = info.attributes.get("event");
       if ("postCommit".equals(event)) {
-        commitCallbacks.add(core.createInitInstance(pluginInfo,SolrEventListener.class,"Event
Listener",null));
-        log.info("added SolrEventListener for postCommit: " + listener);
+        SolrEventListener obj = core.createInitInstance(info,clazz,label,null);
+        commitCallbacks.add(obj);
+        log.info("added SolrEventListener for postCommit: " + obj);
       } else if ("postOptimize".equals(event)) {
-        optimizeCallbacks.add(listener);
-        log.info("added SolrEventListener for postOptimize: " + listener);
+        SolrEventListener obj = core.createInitInstance(info,clazz,label,null);
+        optimizeCallbacks.add(obj);
+        log.info("added SolrEventListener for postOptimize: " + obj);
       }
     }
   }

Modified: lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java?rev=1048890&r1=1048889&r2=1048890&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java
(original)
+++ lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java
Tue Dec 14 01:16:13 2010
@@ -28,18 +28,37 @@ import static org.junit.Assert.*;
 
 public class TestQuerySenderListener extends SolrTestCaseJ4 {
 
+  // number of instances configured in the solrconfig.xml
+  private static final int EXPECTED_MOCK_LISTENER_INSTANCES = 4;
+
+  private static int preInitMockListenerCount = 0;
+
   @BeforeClass
   public static void beforeClass() throws Exception {
+    // record current value prior to core initialization
+    // so we can verify the correct number of instances later
+    // NOTE: this won't work properly if concurrent tests run
+    // in the same VM
+    preInitMockListenerCount = MockEventListener.getCreateCount();
+
     initCore("solrconfig-querysender.xml","schema.xml");
   }
 
+  public void testListenerCreationCounts() {
+    SolrCore core = h.getCore();
+
+    assertEquals("Unexpected number of listeners created",
+                 EXPECTED_MOCK_LISTENER_INSTANCES, 
+                 MockEventListener.getCreateCount() - preInitMockListenerCount);
+  }
+
   @Test
   public void testRequestHandlerRegistry() {
     // property values defined in build.xml
     SolrCore core = h.getCore();
 
-    assertEquals( 1, core.firstSearcherListeners.size() );
-    assertEquals( 1, core.newSearcherListeners.size() );
+    assertEquals( 2, core.firstSearcherListeners.size() );
+    assertEquals( 2, core.newSearcherListeners.size() );
   }
 
   @Test

Modified: lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig-querysender.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig-querysender.xml?rev=1048890&r1=1048889&r2=1048890&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig-querysender.xml
(original)
+++ lucene/dev/branches/branch_3x/solr/src/test/test-files/solr/conf/solrconfig-querysender.xml
Tue Dec 14 01:16:13 2010
@@ -29,6 +29,12 @@
         solr.RAMDirectoryFactory is memory based and not persistent. -->
   <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>
   
+  <updateHandler class="solr.DirectUpdateHandler2">
+    <listener event="postCommit" 
+              class="org.apache.solr.core.MockEventListener" />
+    <listener event="postOptimize" 
+              class="org.apache.solr.core.MockEventListener" />
+  </updateHandler>
   
   <query>
   
@@ -43,6 +49,9 @@
         <lst> <str name="q">rocks</str> <str name="start">0</str>
<str name="rows">10</str> <str name="qt">mock</str></lst>
       </arr>
     </listener>
+    <listener event="newSearcher"
+              class="org.apache.solr.core.MockEventListener" />
+
 
     <!-- a firstSearcher event is fired whenever a new searcher is being
          prepared but there is no current registered searcher to handle
@@ -54,6 +63,9 @@
         </lst>
       </arr>
     </listener>
+    <listener event="firstSearcher"
+              class="org.apache.solr.core.MockEventListener" />
+
   
   </query>
   <requestHandler name="mock" class="org.apache.solr.core.MockQuerySenderListenerReqHandler"
default="true">



Mime
View raw message