lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r815587 - in /lucene/solr/trunk: CHANGES.txt src/java/org/apache/solr/core/SolrCore.java src/java/org/apache/solr/core/SolrResourceLoader.java src/test/org/apache/solr/core/SolrCoreTest.java src/webapp/web/admin/registry.xsl
Date Wed, 16 Sep 2009 01:57:16 GMT
Author: gsingers
Date: Wed Sep 16 01:57:15 2009
New Revision: 815587

URL: http://svn.apache.org/viewvc?rev=815587&view=rev
Log:
SOLR-1427: fixed registry MBean issue

Modified:
    lucene/solr/trunk/CHANGES.txt
    lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
    lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java
    lucene/solr/trunk/src/test/org/apache/solr/core/SolrCoreTest.java
    lucene/solr/trunk/src/webapp/web/admin/registry.xsl

Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=815587&r1=815586&r2=815587&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Wed Sep 16 01:57:15 2009
@@ -557,7 +557,9 @@
     (Uri Boness, yonik)
 
 
-66. SOLR-1381: Fixed improper handling of fields that have only term positions and not term
offsets during Highlighting (Thorsten Fischer, gsingers) 
+66. SOLR-1381: Fixed improper handling of fields that have only term positions and not term
offsets during Highlighting (Thorsten Fischer, gsingers)
+
+67. SOLR-1427: Fixed registry.jsp issue with MBeans (gsingers) 
 
 Other Changes
 ----------------------

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=815587&r1=815586&r2=815587&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 Wed Sep 16 01:57:15 2009
@@ -574,6 +574,8 @@
       // Finally tell anyone who wants to know
       resourceLoader.inform( resourceLoader );
       resourceLoader.inform( this );
+      //register any SolrInfoMBeans
+      resourceLoader.inform(infoRegistry);
       instance = this;   // set singleton for backwards compatibility
     } catch (IOException e) {
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
@@ -830,7 +832,11 @@
   }
   private <T> void addIfNotPresent(Map<String ,T> registry, String name, Class<?
extends  T> c){
     if(!registry.containsKey(name)){
-      registry.put(name, (T) resourceLoader.newInstance(c.getName()));
+      T searchComp = (T) resourceLoader.newInstance(c.getName());
+      registry.put(name, searchComp);
+      if (searchComp instanceof SolrInfoMBean){
+        infoRegistry.put(((SolrInfoMBean)searchComp).getName(), (SolrInfoMBean)searchComp);
+      }
     }
   }
   

Modified: lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java?rev=815587&r1=815586&r2=815587&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/core/SolrResourceLoader.java Wed Sep 16 01:57:15
2009
@@ -68,6 +68,7 @@
   private String dataDir;
   
   private final List<SolrCoreAware> waitingForCore = new ArrayList<SolrCoreAware>();
+  private final List<SolrInfoMBean> infoMBeans = new ArrayList<SolrInfoMBean>();
   private final List<ResourceLoaderAware> waitingForResources = new ArrayList<ResourceLoaderAware>();
   private static final Charset UTF_8 = Charset.forName("UTF-8");
 
@@ -345,6 +346,10 @@
       assertAwareCompatibility( ResourceLoaderAware.class, obj );
       waitingForResources.add( (ResourceLoaderAware)obj );
     }
+    if (obj instanceof SolrInfoMBean){
+      //TODO: Assert here?
+      infoMBeans.add((SolrInfoMBean) obj);
+    }
     return obj;
   }
 
@@ -401,6 +406,10 @@
       assertAwareCompatibility( ResourceLoaderAware.class, obj );
       waitingForResources.add( (ResourceLoaderAware)obj );
     }
+    if (obj instanceof SolrInfoMBean){
+      //TODO: Assert here?
+      infoMBeans.add((SolrInfoMBean) obj);
+    }
     return obj;
   }
 
@@ -427,6 +436,16 @@
     }
     waitingForResources.clear();
   }
