Update of /cvsroot/freenet/freenet/src/freenet/node
In directory sc8-pr-cvs1:/tmp/cvs-serv3827/src/freenet/node
Modified Files:
Main.java Node.java
Log Message:
6189:
Don't open new connections just to send QueryRejected messages (at least not on
initial receipt of *Request), it's not worth it, there's only a 1 hop timeout on the
other end. Thanks to sanity and lostlogic for the so-obvious-it's-invisible solution.
Implement support in logger for selective logging.
Reduce multiplier for bandwidth limits to 1.2.
Add commented-out code for Linux-specific load estimation based on /proc/stat.
Logging
Index: Main.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/Main.java,v
retrieving revision 1.258
retrieving revision 1.259
diff -u -r1.258 -r1.259
--- Main.java 6 Sep 2003 19:28:10 -0000 1.258
+++ Main.java 10 Sep 2003 21:19:52 -0000 1.259
@@ -264,6 +264,8 @@
// set up runtime logging
int thresh = Logger.priorityOf(params.getString("logLevel"));
Core.logger.setThreshold(thresh);
+ String detailedLevels = params.getString("logLevelDetail");
+ Core.logger.setDetailedThresholds(detailedLevels);
String fname = params.getString("logFile");
String logFormat = params.getString("logFormat");
@@ -297,10 +299,10 @@
logDate,
thresh);
}
+ loggerHook.setDetailedThresholds(detailedLevels);
Core.logger.addHook(loggerHook);
Core.logStream = loggerHook.getStream();
- }
- catch (IOException e) {
+ } catch (IOException e) {
System.err.println("Opening log file failed!");
}
// Add a buffering hook for the last couple of entries as well
Index: Node.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/Node.java,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -r1.208 -r1.209
--- Node.java 4 Sep 2003 22:45:06 -0000 1.208
+++ Node.java 10 Sep 2003 21:19:52 -0000 1.209
@@ -144,15 +144,16 @@
config.addOption("routingTableImpl",1,"ng", 330);
// logging options
- config.addOption("logLevel", 1, "normal", 1250);
+ config.addOption("logLevel", 1, "normal", 1250);
config.addOption("logFile", 1, "freenet.log", 1251);
config.addOption("logFormat", 1, "d (c, t, p): m", 1252);
config.addOption("logDate", 1, "", 1253); // locale default
- config.addOption("logMaxLinesCached",1, 10000, 1254);
- config.addOption("logMaxBytesCached",1, "10M", 1255);
- config.addOption("logRotate", 1, false, 1256);
- config.addOption("logRotateUseNativeGzip",1,false,1257);
- config.addOption("logRotateInterval", 1, "hour", 1258);
+ config.addOption("logLevelDetail",1,"", 1254);
+ config.addOption("logMaxLinesCached",1, 10000, 1255);
+ config.addOption("logMaxBytesCached",1, "10M", 1256);
+ config.addOption("logRotate", 1, false, 1257);
+ config.addOption("logRotateUseNativeGzip",1,false,1258);
+ config.addOption("logRotateInterval", 1, "hour", 1259);
// diagnostics options
config.addOption("diagnosticsPath", 1, "stats", 501);
@@ -206,11 +207,13 @@
config.addOption("doOutLimitConnectCutoff",1,true,3258);
config.addOption("outLimitConnectCutoff",1,2.0F,3259);
config.addOption("lowLevelBWLimitFudgeFactor",1,3F/4F,3260);
- config.addOption("lowLevelBWLimitMultiplier",1,1.5F,3261);
+ config.addOption("lowLevelBWLimitMultiplier",1,1.2F,3261);
config.addOption("doLowLevelOutputLimiting",1,true,3262);
config.addOption("doLowLevelInputLimiting",1,true,3263);
- config.addOption("sendingQueueLength",1,256,3264);
- config.addOption("sendingQueueBytes",1,1492*8,3265);
+ // Commented out because of limited use and potential political problems i.e.
not cross platform
+// config.addOption("doCPULoad",1,false,3264);
+ config.addOption("sendingQueueLength",1,256,3265);
+ config.addOption("sendingQueueBytes",1,1492*8,3266);
config.addOption("defaultResetProbability",1, 0.05, 3557);
// WatchMe options.
@@ -704,6 +707,11 @@
" Debug: Report everything that can be reported"
);
+ // logLevelDetail
+ config.setExpert ("logLevelDetail", true);
+ config.argDesc ("logLevelDetail", "<list of class name or package name =
level e.g. freenet.node.rt:debug,freenet.support:minor>");
+ config.shortDesc ("logLevelDetail", "Detailed list of parts of freenet we want
different logging for");
+
// logFile
config.setExpert ("logFile", true);
config.argDesc ("logFile", "<filename>|NO");
@@ -1158,6 +1166,11 @@
config.argDesc ("lowLevelBWLimitMultiplier", "<floating point number over
0>");
config.longDesc ("lowLevelBWLimitMultiplier", "Freenet has 2 separate
bandwidth limiting mechanisms. The low level bandwidth limiter is more accurate, but
can cause bad things to happeen and is quite expensive in terms of CPU time, and works
by delaying messages, which may not be desirable. So by default limiting is done
mainly by the high level limiter (see outLimitCutoff and outLimitConnectCutoff), and
the low level limiter is set to a higher value to ensure that the node's usage does
not get completely out of control when something unusual happens. Set the factor to
multiply the bandwidth limits by before feeding them to the low level limiter here.");
+// // doCPULoad
+// config.setExpert ("doCPULoad", true);
+// config.argDesc ("doCPULoad", "<true|false>");
+// config.longDesc ("doCPULoad", "Whether to try to use the actual CPU usage
percentage in the load estimate calculation.");
+
// sendingQueueLength
config.setExpert ("sendingQueueLength", true);
config.argDesc ("sendingQueueLength", "<positive integer>");
@@ -1732,6 +1745,7 @@
static public boolean doOutLimitConnectCutoff;
static public float outLimitCutoff;
static public float outLimitConnectCutoff;
+// static public boolean doCPULoad;
static public int sendingQueueLength;
static public int sendingQueueBytes;
@@ -2059,6 +2073,7 @@
outLimitCutoff = params.getFloat("outLimitCutoff");
doOutLimitConnectCutoff = params.getBoolean("doOutLimitConnectCutoff");
outLimitConnectCutoff = params.getFloat("outLimitConnectCutoff");
+// doCPULoad = params.getBoolean("doCPULoad");
sendingQueueLength = params.getInt("sendingQueueLength");
sendingQueueBytes = params.getInt("sendingQueueBytes");
//System.err.println("This happens first.");
@@ -2378,6 +2393,78 @@
}
+// static class TickStat {
+// long user;
+// long nice;
+// long system;
+// long spare;
+
+// boolean read(File f) {
+// String firstline;
+// try {
+// FileInputStream fis = new FileInputStream(f);
+// ReadInputStream ris = new ReadInputStream(fis);
+// firstline = ris.readln();
+// ris.close();
+// } catch (IOException e) { return false; }
+// Core.logger.log(this, "Read first line: "+firstline,
+// Logger.DEBUG);
+// if(!firstline.startsWith("cpu")) return false;
+// long[] data = new long[4];
+// for(int i=0;i<4;i++) {
+// firstline = firstline.substring("cpu".length()).trim();
+// firstline = firstline + ' ';
+// int x = firstline.indexOf(' ');
+// if(x == -1) return false;
+// String firstbit = firstline.substring(0, x);
+// try {
+// data[i] = Long.parseLong(firstbit);
+// } catch (NumberFormatException e) {
+// return false;
+// }
+// firstline = firstline.substring(x);
+// }
+// user = data[0];
+// nice = data[1];
+// system = data[2];
+// spare = data[3];
+// Core.logger.log(this, "Read from file: user "+user+" nice "+nice+
+// " system "+system+" spare "+spare, Logger.DEBUG);
+// return true;
+// }
+
+// int calculate(TickStat old) {
+// long userdiff = user - old.user;
+// long nicediff = nice - old.nice;
+// long systemdiff = system - old.system;
+// long sparediff = spare - old.spare;
+
+// if(userdiff + nicediff + systemdiff + sparediff <= 0) return 0;
+// Core.logger.log(this, "User changed by "+userdiff+", Nice: "+nicediff+
+// ", System: "+systemdiff+", Spare: "+sparediff,
+// Logger.DEBUG);
+// int usage = (int)((100 * (userdiff + nicediff + systemdiff)) /
+// (userdiff + nicediff + systemdiff + sparediff));
+// Core.logger.log(this, "CPU usage: "+usage, Logger.DEBUG);
+// return usage;
+// }
+
+// void copyFrom(TickStat old) {
+// user = old.user;
+// nice = old.nice;
+// system = old.system;
+// spare = old.spare;
+// }
+// }
+
+// int lastCPULoadEstimate = 0;
+// long lastCPULoadEstimateTime = 0;
+
+// File proc = File.separator.equals("/") ?
+// new File("/proc/stat") : null;
+// TickStat tsOld = new TickStat();
+// TickStat tsNew = null;
+
/**
* This is a rough estimate based on the number of running
* jobs. Hopefully we can come up with a better metric later.
@@ -2420,10 +2507,35 @@
if (ret > 1.0f) {
return 1.0f;
}
-
+
+ long now = System.currentTimeMillis();
+// if(doCPULoad && File.separator.equals("/")) {
+// if(now - lastCPULoadEstimateTime > 1000) {
+// try {
+// lastCPULoadEstimateTime = now;
+// if(tsNew == null) {
+// tsOld.read(proc);
+// tsNew = new TickStat();
+// } else {
+// if(!tsNew.read(proc)) {
+// Core.logger.log(this, "Failed to parse /proc",
Logger.MINOR);
+// }
+// lastCPULoadEstimate = tsNew.calculate(tsOld);
+// tsOld.copyFrom(tsNew);
+// }
+// } catch (Throwable t) {
+// lastCPULoadEstimate = 0;
+// Core.logger.log(this, "Failed real-CPU-load estimation: "+t, t,
+// Logger.NORMAL);
+// }
+// }
+// }
+// float f = ((float)lastCPULoadEstimate)/100.0F;
+// if(f > ret) ret = f;
+
return (float)ret;
}
-
+
/**
* Hook for rate limiting.
*/
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs