Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

removed unused code (caching is now in web-caching-oscache)

Sami Siren4cd6c71ccd3d
diff --git a/contrib/web2/plugins/caching-oscache/src/java/org/apache/nutch/webapp/CacheManager.java b/contrib/web2/plugins/caching-oscache/src/java/org/apache/nutch/webapp/CacheManager.java
deleted file mode 100644
index 35106189c..000000000
--- a/contrib/web2/plugins/caching-oscache/src/java/org/apache/nutch/webapp/CacheManager.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.apache.nutch.webapp;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.nutch.webapp.common.Search;
-
-import com.opensymphony.oscache.base.Cache;
-import com.opensymphony.oscache.base.CacheEntry;
-import com.opensymphony.oscache.base.EntryRefreshPolicy;
-import com.opensymphony.oscache.base.NeedsRefreshException;
-
-/**
- * CacheManager for
- */
-public class CacheManager {
-
- static final String CACHE_KEY="cache";
-
- class NutchReferehPolicy implements EntryRefreshPolicy {
- private static final long serialVersionUID = 1L;
-
- public boolean needsRefresh(CacheEntry arg0) {
- return false;
- }
- }
-
- EntryRefreshPolicy policy=new NutchReferehPolicy();
-
- Cache cache;
-
- protected CacheManager(){
- cache=new Cache(true,true,false,true,"com.opensymphony.oscache.base.algorithm.UnlimitedCache",Integer.MAX_VALUE);
- }
-
- public static CacheManager getInstance(Configuration conf){
- CacheManager cache=(CacheManager)conf.getObject(CACHE_KEY);
-
- if(cache==null) {
- cache = new CacheManager();
-
- conf.setObject(CACHE_KEY, cache);
- }
- return cache;
- }
-
- /**
- * Get Search object from cache
- * @param id key
- * @return
- * @throws NeedsRefreshException
- */
- public Search getSearch(String id) throws NeedsRefreshException {
- return (Search) cache.getFromCache(id);
- }
-
- /**
- * Put Search object in cache
- *
- * @param id key
- * @param search the search to cache
- */
- public void putSearch(String id, Search search){
- cache.putInCache(id,search,policy);
- }
-
-}
diff --git a/contrib/web2/plugins/caching-oscache/src/java/org/apache/nutch/webapp/controller/CachingSearchController.java b/contrib/web2/plugins/caching-oscache/src/java/org/apache/nutch/webapp/controller/CachingSearchController.java
deleted file mode 100644
index c11631b75..000000000
--- a/contrib/web2/plugins/caching-oscache/src/java/org/apache/nutch/webapp/controller/CachingSearchController.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.apache.nutch.webapp.controller;
-
-import java.io.IOException;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.nutch.webapp.CacheManager;
-import org.apache.nutch.webapp.common.Search;
-import org.apache.nutch.webapp.common.ServiceLocator;
-import org.apache.struts.tiles.ComponentContext;
-
-import com.opensymphony.oscache.base.NeedsRefreshException;
-
-/**
- * This naive search result caching implementation is just an example of
- * extending the web ui.
- */
-public class CachingSearchController extends SearchController {
-
- public void nutchPerform(ComponentContext tileContext,
- HttpServletRequest request, HttpServletResponse response,
- ServletContext servletContext) throws ServletException, IOException {
-
- Search search = null;
- boolean requiresUpdate = false;
-
- // key used for caching
- String key = request.getQueryString();
-
- ServiceLocator locator = getServiceLocator(request);
-
- try {
- search = CacheManager.getInstance(locator.getConfiguration()).getSearch(
- key);
- request.setAttribute("resultInfo", search.getResultInfo());
- request.setAttribute("nutchSearch", search);
-
- LOG.fine("Using cached");
- } catch (NeedsRefreshException e) {
- requiresUpdate = true;
- LOG.fine("Cache update required");
- }
-
- if (search == null || requiresUpdate) {
- LOG.fine("Cache miss");
- super.nutchPerform(tileContext, request, response, servletContext);
- search = (Search) request.getAttribute(SearchController.REQ_ATTR_SEARCH);
- CacheManager.getInstance(locator.getConfiguration()).putSearch(key,
- search);
- }
-
- }
-}