2004-12-15 jrandom

* Handle hard disconnects more gracefully within the streaming lib, and
      log unmonitored events more aggressively.
    * If we drop a peer after connection due to clock skew, log it to the
      /logs.jsp#connectionlogs with relevent info.  In addition, toss it in
      the stat 'tcp.disconnectAfterSkew'.
    * Fixed the formatting in the skew display
    * Added an ERROR message that is fired once after we run out of
      routerInfo files (thanks susi!)
    * Set the connect timeout equal to the streaming lib's disconnect timeout
      if not already specified (the I2PTunnel httpclient already enforces a
      60s connect timeout)
    * Fix for another connection startup problem in the streaming lib.
    * Fix for a stupid error in the probabalistic drop (rand <= P, not > P)
    * Adjust the capacity calculations so that tunnel failures alone in the
      last 10m will not trigger a 0 capacity rank.
This commit is contained in:
jrandom
2004-12-16 02:45:55 +00:00
committed by zzz
parent 5c72aca5ee
commit 66aa29e3d4
17 changed files with 164 additions and 22 deletions

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.111 $ $Date: 2004/12/14 06:54:39 $";
public final static String ID = "$Revision: 1.112 $ $Date: 2004/12/14 11:42:35 $";
public final static String VERSION = "0.4.2.3";
public final static long BUILD = 5;
public final static long BUILD = 6;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -103,6 +103,7 @@ public class StatisticsManager implements Service {
includeThroughput(stats);
includeRate("transport.sendProcessingTime", stats, new long[] { 60*60*1000 });
includeRate("tcp.probabalisticDropQueueSize", stats, new long[] { 60*1000l, 60*60*1000l });
//includeRate("tcp.queueSize", stats);
//includeRate("jobQueue.jobLag", stats, new long[] { 60*1000, 60*60*1000 });
//includeRate("jobQueue.jobRun", stats, new long[] { 60*1000, 60*60*1000 });

View File

@ -147,8 +147,10 @@ class PersistentDataStore extends TransientDataStore {
}
private class ReadJob extends JobImpl {
private boolean _alreadyWarned;
public ReadJob() {
super(PersistentDataStore.this._context);
_alreadyWarned = false;
}
public String getName() { return "DB Read Job"; }
public void runJob() {
@ -158,6 +160,7 @@ class PersistentDataStore extends TransientDataStore {
}
private void readFiles() {
int routerCount = 0;
try {
File dbDir = getDbDir();
File leaseSetFiles[] = dbDir.listFiles(LeaseSetFilter.getInstance());
@ -170,6 +173,9 @@ class PersistentDataStore extends TransientDataStore {
}
File routerInfoFiles[] = dbDir.listFiles(RouterInfoFilter.getInstance());
if (routerInfoFiles != null) {
routerCount += routerInfoFiles.length;
if (routerInfoFiles.length > 5)
_alreadyWarned = false;
for (int i = 0; i < routerInfoFiles.length; i++) {
Hash key = getRouterInfoHash(routerInfoFiles[i].getName());
if ( (key != null) && (!isKnown(key)) )
@ -179,6 +185,11 @@ class PersistentDataStore extends TransientDataStore {
} catch (IOException ioe) {
_log.error("Error reading files in the db dir", ioe);
}
if ( (routerCount <= 5) && (!_alreadyWarned) ) {
_log.error("Very few routerInfo files remaining - please reseed");
_alreadyWarned = true;
}
}
}

View File

@ -107,10 +107,11 @@ public class CapacityCalculator extends Calculator {
} else
val -= stretch * (curRejected.getCurrentEventCount() + curRejected.getLastEventCount());
val += GROWTH_FACTOR;
if (val >= 0) {
return (val + GROWTH_FACTOR);
return val;
} else {
// failed too much, don't grow
return 0.0d;
}
}

View File

@ -364,5 +364,5 @@ public abstract class TransportImpl implements Transport {
/** Make this stuff pretty (only used in the old console) */
public String renderStatusHTML() { return null; }
protected RouterContext getContext() { return _context; }
public RouterContext getContext() { return _context; }
}

View File

@ -440,7 +440,7 @@ public class ConnectionHandler {
} else if ( (clockSkew > Router.CLOCK_FUDGE_FACTOR)
|| (clockSkew < 0 - Router.CLOCK_FUDGE_FACTOR) ) {
status = STATUS_SKEWED;
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddhhmmssSSS");
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmssSSS");
props.setProperty("SKEW", fmt.format(new Date(_context.clock().now())));
} else {
try {
@ -603,7 +603,7 @@ public class ConnectionHandler {
} else if ( (clockSkew > Router.CLOCK_FUDGE_FACTOR)
|| (clockSkew < 0 - Router.CLOCK_FUDGE_FACTOR) ) {
status = STATUS_SKEWED;
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddhhmmssSSS");
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmssSSS");
props.setProperty("SKEW", fmt.format(new Date(_context.clock().now())));
} else if (!sigOk) {
status = STATUS_SIGNATURE_FAILED;

View File

@ -25,7 +25,8 @@ public class MessageHandler implements I2NPMessageReader.I2NPMessageEventListene
_con = con;
_ident = con.getRemoteRouterIdentity();
_identHash = _ident.calculateHash();
_log = con.getRouterContext().logManager().getLog(MessageHandler.class);
_log = con.getRouterContext().logManager().getLog(MessageHandler.class);
transport.getContext().statManager().createRateStat("tcp.disconnectAfterSkew", "How skewed a connection became before we killed it?", "TCP", new long[] { 10*60*1000l, 60*60*1000l, 24*60*60*1000l } );
}
public void disconnected(I2NPMessageReader reader) {
@ -52,15 +53,20 @@ public class MessageHandler implements I2NPMessageReader.I2NPMessageEventListene
private void timeMessageReceived(long remoteTime) {
long delta = _con.getRouterContext().clock().now() - remoteTime;
if ( (delta > Router.CLOCK_FUDGE_FACTOR) || (delta < 0 - Router.CLOCK_FUDGE_FACTOR) ) {
_log.error("Peer " + _identHash.toBase64().substring(0,6) + " is too far skewed ("
+ DataHelper.formatDuration(delta) + ") after uptime of "
+ DataHelper.formatDuration(_con.getLifetime()) );
_con.closeConnection();
_transport.addConnectionErrorMessage("Peer " + _identHash.toBase64().substring(0,6)
+ " is too far skewed ("
+ DataHelper.formatDuration(delta) + ") after uptime of "
+ DataHelper.formatDuration(_con.getLifetime()));
_transport.getContext().statManager().addRateData("tcp.disconnectAfterSkew", delta, _con.getLifetime());
} else {
if (_log.shouldLog(Log.INFO))
_log.info("Peer " + _identHash.toBase64().substring(0,6) + " is only skewed by ("
+ DataHelper.formatDuration(delta) + ") after uptime of "
+ DataHelper.formatDuration(_con.getLifetime()) );
int level = Log.DEBUG;
if ( (delta > Router.CLOCK_FUDGE_FACTOR/2) || (delta < 0 - Router.CLOCK_FUDGE_FACTOR/2) )
level = Log.WARN;
if (_log.shouldLog(level))
_log.log(level, "Peer " + _identHash.toBase64().substring(0,6) + " is only skewed by ("
+ DataHelper.formatDuration(delta) + ") after uptime of "
+ DataHelper.formatDuration(_con.getLifetime()) );
}
}

View File

@ -268,7 +268,7 @@ public class TCPConnection {
for (int i = 0; i < _pendingMessages.size() && excessBytesQueued > 0; i++) {
OutNetMessage msg = (OutNetMessage)_pendingMessages.get(i);
int p = getDropProbability(msg.getMessageSize(), excessBytesQueued);
if (_context.random().nextInt(100) > p) {
if (_context.random().nextInt(100) < p) {
_pendingMessages.remove(i);
i--;
msg.timestamp("Probabalistically dropped due to queue size " + excessBytesQueued);