Apache Nutch is an extensible and scalable web crawler
NUTCH-545 - Configuration and OnlineClusterer get initialized in every request. Contributed by Dawid Weiss.
Tacettin Guney3f724529b4a5
diff --git a/CHANGES.txt b/CHANGES.txtindex f1e9a9456..ea66283d1 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -123,6 +123,9 @@ Unreleased changes (1.0-dev)41. NUTCH-544 - Upgrade Carrot2 clustering plugin to the newest stablerelease (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-021. Changed log4j confiquration to log to stdout on commandlinediff --git a/src/web/jsp/search.jsp b/src/web/jsp/search.jspindex 1bedd20da..e8aafba67 100644--- a/src/web/jsp/search.jsp+++ b/src/web/jsp/search.jsp@@ -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());+ }+ }%><%--