Use HTTP Post operation for resetting memory monitoring state.

Fixes issue #145

Also added textual hint on the button, and display it only when it makes
sense, that is to say when the memory state is 'exhausted'.
pull/149/head
luccioman 7 years ago
parent 0704b1d644
commit c5c3cc1274

@ -62,54 +62,56 @@ public class PerformanceQueues_p {
/* Check the transaction is valid : validation apply then for every uses of this post parameter */
TransactionManager.checkPostTransaction(header, post);
if(post.containsKey("defaultFile")){
// TODO check file-path!
final File value = new File(sb.getAppPath(), post.get("defaultFile", "defaults/yacy.init"));
// check if value is readable file
if(value.exists() && value.isFile() && value.canRead()) {
defaultSettingsFile = value;
}
}
if (post.containsKey("Xmx")) {
int xmx = post.getInt("Xmx", 600); // default maximum heap size
if (OS.isWin32) xmx = Math.min(2000, xmx);
int xms = xmx; //Math.min(xmx, Math.max(90, xmx / 10));
sb.setConfig("javastart_Xmx", "Xmx" + xmx + "m");
sb.setConfig("javastart_Xms", "Xms" + xms + "m");
prop.put("setStartupCommit", "1");
if(post.containsKey("resetObserver")) {
/* The the reset state button is pushed, we only perform this action and do not save other form field values at the same time */
MemoryControl.resetProperState();
} else {
if(post.containsKey("defaultFile")){
// TODO check file-path!
final File value = new File(sb.getAppPath(), post.get("defaultFile", "defaults/yacy.init"));
// check if value is readable file
if(value.exists() && value.isFile() && value.canRead()) {
defaultSettingsFile = value;
}
}
if (post.containsKey("Xmx")) {
int xmx = post.getInt("Xmx", 600); // default maximum heap size
if (OS.isWin32) xmx = Math.min(2000, xmx);
int xms = xmx; //Math.min(xmx, Math.max(90, xmx / 10));
sb.setConfig("javastart_Xmx", "Xmx" + xmx + "m");
sb.setConfig("javastart_Xms", "Xms" + xms + "m");
prop.put("setStartupCommit", "1");
/* Acquire a transaction token for the restart operation */
prop.put("setStartupCommit_" + TransactionManager.TRANSACTION_TOKEN_PARAM, TransactionManager.getTransactionToken(header, "/Steering.html"));
}
if(post.containsKey("diskFree")) {
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_FREE_MIN_STEADYSTATE, post.getLong("diskFree", SwitchboardConstants.RESOURCE_DISK_FREE_MIN_STEADYSTATE_DEFAULT));
}
if(post.containsKey("diskFreeHardlimit")) {
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_FREE_MIN_UNDERSHOT, post.getLong("diskFreeHardlimit", SwitchboardConstants.RESOURCE_DISK_FREE_MIN_UNDERSHOT_DEFAULT));
/* Acquire a transaction token for the restart operation */
prop.put("setStartupCommit_" + TransactionManager.TRANSACTION_TOKEN_PARAM, TransactionManager.getTransactionToken(header, "/Steering.html"));
}
if(post.containsKey("diskFree")) {
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_FREE_MIN_STEADYSTATE, post.getLong("diskFree", SwitchboardConstants.RESOURCE_DISK_FREE_MIN_STEADYSTATE_DEFAULT));
}
if(post.containsKey("diskFreeHardlimit")) {
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_FREE_MIN_UNDERSHOT, post.getLong("diskFreeHardlimit", SwitchboardConstants.RESOURCE_DISK_FREE_MIN_UNDERSHOT_DEFAULT));
/* This is a checkbox in Performance_p.html : when not checked the value is not in post parameters,
* so we take only in account when the relate diskFreeHardlimit is set */
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_FREE_AUTOREGULATE,
post.getBoolean("diskFreeAutoregulate"));
}
if (post.containsKey("diskUsed")) {
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_USED_MAX_STEADYSTATE,
post.getLong("diskUsed", SwitchboardConstants.RESOURCE_DISK_USED_MAX_STEADYSTATE_DEFAULT));
}
if (post.containsKey("diskUsedHardlimit")) {
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_USED_MAX_OVERSHOT, post.getLong("diskUsedHardlimit",
SwitchboardConstants.RESOURCE_DISK_USED_MAX_OVERSHOT_DEFAULT));
/* This is a checkbox in Performance_p.html : when not checked the value is not in post parameters,
* so we take only in account when the relate diskFreeHardlimit is set */
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_FREE_AUTOREGULATE,
post.getBoolean("diskFreeAutoregulate"));
}
if (post.containsKey("diskUsed")) {
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_USED_MAX_STEADYSTATE,
post.getLong("diskUsed", SwitchboardConstants.RESOURCE_DISK_USED_MAX_STEADYSTATE_DEFAULT));
}
if (post.containsKey("diskUsedHardlimit")) {
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_USED_MAX_OVERSHOT, post.getLong("diskUsedHardlimit",
SwitchboardConstants.RESOURCE_DISK_USED_MAX_OVERSHOT_DEFAULT));
/* This is a checkbox in Performance_p.html : when not checked the value is not in post parameters,
* so we take only in account when the related diskFreeHardlimit is set */
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_USED_AUTOREGULATE,
post.getBoolean("diskUsedAutoregulate"));
}
if(post.containsKey("memoryAcceptDHT")) {
sb.setConfig(SwitchboardConstants.MEMORY_ACCEPTDHT, post.getInt("memoryAcceptDHT", 50));
}
if(post.containsKey("resetObserver")) {
MemoryControl.resetProperState();
/* This is a checkbox in Performance_p.html : when not checked the value is not in post parameters,
* so we take only in account when the related diskFreeHardlimit is set */
sb.setConfig(SwitchboardConstants.RESOURCE_DISK_USED_AUTOREGULATE,
post.getBoolean("diskUsedAutoregulate"));
}
if(post.containsKey("memoryAcceptDHT")) {
sb.setConfig(SwitchboardConstants.MEMORY_ACCEPTDHT, post.getInt("memoryAcceptDHT", 50));
}
}
}
final Map<String, String> defaultSettings = ((post == null) || (!(post.containsKey("submitdefault")))) ? null : FileUtils.loadMap(defaultSettingsFile);

