yacy_search_server/htroot/PerformanceConcurrency_p.java
orbiter 1d8d51075c refactoring:
- removed the plasma package. The name of that package came from a very early pre-version of YaCy, even before YaCy was named AnomicHTTPProxy. The Proxy project introduced search for cache contents using class files that had been developed during the plasma project. Information from 2002 about plasma can be found here:
http://web.archive.org/web/20020802110827/http://anomic.de/AnomicPlasma/index.html
We stil have one class that comes mostly unchanged from the plasma project, the Condenser class. But this is now part of the document package and all other classes in the plasma package can be assigned to other packages.
- cleaned up the http package: better structure of that class and clean isolation of server and client classes. The old HTCache becomes part of the client sub-package of http.
- because the plasmaSwitchboard is now part of the search package all servlets had to be touched to declare a different package source.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6232 6c8d7289-2bf4-0310-a012-ef5d649a1542
2009-07-19 20:37:44 +00:00

94 lines
4.2 KiB
Java

// PerformanceConcurrency_p.java
// -----------------------
// part of YaCy
// (C) by Michael Peter Christen; mc@yacy.net
// first published on http:// www.yacy.net
// Frankfurt, Germany, 19.12.2008
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import java.util.Iterator;
import de.anomic.http.metadata.RequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverProcessor;
import de.anomic.server.serverSwitch;
public class PerformanceConcurrency_p {
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch sb) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
// calculate totals
long blocktime_total = 0, exectime_total = 0, passontime_total = 0;
Iterator<serverProcessor<?>> threads = serverProcessor.processes();
serverProcessor<?> p;
while (threads.hasNext()) {
p = threads.next();
blocktime_total += p.getBlockTime();
exectime_total += p.getExecTime();
passontime_total += p.getPassOnTime();
}
if (blocktime_total == 0) blocktime_total = 1;
if (exectime_total == 0) exectime_total = 1;
if (passontime_total == 0) passontime_total = 1;
// set templates for latest news from the threads
long blocktime, exectime, passontime;
threads = serverProcessor.processes();
int c = 0;
long cycles;
while (threads.hasNext()) {
p = threads.next();
cycles = p.getExecCount();
if (cycles == 0) cycles = 1; // avoid division by zero
// set values to templates
prop.put("table_" + c + "_threadname", p.getName());
prop.putHTML("table_" + c + "_longdescr", p.getDescription());
prop.put("table_" + c + "_queuesize", p.queueSize());
prop.put("table_" + c + "_queuesizemax", p.queueSizeMax());
prop.put("table_" + c + "_concurrency", p.concurrency());
prop.putHTML("table_" + c + "_childs", p.getChilds());
blocktime = p.getBlockTime();
exectime = p.getExecTime();
passontime = p.getPassOnTime();
prop.putNum("table_" + c + "_blockreadtime", blocktime / cycles);
prop.putNum("table_" + c + "_blockreadpercent", 100 * blocktime / blocktime_total);
prop.putNum("table_" + c + "_exectime", exectime / cycles);
prop.putNum("table_" + c + "_execpercent", 100 * exectime / exectime_total);
prop.putNum("table_" + c + "_blockwritetime", passontime / cycles);
prop.putNum("table_" + c + "_blockwritepercent", 100 * passontime / passontime_total);
prop.putNum("table_" + c + "_totalcycles", p.getExecCount());
// set a color for the line to show problems
boolean problem = false;
boolean warning = false;
if (p.queueSize() == p.queueSizeMax()) problem = true;
if (p.queueSize() > p.queueSizeMax() * 8 / 10) warning = true;
if (100 * blocktime / blocktime_total > 80) warning = true;
if (100 * exectime / exectime_total > 80) warning = true;
if (100 * passontime / passontime_total > 80) warning = true;
prop.put("table_" + c + "_class", (!warning && !problem) ? 0 : (!problem) ? 1 : 2);
c++;
}
prop.put("table", c);
// return rewrite values for templates
return prop;
}
}