2004-10-13 jrandom

* Fix the probabalistic tunnel reject (we always accepted everything,
      since the docs on java.util.Random.nextDouble() are wrong..)
    * Fixed a race on startup (thanks Quadn!)
This commit is contained in:
jrandom
2004-10-13 19:40:47 +00:00
committed by zzz
parent 2f0c3c7baf
commit d91ac7ef21
4 changed files with 37 additions and 10 deletions

View File

@ -1,4 +1,9 @@
$Id: history.txt,v 1.44 2004/10/10 14:33:09 jrandom Exp $
$Id: history.txt,v 1.45 2004/10/12 16:29:42 jrandom Exp $
2004-10-13 jrandom
* Fix the probabalistic tunnel reject (we always accepted everything,
since the docs on java.util.Random.nextDouble() are wrong..)
* Fixed a race on startup (thanks Quadn!)
2004-10-12 jrandom
* Disable the probabalistic drop by default (enable via the router config

View File

@ -133,12 +133,20 @@ class RouterThrottleImpl implements RouterThrottle {
if (numTunnels > getMinThrottleTunnels()) {
Rate avgTunnels = _context.statManager().getRate("tunnel.participatingTunnels").getRate(60*60*1000);
if (avgTunnels != null) {
double avg = avgTunnels.getAverageValue();
if (avg < numTunnels) {
double avg = 0;
if (avgTunnels.getLastEventCount() > 0)
avg = avgTunnels.getAverageValue();
else
avg = avgTunnels.getLifetimeAverageValue();
if ( (avg > 0) && (avg < numTunnels) ) {
// we're accelerating, lets try not to take on too much too fast
double probAccept = avg / numTunnels;
if (_context.random().nextDouble() < probAccept) {
int v = _context.random().nextInt(100);
if (v < probAccept*100) {
// ok
if (_log.shouldLog(Log.INFO))
_log.info("Probabalistically accept tunnel request (p=" + probAccept
+ " v=" + v + " avg=" + avg + " current=" + numTunnels + ")");
} else {
if (_log.shouldLog(Log.WARN))
_log.warn("Probabalistically refusing tunnel request (avg=" + avg
@ -146,18 +154,31 @@ class RouterThrottleImpl implements RouterThrottle {
_context.statManager().addRateData("router.throttleTunnelProbTooFast", (long)(numTunnels-avg), 0);
return false;
}
} else {
if (_log.shouldLog(Log.INFO))
_log.info("Accepting tunnel request, since the average is " + avg
+ " and we only have " + numTunnels + ")");
}
}
Rate tunnelTestTime10m = _context.statManager().getRate("tunnel.testSuccessTime").getRate(10*60*1000);
Rate tunnelTestTime60m = _context.statManager().getRate("tunnel.testSuccessTime").getRate(60*60*1000);
if ( (tunnelTestTime10m != null) && (tunnelTestTime60m != null) ) {
if ( (tunnelTestTime10m != null) && (tunnelTestTime60m != null) && (tunnelTestTime10m.getLastEventCount() > 0) ) {
double avg10m = tunnelTestTime10m.getAverageValue();
double avg60m = tunnelTestTime60m.getAverageValue();
if (avg10m > avg60m) {
double avg60m = 0;
if (tunnelTestTime60m.getLastEventCount() > 0)
avg60m = tunnelTestTime60m.getAverageValue();
else
avg60m = tunnelTestTime60m.getLifetimeAverageValue();
if ( (avg60m > 0) && (avg10m > avg60m) ) {
double probAccept = avg60m/avg10m;
if (_context.random().nextDouble() < probAccept) {
int v = _context.random().nextInt(100);
if (v < probAccept*100) {
// ok
if (_log.shouldLog(Log.INFO))
_log.info("Probabalistically accept tunnel request (p=" + probAccept
+ " v=" + v + " test time avg 10m=" + avg10m + " 60m=" + avg60m + ")");
} else {
if (_log.shouldLog(Log.WARN))
_log.warn("Probabalistically refusing tunnel request (test time avg 10m=" + avg10m

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.51 $ $Date: 2004/10/10 14:33:09 $";
public final static String ID = "$Revision: 1.52 $ $Date: 2004/10/12 16:29:42 $";
public final static String VERSION = "0.4.1.2";
public final static long BUILD = 1;
public final static long BUILD = 2;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -72,6 +72,7 @@ public class ClientManagerFacadeImpl extends ClientManagerFacade {
private static final long MAX_TIME_TO_REBUILD = 5*60*1000;
public boolean verifyClientLiveliness() {
if (_manager == null) return true;
boolean lively = true;
for (Iterator iter = _manager.getRunnerDestinations().iterator(); iter.hasNext(); ) {
Destination dest = (Destination)iter.next();