mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
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.
This commit is contained in:
parent
0dda979801
commit
bc28247089
|
@ -123,7 +123,7 @@ public class Status
|
|||
final 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());
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user