@ -126,8 +126,9 @@
<span class="info">
<img src="env/grafics/i16.gif" width="16" height="16" alt="Exhausted state info"/>
<span class="infobox" id="exhaustedStateInfo">Within the last eleven minutes, at least four operations have tried to request memory that would have reduced free space within the minimum required.</span>
</span>#(/observerTrigger)#
<a href="?resetObserver=">[reset state]</a>
</span>
<input type="submit" class="btn btn-warning" name="resetObserver" value="Reset state" title="Manually reset to 'proper' state"/>
#(/observerTrigger)#
</div>
<div class="form-group">
<label for="memoryAcceptDHT">Minimum required</label>

@ -2433,7 +2433,7 @@ Memory Settings==Speicher Einstellungen
Memory reserved for <abbr title="Java Virtual Machine">JVM</abbr>==Für <abbr title="Java Virtual Machine">JVM</abbr> reservierter Speicher
"Set"=="Setzen"
Resource Observer==Ressourcen Beobachter
reset state==Status zurücksetzen
Reset state==Status zurücksetzen
> free space==> freiem Speicher
disable <abbr title="Distributed Hash Table">DHT</abbr>-in below==Deaktivere eingehende <abbr title="Distributed Hash Table">DHT</abbr> Transfers unter
<abbr title="Random Access Memory">RAM</abbr>==Arbeitsspeicher

@ -1482,7 +1482,8 @@ Resource Observer==Contrôle des ressources
Memory state==État de la mémoire
>proper<==>sain<
>exhausted<==>espace libre insuffisant<
reset state==réinitialiser l'état
Reset state==Réinitialiser l'état
Manually reset to 'proper' state==Réinitialiser manuellement à l'état 'sain'
Enough memory is available for proper operation.==Il y a suffisamment de mémoire à disposition pour un fonctionnement correct.
Within the last eleven minutes, at least four operations have tried to request memory that would have reduced free space within the minimum required.==Durant les onze dernières minutes, au moins quatre opérations ont tenté d'obtenir une quantité de mémoire qui aurait réduit l'espace libre en-deçà du minimum requis.
Minimum required==Minimum requis

@ -6692,7 +6692,10 @@
<source>&gt;exhausted&lt;</source>
</trans-unit>
<trans-unit id="7ade7e80" xml:space="preserve" approved="no" translate="yes">
<source>reset state</source>
<source>Reset state</source>
</trans-unit>
<trans-unit id="6d08abc8" xml:space="preserve" approved="no" translate="yes">
<source>Manually reset to 'proper' state</source>
</trans-unit>
<trans-unit id="a5c476c2" xml:space="preserve" approved="no" translate="yes">
<source>Enough memory is available for proper operation.</source>

@ -2540,7 +2540,7 @@ Memory Settings==Настройки оперативной памяти
Memory reserved for <abbr title="Java Virtual Machine">JVM</abbr>==Резервирование динамической памяти для Java
"Set"=="Сохранить"
Resource Observer==Обзор ресурсов
reset state==сбросить состояние
Reset state==сбросить состояние
> free space==> свободного места
disable <abbr title="Distributed Hash Table">DHT</abbr>-in below==Остановить <abbr title="Distributed Hash Table">DHT</abbr>-приём при достижении
Accepted change. This will take effect after <strong>restart</strong> of YaCy==Изменения будут применены после <strong>перезапуска</strong> YaCy

@ -2172,7 +2172,7 @@ Memory Settings==Налаштування пам’яті
Memory reserved for <abbr title="Java Virtual Machine">JVM</abbr>==Пам’ять, утримувана для <abbr title="Java Virtual Machine">JVM</abbr>
"Set"=="Виставити"
Resource Observer==Спостерігач за ресурсами
reset state==відновити стан
Reset state==відновити стан
> free space==> вільної пам’яті
disable <abbr title="Distributed Hash Table">DHT</abbr>-in below==Вимкнути отримання <abbr title="Distributed Hash Table">DHT</abbr> при менше
<abbr title="Random Access Memory">RAM</abbr>==Основна пам’ять

@ -2003,7 +2003,7 @@ Memory Settings==内存设置
Memory reserved for <abbr title="Java Virtual Machine">JVM</abbr>==<abbr title="Java Virtual Machine">JVM</abbr>内存设置
"Set"=="设置"
Resource Observer==资源查看
reset state==重置
Reset state==重置
> free space==> 空闲空间
disable <abbr title="Distributed Hash Table">DHT</abbr>-in below==停止接收<abbr title="Distributed Hash Table">DHT</abbr>当低于
<abbr title="Random Access Memory">RAM</abbr>==内存

Loading…
Cancel
Save