same units for memory observer configuration (MiB)

old setting for DHT (RAM) will be lost after update
can be set on /Performance_p.html

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7418 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
lotus 14 years ago
parent 621e176071
commit b1484299b2

@ -887,8 +887,8 @@ disk.free = 3000
# minimum for DHT # minimum for DHT
disk.free.hardlimit = 1000 disk.free.hardlimit = 1000
# minimum memory to accept dht-in (KB) # minimum memory to accept dht-in (MiB)
memory.acceptDHT = 50000 memory.acceptDHTabove = 50
memory.disabledDHT = false memory.disabledDHT = false
# setting if execution of CGI files is allowed or not # setting if execution of CGI files is allowed or not

@ -102,7 +102,7 @@ public class PerformanceQueues_p {
sb.setConfig(SwitchboardConstants.DISK_FREE_HARDLIMIT, diskFreeHardlimit); sb.setConfig(SwitchboardConstants.DISK_FREE_HARDLIMIT, diskFreeHardlimit);
} }
if(post.containsKey("memoryAcceptDHT")) { if(post.containsKey("memoryAcceptDHT")) {
int memoryAcceptDHT = 50000; // default int memoryAcceptDHT = 50; // default
try { memoryAcceptDHT = Integer.parseInt(post.get("memoryAcceptDHT", Integer.toString(memoryAcceptDHT))); } catch (final NumberFormatException e){} try { memoryAcceptDHT = Integer.parseInt(post.get("memoryAcceptDHT", Integer.toString(memoryAcceptDHT))); } catch (final NumberFormatException e){}
sb.setConfig(SwitchboardConstants.MEMORY_ACCEPTDHT, memoryAcceptDHT); sb.setConfig(SwitchboardConstants.MEMORY_ACCEPTDHT, memoryAcceptDHT);
} }

@ -45,7 +45,7 @@
<dd>disable crawls below <input name="diskFree" id="diskFree" type="text" size="4" value="#[diskFree]#" /> MiB free space,<br/> <dd>disable crawls below <input name="diskFree" id="diskFree" type="text" size="4" value="#[diskFree]#" /> MiB free space,<br/>
disable DHT-in below <input name="diskFreeHardlimit" id="diskFreeHardlimit" type="text" size="4" value="#[diskFreeHardlimit]#" /> MiB free space</dd> disable DHT-in below <input name="diskFreeHardlimit" id="diskFreeHardlimit" type="text" size="4" value="#[diskFreeHardlimit]#" /> MiB free space</dd>
<dt><label for="memoryAcceptDHT">RAM</label></dt> <dt><label for="memoryAcceptDHT">RAM</label></dt>
<dd>disable DHT-in below <input name="memoryAcceptDHT" id="memoryAcceptDHT" type="text" size="4" value="#[memoryAcceptDHT]#" /> KiB free space</dd> <dd>disable DHT-in below <input name="memoryAcceptDHT" id="memoryAcceptDHT" type="text" size="4" value="#[memoryAcceptDHT]#" /> MiB free space</dd>
<dt>&nbsp;</dt> <dt>&nbsp;</dt>
<dd><input type="submit" name="setObserver" value="Save" /></dd> <dd><input type="submit" name="setObserver" value="Save" /></dd>
</dl> </dl>

@ -63,7 +63,7 @@ public class ResourceObserver {
* checks the resources and pauses crawls if necessary * checks the resources and pauses crawls if necessary
*/ */
public void resourceObserverJob() { public void resourceObserverJob() {
MemoryControl.setDHTkbytes(getMinFreeMemory()); MemoryControl.setDHTMbyte(getMinFreeMemory());
normalizedDiskFree = getNormalizedDiskFree(); normalizedDiskFree = getNormalizedDiskFree();
normalizedMemoryFree = getNormalizedMemoryFree(); normalizedMemoryFree = getNormalizedMemoryFree();
@ -157,7 +157,7 @@ public class ResourceObserver {
} }
/** /**
* @return amount of space (KiB) that should at least be free * @return amount of space (MiB) that should at least be free
*/ */
public long getMinFreeMemory() { public long getMinFreeMemory() {
return sb.getConfigLong(SwitchboardConstants.MEMORY_ACCEPTDHT, 0); return sb.getConfigLong(SwitchboardConstants.MEMORY_ACCEPTDHT, 0);

@ -373,7 +373,7 @@ public final class SwitchboardConstants {
public static final String DISK_FREE = "disk.free"; public static final String DISK_FREE = "disk.free";
public static final String DISK_FREE_HARDLIMIT = "disk.free.hardlimit"; public static final String DISK_FREE_HARDLIMIT = "disk.free.hardlimit";
public static final String MEMORY_ACCEPTDHT = "memory.acceptDHT"; public static final String MEMORY_ACCEPTDHT = "memory.acceptDHTabove";
public static final String INDEX_RECEIVE_AUTODISABLED = "memory.disabledDHT"; public static final String INDEX_RECEIVE_AUTODISABLED = "memory.disabledDHT";
/* /*

@ -43,7 +43,7 @@ public class MemoryControl {
private static long lastGC = 0l; private static long lastGC = 0l;
private static long DHTkbytes = 0L; private static long DHTMbyte = 0L;
private static long prevDHTtreshold = 0L; private static long prevDHTtreshold = 0L;
private static int DHTtresholdCount = 0; private static int DHTtresholdCount = 0;
private static boolean allowDHT = true; private static boolean allowDHT = true;
@ -185,14 +185,17 @@ public class MemoryControl {
DHTtresholdCount = 0; DHTtresholdCount = 0;
} }
public static void setDHTkbytes(final long kbytes) { /**
DHTkbytes = kbytes; * set the memory to be available
*/
public static void setDHTMbyte(final long mbyte) {
DHTMbyte = mbyte;
DHTtresholdCount = 0; DHTtresholdCount = 0;
} }
private static void checkDHTrule(final long available) { private static void checkDHTrule(final long available) {
// disable dht if memory is less than treshold - 4 times, maximum 11 minutes between each detection // disable dht if memory is less than treshold - 4 times, maximum 11 minutes between each detection
if ((available >> 10) < DHTkbytes) { if ((available >> 20) < DHTMbyte) {
final long t = System.currentTimeMillis(); final long t = System.currentTimeMillis();
if(prevDHTtreshold + 11L /* minutes */ * 60000L > t) { if(prevDHTtreshold + 11L /* minutes */ * 60000L > t) {
DHTtresholdCount++; DHTtresholdCount++;
@ -204,7 +207,7 @@ public class MemoryControl {
log.logInfo("checkDHTrule: below treshold; tresholdCount: " + DHTtresholdCount + "; allowDHT: " + allowDHT); log.logInfo("checkDHTrule: below treshold; tresholdCount: " + DHTtresholdCount + "; allowDHT: " + allowDHT);
} }
else if (!allowDHT && (available >> 10) > (DHTkbytes * 2L)) // we were wrong! else if (!allowDHT && (available >> 20) > (DHTMbyte * 2L)) // we were wrong!
setDHTallowed(); setDHTallowed();
} }

Loading…
Cancel
Save