diff --git a/htroot/Performance_p.html b/htroot/Performance_p.html
index 08ea4fbab..47826943f 100644
--- a/htroot/Performance_p.html
+++ b/htroot/Performance_p.html
@@ -53,7 +53,8 @@
#{/table}#
-
+
+
Changes take effect immediately |
diff --git a/htroot/Performance_p.java b/htroot/Performance_p.java
index fa86e5283..67e434b98 100644
--- a/htroot/Performance_p.java
+++ b/htroot/Performance_p.java
@@ -44,6 +44,8 @@
// if the shell's current path is HTROOT
import java.util.Iterator;
+import java.util.Map;
+import java.io.File;
import org.apache.commons.pool.impl.GenericObjectPool;
@@ -54,6 +56,7 @@ import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.serverThread;
+import de.anomic.server.serverFileUtils;
public class Performance_p {
@@ -61,7 +64,9 @@ public class Performance_p {
// return variable that accumulates replacements
plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;
serverObjects prop = new serverObjects();
-
+ File defaultSettingsFile = new File(switchboard.getRootPath(), "yacy.init");
+ Map defaultSettings = ((post == null) || (!(post.containsKey("submitdefault")))) ? null : serverFileUtils.loadHashMap(defaultSettingsFile);
+
Iterator threads = switchboard.threadNames();
String threadName;
serverThread thread;
@@ -116,15 +121,31 @@ public class Performance_p {
prop.put("table_" + c + "_sleeppercycle", ((idleCycles + busyCycles) == 0) ? "-" : ("" + (sleeptime / (idleCycles + busyCycles))));
prop.put("table_" + c + "_execpercycle", (busyCycles == 0) ? "-" : ("" + (exectime / busyCycles)));
- if ((post != null) && (post.containsKey("delaysubmit"))) {
+ if ((post != null) && (post.containsKey("submitdelay"))) {
// load with new values
- idlesleep = Long.parseLong((String) post.get(threadName + "_idlesleep", "100"));
- busysleep = Long.parseLong((String) post.get(threadName + "_busysleep", "1000"));
+ idlesleep = Long.parseLong((String) post.get(threadName + "_idlesleep", "1000"));
+ busysleep = Long.parseLong((String) post.get(threadName + "_busysleep", "100"));
memprereq = Long.parseLong((String) post.get(threadName + "_memprereq", "0"));
// check values to prevent short-cut loops
- if (idlesleep == 0) idlesleep = 1000;
+ if (idlesleep < 1000) idlesleep = 1000;
+ if (threadName.equals("10_httpd")) { idlesleep = 0; busysleep = 0; memprereq = 0; }
+
+ // on-the-fly re-configuration
+ switchboard.setThreadPerformance(threadName, idlesleep, busysleep, memprereq);
+ switchboard.setConfig(threadName + "_idlesleep", idlesleep);
+ switchboard.setConfig(threadName + "_busysleep", busysleep);
+ switchboard.setConfig(threadName + "_memprereq", memprereq);
+ } if ((post != null) && (post.containsKey("submitdefault"))) {
+ // load with new values
+ idlesleep = Long.parseLong(d((String) defaultSettings.get(threadName + "_idlesleep"), "1000"));
+ busysleep = Long.parseLong(d((String) defaultSettings.get(threadName + "_busysleep"), "100"));
+ memprereq = Long.parseLong(d((String) defaultSettings.get(threadName + "_memprereq"), "0"));
+ // check values to prevent short-cut loops
+ if (idlesleep < 1000) idlesleep = 1000;
+ if (threadName.equals("10_httpd")) { idlesleep = 0; busysleep = 0; memprereq = 0; }
+
// on-the-fly re-configuration
switchboard.setThreadPerformance(threadName, idlesleep, busysleep, memprereq);
switchboard.setConfig(threadName + "_idlesleep", idlesleep);
@@ -133,8 +154,8 @@ public class Performance_p {
} else {
// load with old values
idlesleep = Long.parseLong(switchboard.getConfig(threadName + "_idlesleep" , "1000"));
- busysleep = Long.parseLong(switchboard.getConfig(threadName + "_busysleep", "1000"));
- memprereq = Long.parseLong(switchboard.getConfig(threadName + "_memprereq", "1000"));
+ busysleep = Long.parseLong(switchboard.getConfig(threadName + "_busysleep", "100"));
+ memprereq = Long.parseLong(switchboard.getConfig(threadName + "_memprereq", "0"));
}
prop.put("table_" + c + "_idlesleep", idlesleep);
prop.put("table_" + c + "_busysleep", busysleep);
@@ -219,4 +240,7 @@ public class Performance_p {
return prop;
}
+ private static String d(String a, String b) {
+ return (a == null) ? b : a;
+ }
}
diff --git a/htroot/env/grafics/notifier.gif b/htroot/env/grafics/notifier.gif
index 330c7e881..761a15a99 100644
Binary files a/htroot/env/grafics/notifier.gif and b/htroot/env/grafics/notifier.gif differ
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index f34949aae..4a0a5595e 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -193,7 +193,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
// load the yellow-list
f = switchboard.getConfig("proxyYellowList", null);
if (f != null) {
- yellowList = serverFileUtils.loadSet("yellow", f);
+ yellowList = serverFileUtils.loadSet(f);
this.theLogger.logSystem("loaded yellow-list from file " + f + ", " + yellowList.size() + " entries");
} else {
yellowList = new HashSet();
diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.java
index 4d69f8805..8446148c7 100644
--- a/source/de/anomic/server/serverAbstractSwitch.java
+++ b/source/de/anomic/server/serverAbstractSwitch.java
@@ -85,10 +85,10 @@ public abstract class serverAbstractSwitch implements serverSwitch {
// predefine init's
Map initProps;
- if (initFile.exists()) initProps = loadHashMap(initFile); else initProps = new HashMap();
+ if (initFile.exists()) initProps = serverFileUtils.loadHashMap(initFile); else initProps = new HashMap();
// load config's from last save
- if (configFile.exists()) configProps = loadHashMap(configFile); else configProps = new HashMap();
+ if (configFile.exists()) configProps = serverFileUtils.loadHashMap(configFile); else configProps = new HashMap();
synchronized (configProps) {
@@ -131,41 +131,6 @@ public abstract class serverAbstractSwitch implements serverSwitch {
return log;
}
- public static Map loadHashMap(File f) {
- // load props
- Properties prop = new Properties();
- BufferedInputStream bufferedIn = null;
- try {
- prop.load(bufferedIn = new BufferedInputStream(new FileInputStream(f)));
- } catch (IOException e1) {
- System.err.println("ERROR: " + f.toString() + " not found in settings path");
- prop = null;
- } finally {
- if (bufferedIn != null)try{bufferedIn.close();}catch(Exception e){}
- }
- return (Hashtable) prop;
- }
-
- public static void saveMap(File f, Map props, String comment) throws IOException {
- PrintWriter pw = null;
- try {
- pw = new PrintWriter(new BufferedOutputStream(new FileOutputStream(f)));
- pw.println("# " + comment);
- Iterator i = props.entrySet().iterator();
- String key, value;
- Map.Entry entry;
- while (i.hasNext()) {
- entry = (Map.Entry) i.next();
- key = (String) entry.getKey();
- value = ((String) entry.getValue()).replaceAll("\n", "\\\\n");
- pw.println(key + "=" + value);
- }
- pw.println("# EOF");
- } finally {
- if (pw!=null)try{pw.close();}catch(Exception e){}
- }
- }
-
public void setConfig(String key, long value) {
setConfig(key, "" + value);
}
@@ -230,7 +195,7 @@ public abstract class serverAbstractSwitch implements serverSwitch {
private void saveConfig() {
try {
- saveMap(configFile, configProps, configComment);
+ serverFileUtils.saveMap(configFile, configProps, configComment);
} catch (IOException e) {
System.out.println("ERROR: cannot write config file " + configFile.toString() + ": " + e.getMessage());
}
diff --git a/source/de/anomic/server/serverFileUtils.java b/source/de/anomic/server/serverFileUtils.java
index 84d84ea66..8fa476a29 100644
--- a/source/de/anomic/server/serverFileUtils.java
+++ b/source/de/anomic/server/serverFileUtils.java
@@ -50,8 +50,16 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.PrintWriter;
import java.util.zip.GZIPOutputStream;
import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Hashtable;
+import java.util.Iterator;
public final class serverFileUtils {
@@ -145,7 +153,7 @@ public final class serverFileUtils {
copy(new ByteArrayInputStream(source), dest);
}
- public static HashSet loadSet(String setname, String filename) {
+ public static HashSet loadSet(String filename) {
HashSet set = new HashSet();
BufferedReader br = null;
try {
@@ -163,4 +171,39 @@ public final class serverFileUtils {
return set;
}
+ public static Map loadHashMap(File f) {
+ // load props
+ Properties prop = new Properties();
+ BufferedInputStream bufferedIn = null;
+ try {
+ prop.load(bufferedIn = new BufferedInputStream(new FileInputStream(f)));
+ } catch (IOException e1) {
+ System.err.println("ERROR: " + f.toString() + " not found in settings path");
+ prop = null;
+ } finally {
+ if (bufferedIn != null)try{bufferedIn.close();}catch(Exception e){}
+ }
+ return (Hashtable) prop;
+ }
+
+ public static void saveMap(File f, Map props, String comment) throws IOException {
+ PrintWriter pw = null;
+ try {
+ pw = new PrintWriter(new BufferedOutputStream(new FileOutputStream(f)));
+ pw.println("# " + comment);
+ Iterator i = props.entrySet().iterator();
+ String key, value;
+ Map.Entry entry;
+ while (i.hasNext()) {
+ entry = (Map.Entry) i.next();
+ key = (String) entry.getKey();
+ value = ((String) entry.getValue()).replaceAll("\n", "\\\\n");
+ pw.println(key + "=" + value);
+ }
+ pw.println("# EOF");
+ } finally {
+ if (pw!=null)try{pw.close();}catch(Exception e){}
+ }
+ }
+
}