Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

implement deleteOldDownloads in RexourceObserver on low diskspace - direct assign sb.observer (skip redundant InitThread)

reger121972752ce6
diff --git a/source/net/yacy/search/ResourceObserver.java b/source/net/yacy/search/ResourceObserver.java
index 0bc27cba4..93c52659e 100644
--- a/source/net/yacy/search/ResourceObserver.java
+++ b/source/net/yacy/search/ResourceObserver.java
@@ -34,11 +34,11 @@ import net.yacy.cora.protocol.Domains;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.crawler.data.Cache;
import net.yacy.crawler.data.ResultURLs;
-import net.yacy.data.WorkTables;
import net.yacy.kelondro.data.word.WordReference;
import net.yacy.kelondro.rwi.IndexCell;
import net.yacy.kelondro.util.MemoryControl;
import net.yacy.peers.NewsPool;
+import net.yacy.peers.operation.yacyRelease;
import net.yacy.search.query.SearchEventCache;
public class ResourceObserver {
@@ -65,17 +65,11 @@ public class ResourceObserver {
log.info("path for disc space measurement: " + this.path);
}
- public static void initThread() {
- final Switchboard sb = Switchboard.getSwitchboard();
- sb.observer = new ResourceObserver(Switchboard.getSwitchboard());
- sb.observer.resourceObserverJob();
- }
-
/**
* checks the resources and pauses crawls if necessary
*/
public void resourceObserverJob() {
- MemoryControl.setProperMbyte(getMinFreeMemory());
+ MemoryControl.setProperMbyte(getMinFreeMemory()); // may change by user config
this.normalizedDiskFree = getNormalizedDiskFree();
this.normalizedDiskUsed = getNormalizedDiskUsed(true);
@@ -113,7 +107,8 @@ public class ResourceObserver {
(this.normalizedDiskUsed == Space.EXHAUSTED && this.sb.getConfigBool(SwitchboardConstants.RESOURCE_DISK_USED_AUTOREGULATE, false))) {
shrinkmethods: while (true /*this is not a loop, just a construct that we can leave with a break*/) {
// delete old releases
- //if (getNormalizedDiskFree() == Space.AMPLE && getNormalizedDiskUsed(false) == Space.AMPLE) break;
+ yacyRelease.deleteOldDownloads(sb.releasePath, 1);
+ if (getNormalizedDiskFree() == Space.AMPLE && getNormalizedDiskUsed(false) == Space.AMPLE) break;
// clear HTCACHE
log.info("DISK SPACE EXHAUSTED - deleting HTCACHE");
diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java
index 38bf5fbae..0237b813a 100644
--- a/source/net/yacy/search/Switchboard.java
+++ b/source/net/yacy/search/Switchboard.java
@@ -920,7 +920,8 @@ public final class Switchboard extends serverSwitch {
wikiParser = new WikiCode();
// initializing the resourceObserver
- InstantBusyThread.oneTimeJob(ResourceObserver.class, "initThread", 0);
+ this.observer = new ResourceObserver(this);
+ InstantBusyThread.oneTimeJob(this.observer, "resourceObserverJob", 0);
// initializing the stackCrawlThread
this.crawlStacker =
@@ -2408,7 +2409,7 @@ public final class Switchboard extends serverSwitch {
// after all clean up is done, check the resource usage
this.observer.resourceObserverJob();
-
+
// clean up profiles
checkInterruption();