On Tuesday 03 February 2009 11:36:01 [email protected] wrote: > Author: nextgens > Date: 2009-02-03 11:36:00 +0000 (Tue, 03 Feb 2009) > New Revision: 25484 > > Modified: > trunk/freenet/src/freenet/node/NodePinger.java > Log: > Improve NodePinger: > > -take care of synchronization > -requeue before we do anything so that we are closer to a 200ms period > -logging optimizations > > Modified: trunk/freenet/src/freenet/node/NodePinger.java > =================================================================== > --- trunk/freenet/src/freenet/node/NodePinger.java 2009-02-03 10:14:23 UTC (rev 25483) > +++ trunk/freenet/src/freenet/node/NodePinger.java 2009-02-03 11:36:00 UTC (rev 25484) > @@ -6,15 +6,28 @@ > import java.util.Arrays; > > import freenet.support.Logger; > +import freenet.support.LogThresholdCallback; > > /** > * Track average round-trip time for each peer node, get a geometric mean. > */ > public class NodePinger implements Runnable { > + private static volatile boolean logMINOR; > > - private double meanPing = 0; > + static { > + Logger.registerLogThresholdCallback(new LogThresholdCallback() { > + > + @Override > + public void shouldUpdate() { > + logMINOR = Logger.shouldLog(Logger.MINOR, this); > + } > + }); > + } > + > + private final Node node; > + private volatile double meanPing = 0; > > - static final double CRAZY_MAX_PING_TIME = 365.25*24*60*60*1000; > + public static final double CRAZY_MAX_PING_TIME = 365.25*24*60*60*1000; > > NodePinger(Node n) { > this.node = n; > @@ -24,35 +37,34 @@ > run(); > } > > - final Node node; > - > public void run() { > - //freenet.support.OSThread.RealOSThread.logPID(this); > - try { > - recalculateMean(node.peers.connectedPeers); > - } finally { > - node.ps.queueTimedJob(this, 200); > - } > + // Requeue *before* so that it's accurate in any case > + node.ps.queueTimedJob(this, 200);
Is this really a good idea? If there is heavy load, you could end up with hundreds of these jobs running in parallel?
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Devl mailing list [email protected] http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
