You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ry...@apache.org on 2007/09/22 16:48:22 UTC

svn commit: r578451 - in /lucene/solr/trunk/src: java/org/apache/solr/core/SolrCore.java test/org/apache/solr/core/TestQuerySenderListener.java test/test-files/solr/conf/solrconfig-querysender.xml

Author: ryan
Date: Sat Sep 22 07:48:21 2007
New Revision: 578451

URL: http://svn.apache.org/viewvc?rev=578451&view=rev
Log:
SOLR-215 -- fixing SolrEventListener initalization and adding test that instantiates an SolrEventListener on startup.

Added:
    lucene/solr/trunk/src/test/org/apache/solr/core/TestQuerySenderListener.java   (with props)
    lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig-querysender.xml   (with props)
Modified:
    lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?rev=578451&r1=578450&r2=578451&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java Sat Sep 22 07:48:21 2007
@@ -130,11 +130,11 @@
     if (nodes!=null) {
       for (int i=0; i<nodes.getLength(); i++) {
         Node node = nodes.item(i);
-          String className = DOMUtil.getAttr(node,"class");
-          SolrEventListener listener = (SolrEventListener)solrConfig.newInstance(className);
-          listener.init(DOMUtil.childNodesToNamedList(node));
-          lst.add(listener);
-          log.info("added SolrEventListener: " + listener);
+        String className = DOMUtil.getAttr(node,"class");
+        SolrEventListener listener = createEventListener(className);
+        listener.init(DOMUtil.childNodesToNamedList(node));
+        lst.add(listener);
+        log.info("added SolrEventListener: " + listener);
       }
     }
     return lst;

Added: lucene/solr/trunk/src/test/org/apache/solr/core/TestQuerySenderListener.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/core/TestQuerySenderListener.java?rev=578451&view=auto
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/core/TestQuerySenderListener.java (added)
+++ lucene/solr/trunk/src/test/org/apache/solr/core/TestQuerySenderListener.java Sat Sep 22 07:48:21 2007
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.core;
+
+import org.apache.solr.handler.RequestHandlerBase;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.request.SolrQueryResponse;
+import org.apache.solr.request.SolrRequestHandler;
+import org.apache.solr.util.AbstractSolrTestCase;
+
+public class TestQuerySenderListener extends AbstractSolrTestCase {
+
+  @Override public String getSchemaFile() { return "schema.xml"; }
+  @Override public String getSolrConfigFile() { return "solrconfig-querysender.xml"; }
+
+  public void testRequestHandlerRegistry() {
+    // property values defined in build.xml
+    SolrCore core = h.getCore();
+
+    assertEquals( 1, core.firstSearcherListeners.size() );
+    assertEquals( 1, core.newSearcherListeners.size() );
+  }
+}
+

Propchange: lucene/solr/trunk/src/test/org/apache/solr/core/TestQuerySenderListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/solr/trunk/src/test/org/apache/solr/core/TestQuerySenderListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig-querysender.xml
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig-querysender.xml?rev=578451&view=auto
==============================================================================
--- lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig-querysender.xml (added)
+++ lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig-querysender.xml Sat Sep 22 07:48:21 2007
@@ -0,0 +1,53 @@
+<?xml version="1.0" ?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id$
+     $Source$
+     $Name$
+  -->
+
+<config>
+  
+  
+  <query>
+  
+  
+    <!-- a newSearcher event is fired whenever a new searcher is being prepared
+         and there is a current searcher handling requests (aka registered). -->
+    <!-- QuerySenderListener takes an array of NamedList and executes a
+         local query request for each NamedList in sequence. -->
+    <listener event="newSearcher" class="solr.QuerySenderListener">
+      <arr name="queries">
+        <lst> <str name="q">solr</str> <str name="start">0</str> <str name="rows">10</str> </lst>
+        <lst> <str name="q">rocks</str> <str name="start">0</str> <str name="rows">10</str> </lst>
+      </arr>
+    </listener>
+
+    <!-- a firstSearcher event is fired whenever a new searcher is being
+         prepared but there is no current registered searcher to handle
+         requests or to gain prewarming data from. -->
+    <listener event="firstSearcher" class="solr.QuerySenderListener">
+      <arr name="queries">
+        <lst> <str name="q">fast_warm</str> <str name="start">0</str> <str name="rows">10</str> </lst>
+      </arr>
+    </listener>
+  
+  </query>
+  
+</config>

Propchange: lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig-querysender.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig-querysender.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL