01: // /xml.queues/status_p.java
02: // -------------------------------
03: // part of the yacy
04: //
05: // (C) 2006 Alexander Schier
06: // last major change: 03.11.2006
07: //
08: // This program is free software; you can redistribute it and/or modify
09: // it under the terms of the GNU General Public License as published by
10: // the Free Software Foundation; either version 2 of the License, or
11: // (at your option) any later version.
12: //
13: // This program is distributed in the hope that it will be useful,
14: // but WITHOUT ANY WARRANTY; without even the implied warranty of
15: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: // GNU General Public License for more details.
17: //
18: // You should have received a copy of the GNU General Public License
19: // along with this program; if not, write to the Free Software Foundation, Inc.,
20: // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21: //
22: // Using this software in any meaning (reading, learning, copying, compiling,
23: // running) means that you agree that the Author(s) is (are) not responsible
24: // for cost, loss of data or any harm that may be caused directly or indirectly
25: // by usage of this softare or this documentation. The usage of this software
26: // is on your own risk. The installation and usage (starting/running) of this
27: // software may allow other people or application to access your computer and
28: // any attached devices and is highly dependent on the configuration of the
29: // software which must be done by the user of the software; the author(s) is
30: // (are) also not responsible for proper configuration and usage of the
31: // software, even if provoked by documentation provided together with
32: // the software.
33: //
34: // Any changes to this file according to the GPL as documented in the file
35: // gpl.txt aside this file in the shipment you received can be done to the
36: // lines that follows this copyright notice here, but changes must not be
37: // done inside the copyright notive above. A re-distribution must contain
38: // the intact and unchanged copyright notice.
39: // Contributions and changes to the program code must be marked as such.
40:
41: package xml;
42:
43: import de.anomic.http.httpHeader;
44: import de.anomic.http.httpdByteCountInputStream;
45: import de.anomic.http.httpdByteCountOutputStream;
46: import de.anomic.plasma.plasmaSwitchboard;
47: import de.anomic.server.serverObjects;
48: import de.anomic.server.serverSwitch;
49: import de.anomic.yacy.yacyCore;
50:
51: public class status_p {
52:
53: public static serverObjects respond(httpHeader header,
54: serverObjects post, serverSwitch env) {
55: // return variable that accumulates replacements
56: plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
57: serverObjects prop = new serverObjects();
58: if (post == null || !post.containsKey("html"))
59: prop.setLocalized(false);
60: prop.put("rejected", "0");
61: yacyCore.peerActions.updateMySeed();
62: final int cacheOutSize = switchboard.wordIndex
63: .dhtOutCacheSize();
64: final long cacheMaxSize = switchboard.getConfigLong(
65: plasmaSwitchboard.WORDCACHE_MAX_COUNT, 10000);
66: prop.putNum("ppm", yacyCore.seedDB.mySeed().getPPM());
67: prop.putNum("qpm", yacyCore.seedDB.mySeed().getQPM());
68: prop.putNum("wordCacheSize", switchboard.wordIndex
69: .dhtOutCacheSize()
70: + switchboard.wordIndex.dhtInCacheSize());
71: prop.putNum("wordCacheWSize", cacheOutSize);
72: prop.putNum("wordCacheKSize", switchboard.wordIndex
73: .dhtInCacheSize());
74: prop.putNum("wordCacheMaxSize", cacheMaxSize);
75: prop.put("wordCacheWCount", cacheOutSize);
76: prop.put("wordCacheMaxCount", cacheMaxSize);
77:
78: //
79: // memory usage and system attributes
80: final Runtime rt = Runtime.getRuntime();
81: prop.putNum("freeMemory", rt.freeMemory());
82: prop.putNum("totalMemory", rt.totalMemory());
83: prop.putNum("maxMemory", rt.maxMemory());
84: prop.putNum("processors", rt.availableProcessors());
85:
86: // proxy traffic
87: prop.put("trafficIn", httpdByteCountInputStream
88: .getGlobalCount());
89: prop.put("trafficProxy", httpdByteCountOutputStream
90: .getAccountCount("PROXY"));
91: prop.put("trafficCrawler", httpdByteCountInputStream
92: .getAccountCount("CRAWLER"));
93:
94: // return rewrite properties
95: return prop;
96: }
97:
98: }
|