Author: toad
Date: 2007-03-23 13:26:54 +0000 (Fri, 23 Mar 2007)
New Revision: 12281
Modified:
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/NodeClientCore.java
trunk/freenet/src/freenet/node/NodeDispatcher.java
trunk/freenet/src/freenet/node/NodeStats.java
Log:
More fixes
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2007-03-22 20:47:32 UTC (rev
12280)
+++ trunk/freenet/src/freenet/node/Node.java 2007-03-23 13:26:54 UTC (rev
12281)
@@ -1291,7 +1291,7 @@
oldThrottle.delete();
}
- nodeStats = new NodeStats(this, sortOrder, nodeConfig,
oldThrottleFS, ibwLimit, ibwLimit);
+ nodeStats = new NodeStats(this, sortOrder, new
SubConfig("node.load", config), oldThrottleFS, ibwLimit, ibwLimit);
clientCore = new NodeClientCore(this, config, nodeConfig,
nodeDir, portNumber, sortOrder, oldThrottleFS == null ? null :
oldThrottleFS.subset("RequestStarters"));
@@ -1348,10 +1348,12 @@
if(!noSwaps)
lm.startSender(this, this.swapInterval);
+ dispatcher.start(nodeStats); // must be before usm
dnsr.start();
ps.start(nodeStats);
+ peers.start(); // must be before usm
+ nodeStats.start();
usm.start(disableHangCheckers);
- peers.start();
if(isUsingWrapper()) {
Logger.normal(this, "Using wrapper correctly:
"+nodeStarter);
Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java 2007-03-22 20:47:32 UTC
(rev 12280)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java 2007-03-23 13:26:54 UTC
(rev 12281)
@@ -1,7 +1,6 @@
package freenet.node;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
Modified: trunk/freenet/src/freenet/node/NodeDispatcher.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeDispatcher.java 2007-03-22 20:47:32 UTC
(rev 12280)
+++ trunk/freenet/src/freenet/node/NodeDispatcher.java 2007-03-23 13:26:54 UTC
(rev 12281)
@@ -38,7 +38,7 @@
private static boolean logMINOR;
final Node node;
- final NodeStats nodeStats;
+ private NodeStats nodeStats;
NodeDispatcher(Node node) {
this.node = node;
@@ -729,4 +729,8 @@
double nodeLoc = node.getLocation();
innerHandleProbeRequest(null, l, ll, d, (nodeLoc > d) ? nodeLoc
: 1.0, nodeLoc, node.maxHTL(), (short)0, false, false, cb);
}
-}
+
+ void start(NodeStats stats) {
+ this.nodeStats = stats;
+ }
+}
\ No newline at end of file
Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java 2007-03-22 20:47:32 UTC
(rev 12280)
+++ trunk/freenet/src/freenet/node/NodeStats.java 2007-03-23 13:26:54 UTC
(rev 12281)
@@ -1,13 +1,6 @@
package freenet.node;
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Comparator;
@@ -19,13 +12,11 @@
import freenet.io.comm.IOStatisticCollector;
import freenet.node.Node.NodeInitException;
import freenet.support.Logger;
-import freenet.support.OOMHandler;
import freenet.support.SimpleFieldSet;
import freenet.support.SizeUtil;
import freenet.support.TimeUtil;
import freenet.support.TokenBucket;
import freenet.support.api.IntCallback;
-import freenet.support.api.StringCallback;
import freenet.support.math.RunningAverage;
import freenet.support.math.TimeDecayingRunningAverage;
@@ -70,9 +61,6 @@
private boolean logMINOR;
- /** Memory Checker thread */
- private final Thread myMemoryChecker;
-
/** first time bwlimitDelay was over PeerManagerUserAlert threshold */
private long firstBwlimitDelayTimeThresholdBreak ;
/** first time nodeAveragePing was over PeerManagerUserAlert threshold
*/
@@ -152,12 +140,6 @@
this.rootThreadGroup = tg;
throttledPacketSendAverage =
new TimeDecayingRunningAverage(1, 10*60*1000 /* should
be significantly longer than a typical transfer */, 0, Long.MAX_VALUE);
- //Memory Checking thread
- // TODO: proper config. callbacks : maybe we shoudln't start
the thread at all if it's not worthy
- this.myMemoryChecker = new Thread(new MemoryChecker(), "Memory
checker");
- this.myMemoryChecker.setPriority(Thread.MAX_PRIORITY);
- this.myMemoryChecker.setDaemon(true);
-
nodePinger = new NodePinger(node);
previous_input_stat = 0;
@@ -183,7 +165,7 @@
threadLimit = statsConfig.getInt("threadLimit");
- persister = new ConfigurablePersister(this, statsConfig,
"throttleFile", "node-throttle.dat", sortOrder++, true, false,
+ persister = new ConfigurablePersister(this, statsConfig,
"nodeThrottleFile", "node-throttle.dat", sortOrder++, true, false,
"File to store node statistics in", "File to
store node statistics in (not client statistics, and these are used to decide
whether to accept requests so please don't delete)");
SimpleFieldSet throttleFS = persister.read();
@@ -220,8 +202,12 @@
public void start() throws NodeInitException {
nodePinger.start();
- myMemoryChecker.start();
persister.start();
+ //Memory Checking thread
+ // TODO: proper config. callbacks : maybe we shoudln't start
the thread at all if it's not worthy
+ Thread myMemoryChecker = new Thread(new MemoryChecker(),
"Memory checker");
+ myMemoryChecker.setPriority(Thread.MAX_PRIORITY);
+ myMemoryChecker.setDaemon(true);
}
private long lastAcceptedRequest = -1;
@@ -472,7 +458,7 @@
public void waitUntilNotOverloaded(boolean isInsert) {
while(threadLimit < getActiveThreadCount()){
try{
- wait(5000);
+ Thread.sleep(5000);
} catch (InterruptedException e) {}
}
}