2006-02-06 20:47:59 +01:00
|
|
|
|
2008-08-25 20:11:47 +02:00
|
|
|
|
2010-08-23 14:32:02 +02:00
|
|
|
import net.yacy.cora.protocol.RequestHeader;
|
2010-09-11 17:58:15 +02:00
|
|
|
import net.yacy.kelondro.io.ByteCount;
|
|
|
|
//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;
|
|
|
|
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;
|
2010-04-27 23:47:41 +02:00
|
|
|
boolean html = post != null && post.containsKey("html");
|
|
|
|
prop.setLocalized(html);
|
|
|
|
if (post != null && post.containsKey("segment") && sb.verifyAuthentication(header, false)) {
|
|
|
|
segment = sb.indexSegments.segment(post.get("segment"));
|
2009-10-09 16:44:20 +02:00
|
|
|
}
|
|
|
|
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());
|
2010-04-27 23:47:41 +02:00
|
|
|
prop.putNum("wordCacheSize", segment.termIndex().getBufferSize());
|
|
|
|
prop.putNum("wordCacheMaxSize", cacheMaxSize);
|
|
|
|
|
|
|
|
// crawl queues
|
|
|
|
prop.putNum("localCrawlSize", sb.getThread(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL).getJobCount());
|
|
|
|
prop.putNum("limitCrawlSize", sb.crawlQueues.limitCrawlJobSize());
|
|
|
|
prop.putNum("remoteCrawlSize", sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount());
|
|
|
|
prop.putNum("loaderSize", sb.crawlQueues.workerSize());
|
|
|
|
prop.putNum("loaderMax", sb.getConfigLong(SwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, 10));
|
|
|
|
|
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());
|
2011-07-19 14:48:50 +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
|
2010-09-11 17:58:15 +02:00
|
|
|
prop.put("trafficIn", ByteCount.getGlobalCount());
|
|
|
|
prop.put("trafficProxy", ByteCount.getAccountCount(ByteCount.PROXY));
|
|
|
|
prop.put("trafficCrawler", ByteCount.getAccountCount(ByteCount.CRAWLER));
|
2006-11-03 20:44:31 +01:00
|
|
|
|
2006-02-06 20:47:59 +01:00
|
|
|
// return rewrite properties
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|