implement deleteOldDownloads in RexourceObserver on low diskspace

- direct assign sb.observer (skip redundant InitThread)
pull/8/head
reger 10 years ago
parent 0d5ac6e527
commit 121972752c

@ -34,11 +34,11 @@ import net.yacy.cora.protocol.Domains;
import net.yacy.cora.util.ConcurrentLog; import net.yacy.cora.util.ConcurrentLog;
import net.yacy.crawler.data.Cache; import net.yacy.crawler.data.Cache;
import net.yacy.crawler.data.ResultURLs; import net.yacy.crawler.data.ResultURLs;
import net.yacy.data.WorkTables;
import net.yacy.kelondro.data.word.WordReference; import net.yacy.kelondro.data.word.WordReference;
import net.yacy.kelondro.rwi.IndexCell; import net.yacy.kelondro.rwi.IndexCell;
import net.yacy.kelondro.util.MemoryControl; import net.yacy.kelondro.util.MemoryControl;
import net.yacy.peers.NewsPool; import net.yacy.peers.NewsPool;
import net.yacy.peers.operation.yacyRelease;
import net.yacy.search.query.SearchEventCache; import net.yacy.search.query.SearchEventCache;
public class ResourceObserver { public class ResourceObserver {
@ -65,17 +65,11 @@ public class ResourceObserver {
log.info("path for disc space measurement: " + this.path); 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 * checks the resources and pauses crawls if necessary
*/ */
public void resourceObserverJob() { public void resourceObserverJob() {
MemoryControl.setProperMbyte(getMinFreeMemory()); MemoryControl.setProperMbyte(getMinFreeMemory()); // may change by user config
this.normalizedDiskFree = getNormalizedDiskFree(); this.normalizedDiskFree = getNormalizedDiskFree();
this.normalizedDiskUsed = getNormalizedDiskUsed(true); this.normalizedDiskUsed = getNormalizedDiskUsed(true);
@ -113,7 +107,8 @@ public class ResourceObserver {
(this.normalizedDiskUsed == Space.EXHAUSTED && this.sb.getConfigBool(SwitchboardConstants.RESOURCE_DISK_USED_AUTOREGULATE, false))) { (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*/) { shrinkmethods: while (true /*this is not a loop, just a construct that we can leave with a break*/) {
// delete old releases // 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 // clear HTCACHE
log.info("DISK SPACE EXHAUSTED - deleting HTCACHE"); log.info("DISK SPACE EXHAUSTED - deleting HTCACHE");

@ -920,7 +920,8 @@ public final class Switchboard extends serverSwitch {
wikiParser = new WikiCode(); wikiParser = new WikiCode();
// initializing the resourceObserver // initializing the resourceObserver
InstantBusyThread.oneTimeJob(ResourceObserver.class, "initThread", 0); this.observer = new ResourceObserver(this);
InstantBusyThread.oneTimeJob(this.observer, "resourceObserverJob", 0);
// initializing the stackCrawlThread // initializing the stackCrawlThread
this.crawlStacker = this.crawlStacker =
@ -2408,7 +2409,7 @@ public final class Switchboard extends serverSwitch {
// after all clean up is done, check the resource usage // after all clean up is done, check the resource usage
this.observer.resourceObserverJob(); this.observer.resourceObserverJob();
// clean up profiles // clean up profiles
checkInterruption(); checkInterruption();

Loading…
Cancel
Save