Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Added methods in resource observer to calculate the available and the occupied disc space. These values are also shown on the status page. The disc space calculation shall be used for a disk-limitation of the search index.
Michael Peter Christenbc28247089dc
diff --git a/htroot/Status.java b/htroot/Status.javaindex 7e0c98211..5ff0dbaf8 100644--- a/htroot/Status.java+++ b/htroot/Status.java@@ -123,7 +123,7 @@ public class Statusfinal boolean adminaccess = sb.adminAuthenticated(header) >= 2;if ( adminaccess ) {prop.put("showPrivateTable", "1");- prop.put("privateStatusTable", "Status_p.inc");+ prop.put("privateStatusTable", "status_p.inc");} else {prop.put("showPrivateTable", "0");prop.put("privateStatusTable", "");@@ -318,9 +318,10 @@ public class Status}// memory usage and system attributes- prop.put("freeMemory", Formatter.bytesToString(MemoryControl.free()));- prop.put("totalMemory", Formatter.bytesToString(MemoryControl.total()));+ prop.put("usedMemory", Formatter.bytesToString(MemoryControl.total()));prop.put("maxMemory", Formatter.bytesToString(MemoryControl.maxMemory()));+ prop.put("usedDisk", Formatter.bytesToString(sb.observer.getSizeOfDataPath()));+ prop.put("freeDisk", Formatter.bytesToString(sb.observer.getUsableSpace()));prop.put("processors", WorkflowProcessor.availableCPU);prop.put("load", Memory.load());diff --git a/htroot/Status_p.inc b/htroot/Status_p.incindex fc5708368..87c2082f4 100644--- a/htroot/Status_p.inc+++ b/htroot/Status_p.inc@@ -67,10 +67,12 @@</dd><dt><a href="PerformanceMemory_p.html">Memory Usage</a></dt>- <dd>- free: #[freeMemory]#<br/>- total: #[totalMemory]#<br/>- max: #[maxMemory]#</dd>+ <dd><table border="0" cellspacing="0">+ <tr><td>RAM used:</td><td align="right">#[usedMemory]#</td></tr>+ <tr><td>RAM max:</td><td align="right">#[maxMemory]#</td></tr>+ <tr><td>DISK used:</td><td align="right">#[usedDisk]#</td></tr>+ <tr><td>DISK free:</td><td align="right">#[freeDisk]#</td></tr>+ </table></dd><dt>Traffic [<a href="Status.html?ResetTraffic=">Reset</a>]</dt><dd>Proxy: #[trafficProxy]#<br/>Crawler: #[trafficCrawler]#</dd>diff --git a/source/net/yacy/search/ResourceObserver.java b/source/net/yacy/search/ResourceObserver.javaindex 32e8d2396..f7941a09f 100644--- a/source/net/yacy/search/ResourceObserver.java+++ b/source/net/yacy/search/ResourceObserver.java@@ -26,6 +26,8 @@ package net.yacy.search;import java.io.File;+import org.apache.commons.io.FileUtils;+import net.yacy.cora.document.WordCache;import net.yacy.cora.protocol.Domains;import net.yacy.cora.util.ConcurrentLog;@@ -70,7 +72,7 @@ public class ResourceObserver {if (this.normalizedDiskFree.compareTo(Space.HIGH) < 0 || this.normalizedMemoryFree.compareTo(Space.HIGH) < 0 ) {String reason = "";- if (this.normalizedDiskFree.compareTo(Space.HIGH) < 0) reason += " not enough disk space, " + this.path.getUsableSpace();+ if (this.normalizedDiskFree.compareTo(Space.HIGH) < 0) reason += " not enough disk space, " + getUsableSpace();if (this.normalizedMemoryFree.compareTo(Space.HIGH) < 0 ) reason += " not enough memory space";if (!this.sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)) {log.info("pausing local crawls");@@ -100,6 +102,19 @@ public class ResourceObserver {}}+ private long sizeOfDirectory_lastCountTime = 0;+ private long sizeOfDirectory_lastCountValue = 0;+ public long getSizeOfDataPath() {+ if (System.currentTimeMillis() - this.sizeOfDirectory_lastCountTime < 60000) return this.sizeOfDirectory_lastCountValue;+ this.sizeOfDirectory_lastCountTime = System.currentTimeMillis();+ this.sizeOfDirectory_lastCountValue = FileUtils.sizeOfDirectory(this.path);+ return this.sizeOfDirectory_lastCountValue;+ }++ public long getUsableSpace() {+ return this.path.getUsableSpace();+ }+/*** returns the amount of disk space available* @return <ul>@@ -109,7 +124,7 @@ public class ResourceObserver {* </ul>*/private Space getNormalizedDiskFree() {- final long currentSpace = this.path.getUsableSpace();+ final long currentSpace = getUsableSpace();//final long currentSpace = getUsableSpace(this.path);if (currentSpace < 1L) return Space.HIGH;Space ret = Space.HIGH;