|
|
|
@ -55,13 +55,13 @@ public class PerformanceQueues_p {
|
|
|
|
|
performanceProfiles.put("defaults/yacy.init", "default (crawl)");
|
|
|
|
|
performanceProfiles.put("defaults/performance_dht.profile", "prefer DHT");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
|
|
|
|
// return variable that accumulates replacements
|
|
|
|
|
final Switchboard sb = (Switchboard) env;
|
|
|
|
|
final serverObjects prop = new serverObjects();
|
|
|
|
|
File defaultSettingsFile = new File(sb.getAppPath(), "defaults/yacy.init");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get segment
|
|
|
|
|
Segment indexSegment = null;
|
|
|
|
|
if (post != null && post.containsKey("segment")) {
|
|
|
|
@ -73,7 +73,7 @@ public class PerformanceQueues_p {
|
|
|
|
|
// take default segment
|
|
|
|
|
indexSegment = sb.indexSegments.segment(Segments.Process.PUBLIC);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(post != null) {
|
|
|
|
|
if(post.containsKey("defaultFile")){
|
|
|
|
|
// TODO check file-path!
|
|
|
|
@ -108,10 +108,10 @@ public class PerformanceQueues_p {
|
|
|
|
|
Iterator<String> threads = sb.threadNames();
|
|
|
|
|
String threadName;
|
|
|
|
|
BusyThread thread;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final boolean xml = (header.get(HeaderFramework.CONNECTION_PROP_PATH)).endsWith(".xml");
|
|
|
|
|
prop.setLocalized(!xml);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// calculate totals
|
|
|
|
|
long blocktime_total = 0, sleeptime_total = 0, exectime_total = 0;
|
|
|
|
|
while (threads.hasNext()) {
|
|
|
|
@ -120,11 +120,11 @@ public class PerformanceQueues_p {
|
|
|
|
|
blocktime_total += thread.getBlockTime();
|
|
|
|
|
sleeptime_total += thread.getSleepTime();
|
|
|
|
|
exectime_total += thread.getExecTime();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (blocktime_total == 0) blocktime_total = 1;
|
|
|
|
|
if (sleeptime_total == 0) sleeptime_total = 1;
|
|
|
|
|
if (exectime_total == 0) exectime_total = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set templates for latest news from the threads
|
|
|
|
|
long blocktime, sleeptime, exectime;
|
|
|
|
|
long idlesleep, busysleep, memuse, memprereq;
|
|
|
|
@ -141,11 +141,11 @@ public class PerformanceQueues_p {
|
|
|
|
|
sb.setConfig("performanceProfile", post.get("defaultFile", "defaults/yacy.init"));
|
|
|
|
|
sb.setConfig("performanceSpeed", post.getInt("profileSpeed", 100));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (threads.hasNext()) {
|
|
|
|
|
threadName = threads.next();
|
|
|
|
|
thread = sb.getThread(threadName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set values to templates
|
|
|
|
|
prop.put("table_" + c + "_threadname", threadName);
|
|
|
|
|
|
|
|
|
@ -159,7 +159,7 @@ public class PerformanceQueues_p {
|
|
|
|
|
prop.putHTML("table_" + c + "_longdescr", thread.getLongDescription());
|
|
|
|
|
queuesize = thread.getJobCount();
|
|
|
|
|
prop.put("table_" + c + "_queuesize", (queuesize == Integer.MAX_VALUE) ? "unlimited" : Formatter.number(queuesize, !xml));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
blocktime = thread.getBlockTime();
|
|
|
|
|
sleeptime = thread.getSleepTime();
|
|
|
|
|
exectime = thread.getExecTime();
|
|
|
|
@ -180,7 +180,7 @@ public class PerformanceQueues_p {
|
|
|
|
|
prop.putNum("table_" + c + "_sleeppercycle", ((idleCycles + busyCycles) == 0) ? -1 : sleeptime / (idleCycles + busyCycles));
|
|
|
|
|
prop.putNum("table_" + c + "_execpercycle", (busyCycles == 0) ? -1 : exectime / busyCycles);
|
|
|
|
|
prop.putNum("table_" + c + "_memusepercycle", (busyCycles == 0) ? -1 : memuse / busyCycles / 1024);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// load with old values
|
|
|
|
|
idlesleep = sb.getConfigLong(threadName + "_idlesleep" , 1000);
|
|
|
|
|
busysleep = sb.getConfigLong(threadName + "_busysleep", 100);
|
|
|
|
@ -189,13 +189,13 @@ public class PerformanceQueues_p {
|
|
|
|
|
// load with new values
|
|
|
|
|
idlesleep = post.getLong(threadName + "_idlesleep", idlesleep);
|
|
|
|
|
busysleep = post.getLong(threadName + "_busysleep", busysleep);
|
|
|
|
|
memprereq = post.getLong(threadName + "_memprereq", memprereq) * 1024;
|
|
|
|
|
memprereq = post.getLong(threadName + "_memprereq", memprereq) * 1024l;
|
|
|
|
|
if (memprereq == 0) memprereq = sb.getConfigLong(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; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sb.setThreadPerformance(threadName, idlesleep, busysleep, memprereq);
|
|
|
|
|
idlesleep = sb.getConfigLong(threadName + "_idlesleep", idlesleep);
|
|
|
|
|
busysleep = sb.getConfigLong(threadName + "_busysleep", busysleep);
|
|
|
|
@ -228,7 +228,7 @@ public class PerformanceQueues_p {
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
prop.put("table", c);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// performance profiles
|
|
|
|
|
c = 0;
|
|
|
|
|
final String usedfile = sb.getConfig("performanceProfile", "defaults/yacy.init");
|
|
|
|
@ -239,7 +239,7 @@ public class PerformanceQueues_p {
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
prop.put("profile", c);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c = 0;
|
|
|
|
|
final int[] speedValues = {200,150,100,50,25,10};
|
|
|
|
|
final int usedspeed = sb.getConfigInt("performanceSpeed", 100);
|
|
|
|
@ -250,27 +250,27 @@ public class PerformanceQueues_p {
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
prop.put("speed", c);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((post != null) && (post.containsKey("cacheSizeSubmit"))) {
|
|
|
|
|
final int wordCacheMaxCount = post.getInt("wordCacheMaxCount", 20000);
|
|
|
|
|
sb.setConfig(SwitchboardConstants.WORDCACHE_MAX_COUNT, Integer.toString(wordCacheMaxCount));
|
|
|
|
|
indexSegment.termIndex().setBufferMaxWordCount(wordCacheMaxCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((post != null) && (post.containsKey("poolConfig"))) {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* configuring the crawler pool
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* configuring the crawler pool
|
|
|
|
|
*/
|
|
|
|
|
// get the current crawler pool configuration
|
|
|
|
|
int maxBusy = post.getInt("Crawler Pool_maxActive", 8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// storing the new values into configfile
|
|
|
|
|
sb.setConfig(SwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX,maxBusy);
|
|
|
|
|
//switchboard.setConfig("crawler.MinIdleThreads",minIdle);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* configuring the http pool
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* configuring the http pool
|
|
|
|
|
*/
|
|
|
|
|
final WorkflowThread httpd = sb.getThread("10_httpd");
|
|
|
|
|
try {
|
|
|
|
@ -279,23 +279,23 @@ public class PerformanceQueues_p {
|
|
|
|
|
maxBusy = 8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
((serverCore)httpd).setMaxSessionCount(maxBusy);
|
|
|
|
|
|
|
|
|
|
((serverCore)httpd).setMaxSessionCount(maxBusy);
|
|
|
|
|
|
|
|
|
|
// storing the new values into configfile
|
|
|
|
|
sb.setConfig("httpdMaxBusySessions",maxBusy);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((post != null) && (post.containsKey("PrioritySubmit"))) {
|
|
|
|
|
sb.setConfig("javastart_priority",post.get("YaCyPriority","0"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((post != null) && (post.containsKey("onlineCautionSubmit"))) {
|
|
|
|
|
sb.setConfig(SwitchboardConstants.PROXY_ONLINE_CAUTION_DELAY, Integer.toString(post.getInt("crawlPauseProxy", 30000)));
|
|
|
|
|
sb.setConfig(SwitchboardConstants.LOCALSEACH_ONLINE_CAUTION_DELAY, Integer.toString(post.getInt("crawlPauseLocalsearch", 30000)));
|
|
|
|
|
sb.setConfig(SwitchboardConstants.REMOTESEARCH_ONLINE_CAUTION_DELAY, Integer.toString(post.getInt("crawlPauseRemotesearch", 30000)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((post != null) && (post.containsKey("minimumDeltaSubmit"))) {
|
|
|
|
|
final long minimumLocalDelta = post.getLong("minimumLocalDelta", sb.crawlQueues.noticeURL.getMinimumLocalDelta());
|
|
|
|
|
final long minimumGlobalDelta = post.getLong("minimumGlobalDelta", sb.crawlQueues.noticeURL.getMinimumGlobalDelta());
|
|
|
|
@ -303,13 +303,13 @@ public class PerformanceQueues_p {
|
|
|
|
|
sb.setConfig("minimumGlobalDelta", minimumGlobalDelta);
|
|
|
|
|
sb.crawlQueues.noticeURL.setMinimumDelta(minimumLocalDelta, minimumGlobalDelta);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// delta settings
|
|
|
|
|
prop.put("minimumLocalDelta", sb.crawlQueues.noticeURL.getMinimumLocalDelta());
|
|
|
|
|
prop.put("minimumGlobalDelta", sb.crawlQueues.noticeURL.getMinimumGlobalDelta());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// table cache settings
|
|
|
|
|
prop.putNum("urlCacheSize", indexSegment.urlMetadata().writeCacheSize());
|
|
|
|
|
prop.putNum("urlCacheSize", indexSegment.urlMetadata().writeCacheSize());
|
|
|
|
|
prop.putNum("wordCacheSize", indexSegment.termIndex().getBufferSize());
|
|
|
|
|
prop.putNum("wordCacheSizeKBytes", indexSegment.termIndex().getBufferSizeBytes()/1024);
|
|
|
|
|
prop.putNum("maxURLinCache", indexSegment.termIndex().getBufferMaxReferences());
|
|
|
|
@ -323,30 +323,30 @@ public class PerformanceQueues_p {
|
|
|
|
|
prop.putNum("crawlPauseProxyCurrent", (System.currentTimeMillis() - sb.proxyLastAccess) / 1000);
|
|
|
|
|
prop.putNum("crawlPauseLocalsearchCurrent", (System.currentTimeMillis() - sb.localSearchLastAccess) / 1000);
|
|
|
|
|
prop.putNum("crawlPauseRemotesearchCurrent", (System.currentTimeMillis() - sb.remoteSearchLastAccess) / 1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// table thread pool settings
|
|
|
|
|
prop.put("pool_0_name","Crawler Pool");
|
|
|
|
|
prop.put("pool_0_maxActive", sb.getConfigLong("crawler.MaxActiveThreads", 0));
|
|
|
|
|
prop.put("pool_0_numActive",sb.crawlQueues.workerSize());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final WorkflowThread httpd = sb.getThread("10_httpd");
|
|
|
|
|
prop.put("pool_1_name", "httpd Session Pool");
|
|
|
|
|
prop.put("pool_1_maxActive", ((serverCore)httpd).getMaxSessionCount());
|
|
|
|
|
prop.put("pool_1_numActive", ((serverCore)httpd).getJobCount());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prop.put("pool", "2");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final long curr_prio = sb.getConfigLong("javastart_priority",0);
|
|
|
|
|
prop.put("priority_normal",(curr_prio == 0) ? "1" : "0");
|
|
|
|
|
prop.put("priority_below",(curr_prio == 10) ? "1" : "0");
|
|
|
|
|
prop.put("priority_low",(curr_prio == 20) ? "1" : "0");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// parse initialization memory settings
|
|
|
|
|
final String Xmx = sb.getConfig("javastart_Xmx", "Xmx500m").substring(3);
|
|
|
|
|
prop.put("Xmx", Xmx.substring(0, Xmx.length() - 1));
|
|
|
|
|
final String Xms = sb.getConfig("javastart_Xms", "Xms500m").substring(3);
|
|
|
|
|
prop.put("Xms", Xms.substring(0, Xms.length() - 1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final long diskFree = sb.getConfigLong(SwitchboardConstants.DISK_FREE, 3000L);
|
|
|
|
|
final long diskFreeHardlimit = sb.getConfigLong(SwitchboardConstants.DISK_FREE_HARDLIMIT, 1000L);
|
|
|
|
|
final long memoryAcceptDHT = sb.getConfigLong(SwitchboardConstants.MEMORY_ACCEPTDHT, 50000L);
|
|
|
|
@ -355,11 +355,11 @@ public class PerformanceQueues_p {
|
|
|
|
|
prop.put("diskFreeHardlimit", diskFreeHardlimit);
|
|
|
|
|
prop.put("memoryAcceptDHT", memoryAcceptDHT);
|
|
|
|
|
if(observerTrigger) prop.put("observerTrigger", "1");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return rewrite values for templates
|
|
|
|
|
return prop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String d(final String a, final String b) {
|
|
|
|
|
return (a == null) ? b : a;
|
|
|
|
|
}
|
|
|
|
|