+
+  /**
+   * Register any {@link org.apache.solr.core.SolrInfoMBean}s
+   * @param infoRegistry The Info Registry
+   */
+  public void inform(Map<String, SolrInfoMBean> infoRegistry) {
+    for (SolrInfoMBean bean : infoMBeans) {
+      infoRegistry.put(bean.getName(), bean);
+    }
+  }
   /**
    * Determines the solrhome from the environment.
    * Tries JNDI (java:comp/env/solr/home) then system property (solr.solr.home);
@@ -535,4 +554,5 @@
     throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, builder.toString() );
   }
 
+
 }

Modified: lucene/solr/trunk/src/test/org/apache/solr/core/SolrCoreTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/core/SolrCoreTest.java?rev=815587&r1=815586&r2=815587&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/core/SolrCoreTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/core/SolrCoreTest.java Wed Sep 16 01:57:15
2009
@@ -18,6 +18,8 @@
 package org.apache.solr.core;
 
 import org.apache.solr.handler.RequestHandlerBase;
+import org.apache.solr.handler.component.SpellCheckComponent;
+import org.apache.solr.handler.component.QueryComponent;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrQueryResponse;
 import org.apache.solr.request.SolrRequestHandler;
@@ -164,6 +166,24 @@
     service.shutdown();
     assertTrue("Running for too long...", service.awaitTermination(60, TimeUnit.SECONDS));
   }
+
+  public void testInfoRegistry() throws Exception {
+    //TEst that SolrInfoMBeans are registered, including SearchComponents
+    SolrCore core = h.getCore();
+
+    Map<String, SolrInfoMBean> infoRegistry = core.getInfoRegistry();
+    assertTrue("infoRegistry Size: " + infoRegistry.size() + " is not greater than: " + 0,
infoRegistry.size() > 0);
+    //try out some that we know are in the config
+    SolrInfoMBean bean = infoRegistry.get(SpellCheckComponent.class.getName());
+    assertNotNull("bean not registered", bean);
+    //try a default one
+    bean = infoRegistry.get(QueryComponent.class.getName());
+    assertNotNull("bean not registered", bean);
+    //try a Req Handler, which are stored by name, not clas
+    bean = infoRegistry.get("standard");
+    assertNotNull("bean not registered", bean);
+  }
+
 }
 
 

Modified: lucene/solr/trunk/src/webapp/web/admin/registry.xsl
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/registry.xsl?rev=815587&r1=815586&r2=815587&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/web/admin/registry.xsl (original)
+++ lucene/solr/trunk/src/webapp/web/admin/registry.xsl Wed Sep 16 01:57:15 2009
@@ -66,6 +66,7 @@
         [<a href="#cache">Cache</a>]
         [<a href="#query">Query</a>]
         [<a href="#update">Update</a>]
+        [<a href="#highlighting">Highlighting</a>]
         [<a href="#other">Other</a>]
       </td>
     </tr>
@@ -248,6 +249,39 @@
           </td>
         </tr>
   </xsl:template>
+  <xsl:template match="solr/solr-info/HIGHLIGHTING">
+    <br />
+    <a name="highlighting"><h2>Highlighting</h2></a>
+    <table>
+        <tr>
+          <td align="right">
+            &#xa0;
+          </td>
+          <td>
+          </td>
+        </tr>
+    <xsl:apply-templates/>
+    </table>
+  </xsl:template>
+  <xsl:template match="solr/solr-info/HIGHLIGHTING/entry">
+      <xsl:for-each select="*">
+        <tr>
+          <td align="right">
+            <strong><xsl:value-of select="name()"/>:&#xa0;</strong>
+          </td>
+          <td>
+            <tt><xsl:value-of select="."/>&#xa0;</tt>
+          </td>
+        </tr>
+      </xsl:for-each>
+        <tr>
+          <td align="right">
+          </td>
+          <td>
+          </td>
+        </tr>
+  </xsl:template>
+
 
   <xsl:template match="solr/solr-info/OTHER">
     <br />



Mime
View raw message