* Stats: Add code to disable most stats to save memory.
Set on configstats.jsp or set stat.full=false to disable the stats. (true by default for now)
This commit is contained in:
@ -20,11 +20,13 @@ public class ConfigStatsHandler extends FormHandler {
|
||||
private String _graphs;
|
||||
private boolean _explicitFilter;
|
||||
private String _explicitFilterValue;
|
||||
private boolean _isFull;
|
||||
|
||||
public ConfigStatsHandler() {
|
||||
super();
|
||||
_stats = new ArrayList();
|
||||
_explicitFilter = false;
|
||||
_isFull = false;
|
||||
}
|
||||
|
||||
protected void processForm() {
|
||||
@ -70,6 +72,7 @@ public class ConfigStatsHandler extends FormHandler {
|
||||
|
||||
public void setExplicitFilter(String foo) { _explicitFilter = true; }
|
||||
public void setExplicitFilterValue(String filter) { _explicitFilterValue = filter; }
|
||||
public void setIsFull(String foo) { _isFull = true; }
|
||||
|
||||
/**
|
||||
* The user made changes to the config and wants to save them, so
|
||||
@ -109,6 +112,7 @@ public class ConfigStatsHandler extends FormHandler {
|
||||
|
||||
_context.router().setConfigSetting(StatManager.PROP_STAT_FILTER, stats.toString());
|
||||
_context.router().setConfigSetting("stat.summaries", _graphs);
|
||||
_context.router().setConfigSetting(StatManager.PROP_STAT_FULL, "" + _isFull);
|
||||
boolean ok = _context.router().saveConfig();
|
||||
if (ok)
|
||||
addFormNotice("Stat filter and location updated successfully to: " + stats.toString());
|
||||
|
@ -10,6 +10,7 @@ import java.util.StringTokenizer;
|
||||
import net.i2p.stat.Rate;
|
||||
import net.i2p.stat.RateStat;
|
||||
import net.i2p.stat.FrequencyStat;
|
||||
import net.i2p.stat.StatManager;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
@ -141,4 +142,10 @@ public class ConfigStatsHelper {
|
||||
public boolean getCurrentIsGraphed() { return _currentIsGraphed; }
|
||||
public boolean getCurrentCanBeGraphed() { return _currentCanBeGraphed; }
|
||||
public String getExplicitFilter() { return _filter; }
|
||||
public boolean getIsFull() {
|
||||
String f = _context.getProperty(StatManager.PROP_STAT_FULL);
|
||||
if (f != null && f.equals("true"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ function toggleAll(category)
|
||||
System.setProperty("net.i2p.router.web.ConfigStatsHandler.nonce", new java.util.Random().nextLong()+""); %>
|
||||
<input type="hidden" name="action" value="foo" />
|
||||
<input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigStatsHandler.nonce")%>" />
|
||||
Enable full stats?
|
||||
<input type="checkbox" name="isFull" value="true" <%
|
||||
if (statshelper.getIsFull()) { %>checked="true" <% } %>/>
|
||||
(change requires restart to take effect)<br />
|
||||
Stat file: <input type="text" name="filename" value="<%=statshelper.getFilename()%>" /><br />
|
||||
Filter: (<a href="javascript: void(null);" onclick="toggleAll('*')">toggle all</a>)<br />
|
||||
<table>
|
||||
|
@ -32,6 +32,22 @@ public class StatManager {
|
||||
public static final String PROP_STAT_FILTER = "stat.logFilters";
|
||||
public static final String PROP_STAT_FILE = "stat.logFile";
|
||||
public static final String DEFAULT_STAT_FILE = "stats.log";
|
||||
public static final String PROP_STAT_FULL = "stat.full";
|
||||
public static final String DEFAULT_STAT_FULL = "true";
|
||||
public static final String PROP_STAT_REQUIRED = "stat.required";
|
||||
/**
|
||||
* These are all the stats published in netDb, plus those required for the operation of
|
||||
* the router (many in RouterThrottleImpl), plus those that are on graphs.jsp by default.
|
||||
* Wildcard ('*') allowed at end of stat only.
|
||||
* Ignore all the rest of the stats unless stat.full=true.
|
||||
*/
|
||||
public static final String DEFAULT_STAT_REQUIRED =
|
||||
"bw.recvRate,bw.sendBps,bw.sendRate,client.sendAckTime,clock.skew,crypto.elGamal.encrypt," +
|
||||
"jobQueue.jobLag,netDb.successTime,router.fastPeers," +
|
||||
"transport.receiveMessageSize,transport.sendMessageSize,transport.sendProcessingTime," +
|
||||
"tunnel.buildRatio.*,tunnel.buildFailure,tunnel.buildSuccess,tunnel.corruptMessage," +
|
||||
"tunnel.decryptRequestTime,tunnel.fragmentedDropped,tunnel.participatingMessageCount,"+
|
||||
"tunnel.participatingTunnels,tunnel.testFailedTime,tunnel.testSuccessTime" ;
|
||||
|
||||
/**
|
||||
* The stat manager should only be constructed and accessed through the
|
||||
@ -67,6 +83,7 @@ public class StatManager {
|
||||
* @param periods array of period lengths (in milliseconds)
|
||||
*/
|
||||
public void createFrequencyStat(String name, String description, String group, long periods[]) {
|
||||
if (ignoreStat(name)) return;
|
||||
if (_frequencyStats.containsKey(name)) return;
|
||||
_frequencyStats.put(name, new FrequencyStat(name, description, group, periods));
|
||||
}
|
||||
@ -80,6 +97,7 @@ public class StatManager {
|
||||
* @param periods array of period lengths (in milliseconds)
|
||||
*/
|
||||
public void createRateStat(String name, String description, String group, long periods[]) {
|
||||
if (ignoreStat(name)) return;
|
||||
synchronized (_rateStats) {
|
||||
if (_rateStats.containsKey(name)) return;
|
||||
RateStat rs = new RateStat(name, description, group, periods);
|
||||
@ -165,4 +183,20 @@ public class StatManager {
|
||||
|
||||
public String getStatFilter() { return _context.getProperty(PROP_STAT_FILTER); }
|
||||
public String getStatFile() { return _context.getProperty(PROP_STAT_FILE, DEFAULT_STAT_FILE); }
|
||||
|
||||
// Save memory by not creating stats unless they are required for router operation
|
||||
// Return true if the stat should be ignored.
|
||||
public boolean ignoreStat(String statName) {
|
||||
if (_context.getProperty(PROP_STAT_FULL, DEFAULT_STAT_FULL).equalsIgnoreCase("true"))
|
||||
return false;
|
||||
String required = _context.getProperty(PROP_STAT_REQUIRED, DEFAULT_STAT_REQUIRED);
|
||||
String req[] = required.split(",");
|
||||
for (int i=0; i<req.length; i++) {
|
||||
if (req[i].equals(statName))
|
||||
return false;
|
||||
if (req[i].endsWith("*") && statName.startsWith(req[i].substring(0, req[i].length() - 2)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@
|
||||
for configuration instructions
|
||||
* i2psnark: Don't do a naming lookup for Base64 destkeys
|
||||
* i2psnark: Add a StartAll button
|
||||
* Stats: Add code to disable most stats to save memory.
|
||||
Set on configstats.jsp or set stat.full=false to disable the stats.
|
||||
(true by default for now)
|
||||
|
||||
2008-03-01 zzz
|
||||
* Fix netdb.knownLeaseSets count reported by floodfill routers
|
||||
|
@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
|
||||
public class RouterVersion {
|
||||
public final static String ID = "$Revision: 1.548 $ $Date: 2008-02-10 15:00:00 $";
|
||||
public final static String VERSION = "0.6.1.31";
|
||||
public final static long BUILD = 3201;
|
||||
public final static long BUILD = 3202;
|
||||
public static void main(String args[]) {
|
||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||
System.out.println("Router ID: " + RouterVersion.ID);
|
||||
|
Reference in New Issue
Block a user