2006-02-06 20:47:59 +01:00
|
|
|
|
2008-08-25 20:11:47 +02:00
|
|
|
|
2009-10-11 23:29:18 +02:00
|
|
|
import net.yacy.kelondro.io.ByteCountInputStream;
|
|
|
|
import net.yacy.kelondro.io.ByteCountOutputStream;
|
2009-10-10 03:14:19 +02:00
|
|
|
import net.yacy.kelondro.util.MemoryControl;
|
2009-10-11 02:12:19 +02:00
|
|
|
import net.yacy.kelondro.workflow.WorkflowProcessor;
|
2009-10-11 23:29:18 +02:00
|
|
|
import de.anomic.http.server.RequestHeader;
|
2009-10-11 02:12:19 +02:00
|
|
|
import de.anomic.search.Segment;
|
|
|
|
import de.anomic.search.Segments;
|
2009-07-19 22:37:44 +02:00
|
|
|
import de.anomic.search.Switchboard;
|
|
|
|
import de.anomic.search.SwitchboardConstants;
|
2006-02-06 20:47:59 +01:00
|
|
|
import de.anomic.server.serverObjects;
|
|
|
|
import de.anomic.server.serverSwitch;
|
|
|
|
|
|
|
|
public class status_p {
|
|
|
|
|
|
|
|
|
2009-07-19 22:37:44 +02:00
|
|
|
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
2006-02-06 20:47:59 +01:00
|
|
|
// return variable that accumulates replacements
|
2009-07-19 22:37:44 +02:00
|
|
|
final Switchboard sb = (Switchboard) env;
|
2008-08-02 14:12:04 +02:00
|
|
|
final serverObjects prop = new serverObjects();
|
2009-10-09 16:44:20 +02:00
|
|
|
Segment segment = null;
|
|
|
|
if (post == null || !post.containsKey("html")) {
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.setLocalized(false);
|
2009-10-09 16:44:20 +02:00
|
|
|
if (post.containsKey("segment") && sb.verifyAuthentication(header, false)) {
|
|
|
|
segment = sb.indexSegments.segment(post.get("segment"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (segment == null) segment = sb.indexSegments.segment(Segments.Process.PUBLIC);
|
|
|
|
|
2007-10-24 23:38:19 +02:00
|
|
|
prop.put("rejected", "0");
|
2008-06-04 23:34:57 +02:00
|
|
|
sb.updateMySeed();
|
2009-07-19 22:37:44 +02:00
|
|
|
final int cacheMaxSize = (int) sb.getConfigLong(SwitchboardConstants.WORDCACHE_MAX_COUNT, 10000);
|
2008-08-04 12:47:26 +02:00
|
|
|
prop.putNum("ppm", sb.currentPPM());
|
2009-05-28 16:26:05 +02:00
|
|
|
prop.putNum("qpm", sb.peers.mySeed().getQPM());
|
2009-10-09 16:44:20 +02:00
|
|
|
prop.put("wordCacheSize", Integer.toString(segment.termIndex().getBufferSize()));
|
2009-03-18 22:25:52 +01:00
|
|
|
prop.put("wordCacheMaxSize", Integer.toString(cacheMaxSize));
|
2006-11-03 20:44:31 +01:00
|
|
|
//
|
|
|
|
// memory usage and system attributes
|
2009-01-30 16:33:00 +01:00
|
|
|
prop.putNum("freeMemory", MemoryControl.free());
|
|
|
|
prop.putNum("totalMemory", MemoryControl.total());
|
2009-04-17 00:45:39 +02:00
|
|
|
prop.putNum("maxMemory", MemoryControl.maxMemory);
|
2009-10-11 02:12:19 +02:00
|
|
|
prop.putNum("processors", WorkflowProcessor.availableCPU);
|
2006-11-03 20:44:31 +01:00
|
|
|
|
|
|
|
// proxy traffic
|
2009-07-19 22:37:44 +02:00
|
|
|
prop.put("trafficIn", ByteCountInputStream.getGlobalCount());
|
|
|
|
prop.put("trafficProxy", ByteCountOutputStream.getAccountCount("PROXY"));
|
|
|
|
prop.put("trafficCrawler", ByteCountInputStream.getAccountCount("CRAWLER"));
|
2006-11-03 20:44:31 +01:00
|
|
|
|
2006-02-06 20:47:59 +01:00
|
|
|
// return rewrite properties
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|