From 790e0b1894c6b1e56a7a96fb435e39cd13d759eb Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 3 Nov 2010 18:31:36 +0000 Subject: [PATCH] - enhanced index deletion in IndexControlRWIs_p: delete also robots.txt database and cache if demanded - added option for details of deletion - added deletion to new ConfigHTCache_p servlet git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7294 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ConfigHTCache_p.html | 15 +++++++++++++++ htroot/ConfigHTCache_p.java | 17 ++++++++++++----- htroot/IndexControlRWIs_p.html | 10 ++++++++-- htroot/IndexControlRWIs_p.java | 20 +++++++++++++++----- source/de/anomic/http/client/Cache.java | 17 +++++++++++++++++ 5 files changed, 67 insertions(+), 12 deletions(-) diff --git a/htroot/ConfigHTCache_p.html b/htroot/ConfigHTCache_p.html index e1ef22e96..9079dcf65 100644 --- a/htroot/ConfigHTCache_p.html +++ b/htroot/ConfigHTCache_p.html @@ -28,6 +28,21 @@ + +
+
Cleanup +
+
Cache Deletion
+
Delete HTTP & FTP Cache
+ Delete robots.txt Cache


+ +
+
+
+
+ #%env/templates/footer.template%# diff --git a/htroot/ConfigHTCache_p.java b/htroot/ConfigHTCache_p.java index 079ce9b5d..4a0d82946 100644 --- a/htroot/ConfigHTCache_p.java +++ b/htroot/ConfigHTCache_p.java @@ -29,9 +29,9 @@ import java.io.File; import net.yacy.cora.protocol.RequestHeader; -import net.yacy.kelondro.logging.Log; import de.anomic.http.client.Cache; +import de.anomic.search.Switchboard; import de.anomic.search.SwitchboardConstants; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; @@ -40,13 +40,13 @@ public class ConfigHTCache_p { public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { // return variable that accumulates replacements + final Switchboard sb = (Switchboard) env; final serverObjects prop = new serverObjects(); String oldProxyCachePath, newProxyCachePath; int newProxyCacheSize; - if (post != null && post.containsKey("set")) try { - + if (post != null && post.containsKey("set")) { // proxyCache - check and create the directory oldProxyCachePath = env.getConfig(SwitchboardConstants.HTCACHE_PATH, SwitchboardConstants.HTCACHE_PATH_DEFAULT); newProxyCachePath = post.get("HTCachePath", SwitchboardConstants.HTCACHE_PATH_DEFAULT); @@ -63,8 +63,15 @@ public class ConfigHTCache_p { if (newProxyCacheSize < 4) { newProxyCacheSize = 4; } env.setConfig(SwitchboardConstants.PROXY_CACHE_SIZE, newProxyCacheSize); Cache.setMaxCacheSize(newProxyCacheSize * 1024 * 1024); - } catch (final Exception e) { - Log.logException(e); + } + + if (post != null && post.containsKey("deletecomplete")) { + if (post.get("deleteCache", "").equals("on")) { + Cache.clear(); + } + if (post.get("deleteRobots", "").equals("on")) { + sb.robots.clear(); + } } prop.put("HTCachePath", env.getConfig(SwitchboardConstants.HTCACHE_PATH, SwitchboardConstants.HTCACHE_PATH_DEFAULT)); diff --git a/htroot/IndexControlRWIs_p.html b/htroot/IndexControlRWIs_p.html index 8266db425..2c125434f 100644 --- a/htroot/IndexControlRWIs_p.html +++ b/htroot/IndexControlRWIs_p.html @@ -39,8 +39,14 @@
Cleanup
-
Index Deletion
(deletes all words and all urls)
-
+
Index Deletion
+
Delete Search Index
+ Stop Crawler and delete Crawl Queues
+ Delete HTTP & FTP Cache
+ Delete robots.txt Cache


+
diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java index a18fbbecc..6c8485351 100644 --- a/htroot/IndexControlRWIs_p.java +++ b/htroot/IndexControlRWIs_p.java @@ -55,6 +55,7 @@ import net.yacy.repository.Blacklist; import de.anomic.crawler.CrawlProfile; import de.anomic.data.listManager; +import de.anomic.http.client.Cache; import de.anomic.search.QueryParams; import de.anomic.search.RankingProcess; import de.anomic.search.ReferenceOrder; @@ -145,11 +146,20 @@ public class IndexControlRWIs_p { } // delete everything - if (post.containsKey("deletecomplete") && post.containsKey("confirmDelete")) { - segment.clear(); - sb.crawlQueues.clear(); - sb.crawlStacker.clear(); - sb.robots.clear(); + if (post.containsKey("deletecomplete")) { + if (post.get("deleteIndex", "").equals("on")) { + segment.clear(); + } + if (post.get("deleteCrawlQueues", "").equals("on")) { + sb.crawlQueues.clear(); + sb.crawlStacker.clear(); + } + if (post.get("deleteCache", "").equals("on")) { + Cache.clear(); + } + if (post.get("deleteRobots", "").equals("on")) { + sb.robots.clear(); + } post.remove("deletecomplete"); } diff --git a/source/de/anomic/http/client/Cache.java b/source/de/anomic/http/client/Cache.java index f4b3ef691..fbe554b18 100644 --- a/source/de/anomic/http/client/Cache.java +++ b/source/de/anomic/http/client/Cache.java @@ -91,6 +91,23 @@ public final class Cache { Log.logException(e); } } + + /** + * clear the cache + */ + public static void clear() { + responseHeaderDB.clear(); + try { + fileDB.clear(); + } catch (IOException e) { + Log.logException(e); + } + try { + fileDBunbuffered.clear(); + } catch (IOException e) { + Log.logException(e); + } + } /** * This method changes the HTCache size.