}
}
final Map<String, String> defaultSettings = ((post == null) || (!(post.containsKey("submitdefault")))) ? null : FileUtils.loadMap(defaultSettingsFile);
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()) {
threadName = threads.next();
thread = sb.getThread(threadName);
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;
int queuesize;
threads = sb.threadNames();
int c = 0;
long idleCycles, busyCycles, memshortageCycles;
// set profile?
final double multiplier = (post != null) && post.containsKey("profileSpeed") ? 100.0 / post.getFloat("profileSpeed", 100.0f) : 1.0;
final boolean setProfile = (post != null && post.containsKey("submitdefault"));
final boolean setDelay = (post != null) && (post.containsKey("submitdelay"));
// save used settings file to config
if (setProfile && post != null){
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);
prop.putHTML("table_" + c + "_hasurl_shortdescr", thread.getShortDescription());
if(thread.getMonitorURL() == null) {
prop.put("table_"+c+"_hasurl", "0");
}else{
prop.put("table_"+c+"_hasurl", "1");
prop.put("table_" + c + "_hasurl_url", thread.getMonitorURL());
}
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();
memuse = thread.getMemoryUse();
idleCycles = thread.getIdleCycles();
busyCycles = thread.getBusyCycles();
memshortageCycles = thread.getOutOfMemoryCycles();
prop.putNum("table_" + c + "_blocktime", blocktime / 1000);
prop.putNum("table_" + c + "_blockpercent", 100 * blocktime / blocktime_total);
prop.putNum("table_" + c + "_sleeptime", sleeptime / 1000);
prop.putNum("table_" + c + "_sleeppercent", 100 * sleeptime / sleeptime_total);
prop.putNum("table_" + c + "_exectime", exectime / 1000);