You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by do...@apache.org on 2007/08/28 08:34:37 UTC

svn commit: r570331 - in /lucene/nutch/trunk: CHANGES.txt src/web/jsp/search.jsp

Author: dogacan
Date: Mon Aug 27 23:34:36 2007
New Revision: 570331

URL: http://svn.apache.org/viewvc?rev=570331&view=rev
Log:
NUTCH-545 - Configuration and OnlineClusterer get initialized in every request. Contributed by Dawid Weiss.

Modified:
    lucene/nutch/trunk/CHANGES.txt
    lucene/nutch/trunk/src/web/jsp/search.jsp

Modified: lucene/nutch/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/CHANGES.txt?rev=570331&r1=570330&r2=570331&view=diff
==============================================================================
--- lucene/nutch/trunk/CHANGES.txt (original)
+++ lucene/nutch/trunk/CHANGES.txt Mon Aug 27 23:34:36 2007
@@ -123,6 +123,9 @@
 41. NUTCH-544 - Upgrade Carrot2 clustering plugin to the newest stable 
     release (2.1). (Dawid Weiss via dogacan)
 
+42. NUTCH-545 - Configuration and OnlineClusterer get initialized in every
+    request. (Dawid Weiss via dogacan)
+
 Release 0.9 - 2007-04-02
 
  1. Changed log4j confiquration to log to stdout on commandline

Modified: lucene/nutch/trunk/src/web/jsp/search.jsp
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/web/jsp/search.jsp?rev=570331&r1=570330&r2=570331&view=diff
==============================================================================
--- lucene/nutch/trunk/src/web/jsp/search.jsp (original)
+++ lucene/nutch/trunk/src/web/jsp/search.jsp Mon Aug 27 23:34:36 2007
@@ -22,6 +22,8 @@
   import="java.io.*"
   import="java.util.*"
   import="java.net.*"
+  import="javax.servlet.http.*"
+  import="javax.servlet.*"
 
   import="org.apache.nutch.html.Entities"
   import="org.apache.nutch.metadata.Nutch"
@@ -30,30 +32,40 @@
   import="org.apache.nutch.clustering.*"
   import="org.apache.hadoop.conf.*"
   import="org.apache.nutch.util.NutchConfiguration"
-
-%><%
-  Configuration nutchConf = NutchConfiguration.get(application);
-  
+%><%!
   /**
    * Number of hits to retrieve and cluster if clustering extension is available
    * and clustering is on. By default, 100. Configurable via nutch-conf.xml.
    */
-  int HITS_TO_CLUSTER = 
-    nutchConf.getInt("extension.clustering.hits-to-cluster", 100);
+  private int HITS_TO_CLUSTER;
 
   /**
    * An instance of the clustering extension, if available.
    */
-  OnlineClusterer clusterer = null;
-  try {
-    clusterer = new OnlineClustererFactory(nutchConf).getOnlineClusterer();
-  } catch (PluginRuntimeException e) {
-    // NOTE: Dawid Weiss
-    // should we ignore plugin exceptions, or rethrow it? Rethrowing
-    // it effectively prevents the servlet class from being loaded into
-    // the JVM
-  }
+  private OnlineClusterer clusterer;
   
+  /**
+   * Nutch configuration for this servlet.
+   */
+  private Configuration nutchConf;
+
+  /**
+   * Initialize search bean.
+   */
+  public void jspInit() {
+    super.jspInit();
+    
+    final ServletContext application = getServletContext(); 
+    nutchConf = NutchConfiguration.get(application);
+
+	HITS_TO_CLUSTER = nutchConf.getInt("extension.clustering.hits-to-cluster", 100);
+
+    try {
+      clusterer = new OnlineClustererFactory(nutchConf).getOnlineClusterer();
+    } catch (PluginRuntimeException e) {
+      NutchBean.LOG("Could not initialize online clusterer: " + e.toString());
+    }
+  }
 %>
 
 <%--