diff --git a/core/java/src/net/i2p/stat/BufferedStatLog.java b/core/java/src/net/i2p/stat/BufferedStatLog.java index fa131b9a3..e81f45b3d 100644 --- a/core/java/src/net/i2p/stat/BufferedStatLog.java +++ b/core/java/src/net/i2p/stat/BufferedStatLog.java @@ -68,7 +68,7 @@ public class BufferedStatLog implements StatLog { private boolean shouldLog(String stat) { synchronized (_statFilters) { - return _statFilters.contains(stat); + return _statFilters.contains(stat) || _statFilters.contains("*"); } } diff --git a/history.txt b/history.txt index 72a911412..3bc86964d 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,9 @@ -$Id: history.txt,v 1.30 2004/10/02 14:05:24 jrandom Exp $ +$Id: history.txt,v 1.31 2004/10/03 15:48:43 jrandom Exp $ + +2004-10-04 jrandom + * Update the shitlist to reject a peer for an exponentially increasing + period of time (with an upper bounds of an hour). + * Various minor stat and debugging fixes 2004-10-03 jrandom * Add a new stat logging component to optionally dump the raw stats to diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 6142682cb..4babaae5a 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.40 $ $Date: 2004/10/02 14:05:24 $"; + public final static String ID = "$Revision: 1.41 $ $Date: 2004/10/03 15:48:43 $"; public final static String VERSION = "0.4.1.1"; - public final static long BUILD = 6; + public final static long BUILD = 7; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION); System.out.println("Router ID: " + RouterVersion.ID); diff --git a/router/java/src/net/i2p/router/Shitlist.java b/router/java/src/net/i2p/router/Shitlist.java index f3cc0e1de..a33bb51e7 100644 --- a/router/java/src/net/i2p/router/Shitlist.java +++ b/router/java/src/net/i2p/router/Shitlist.java @@ -16,6 +16,7 @@ import java.util.Iterator; import java.util.Map; import net.i2p.data.Hash; +import net.i2p.router.peermanager.PeerProfile; import net.i2p.util.Log; /** @@ -62,8 +63,16 @@ public class Shitlist { if (_log.shouldLog(Log.INFO)) _log.info("Shitlisting router " + peer.toBase64(), new Exception("Shitlist cause")); + long period = SHITLIST_DURATION_MS; + PeerProfile prof = _context.profileOrganizer().getProfile(peer); + if (prof != null) + period = SHITLIST_DURATION_MS << prof.incrementShitlists(); + + if (period > 60*60*1000) + period = 60*60*1000; + synchronized (_shitlist) { - Date oldDate = (Date)_shitlist.put(peer, new Date(_context.clock().now())); + Date oldDate = (Date)_shitlist.put(peer, new Date(_context.clock().now() + period)); wasAlready = (null == oldDate); if (reason != null) { _shitlistCause.put(peer, reason); @@ -85,6 +94,9 @@ public class Shitlist { _shitlist.remove(peer); _shitlistCause.remove(peer); } + PeerProfile prof = _context.profileOrganizer().getProfile(peer); + if (prof != null) + prof.unshitlist(); } public boolean isShitlisted(Hash peer) { @@ -95,7 +107,7 @@ public class Shitlist { if (shitlistDate == null) return false; // check validity - if (shitlistDate.getTime() > _context.clock().now() - SHITLIST_DURATION_MS) { + if (shitlistDate.getTime() > _context.clock().now()) { return true; } else { unshitlistRouter(peer); @@ -115,7 +127,7 @@ public class Shitlist { shitlist = new HashMap(_shitlist); } - long limit = _context.clock().now() - SHITLIST_DURATION_MS; + long limit = _context.clock().now(); for (Iterator iter = shitlist.keySet().iterator(); iter.hasNext(); ) { Hash key = (Hash)iter.next(); @@ -146,7 +158,7 @@ public class Shitlist { Date shitDate = (Date)shitlist.get(key); buf.append("
  • ").append(key.toBase64()).append(""); buf.append(" (?)"); - buf.append(" was shitlisted on "); + buf.append(" expiring on "); buf.append(shitDate); String cause = (String)causes.get(key); if (cause != null) { diff --git a/router/java/src/net/i2p/router/peermanager/PeerProfile.java b/router/java/src/net/i2p/router/peermanager/PeerProfile.java index 3af9c3514..3723bb3e8 100644 --- a/router/java/src/net/i2p/router/peermanager/PeerProfile.java +++ b/router/java/src/net/i2p/router/peermanager/PeerProfile.java @@ -44,6 +44,7 @@ public class PeerProfile { private DBHistory _dbHistory; // does this peer profile contain expanded data, or just the basics? private boolean _expanded; + private int _consecutiveShitlists; public PeerProfile(RouterContext context, Hash peer) { this(context, peer, true); @@ -57,6 +58,7 @@ public class PeerProfile { _capacityValue = 0; _integrationValue = 0; _isFailing = false; + _consecutiveShitlists = 0; _peer = peer; if (expand) expandProfile(); @@ -74,6 +76,9 @@ public class PeerProfile { */ public boolean getIsExpanded() { return _expanded; } + public int incrementShitlists() { return _consecutiveShitlists++; } + public void unshitlist() { _consecutiveShitlists = 0; } + /** * Is this peer active at the moment (sending/receiving messages within the last * 5 minutes) diff --git a/router/java/src/net/i2p/router/transport/TransportImpl.java b/router/java/src/net/i2p/router/transport/TransportImpl.java index 04383adbc..0b2fe2603 100644 --- a/router/java/src/net/i2p/router/transport/TransportImpl.java +++ b/router/java/src/net/i2p/router/transport/TransportImpl.java @@ -226,9 +226,9 @@ public abstract class TransportImpl implements Transport { } } - _context.statManager().addRateData("transport.sendProcessingTime", msg.getLifetime(), msg.getLifetime()); - + if (sendSuccessful) { + _context.statManager().addRateData("transport.sendProcessingTime", lifetime, lifetime); _context.profileManager().messageSent(msg.getTarget().getIdentity().getHash(), getStyle(), sendTime, msg.getMessageSize()); _context.statManager().addRateData("transport.sendMessageSize", msg.getMessageSize(), sendTime); } else { diff --git a/router/java/src/net/i2p/router/transport/tcp/ConnectionRunner.java b/router/java/src/net/i2p/router/transport/tcp/ConnectionRunner.java index 82b3cddb2..500e33531 100644 --- a/router/java/src/net/i2p/router/transport/tcp/ConnectionRunner.java +++ b/router/java/src/net/i2p/router/transport/tcp/ConnectionRunner.java @@ -59,9 +59,13 @@ class ConnectionRunner implements Runnable { if (_log.shouldLog(Log.WARN)) _log.warn("message " + msg.getMessageType() + "/" + msg.getMessageId() + " expired before it could be sent"); + + msg.timestamp("ConnectionRunner.sendMessage noData"); _con.sent(msg, false, 0); return; } + + msg.timestamp("ConnectionRunner.sendMessage data"); OutputStream out = _con.getOutputStream(); boolean ok = false; diff --git a/router/java/src/net/i2p/router/transport/tcp/TCPConnection.java b/router/java/src/net/i2p/router/transport/tcp/TCPConnection.java index 843ce2b04..797dab478 100644 --- a/router/java/src/net/i2p/router/transport/tcp/TCPConnection.java +++ b/router/java/src/net/i2p/router/transport/tcp/TCPConnection.java @@ -139,6 +139,7 @@ public class TCPConnection { * */ public void addMessage(OutNetMessage msg) { + msg.timestamp("TCPConnection.addMessage"); synchronized (_pendingMessages) { _pendingMessages.add(msg); _pendingMessages.notifyAll(); @@ -157,7 +158,9 @@ public class TCPConnection { while ( (msg == null) && (!_closed) ) { List expired = null; long now = _context.clock().now(); + int queueSize = 0; synchronized (_pendingMessages) { + queueSize = _pendingMessages.size(); for (int i = 0; i < _pendingMessages.size(); i++) { OutNetMessage cur = (OutNetMessage)_pendingMessages.get(i); if (cur.getExpiration() < now) { @@ -182,10 +185,19 @@ public class TCPConnection { if (expired != null) { for (int i = 0; i < expired.size(); i++) { OutNetMessage cur = (OutNetMessage)expired.get(i); + cur.timestamp("TCPConnection.getNextMessage expired"); + if (_log.shouldLog(Log.WARN)) + _log.warn("Message " + cur.getMessageId() + " expired on the queue to " + + _ident.getHash().toBase64().substring(0,6) + + " (queue size " + queueSize + ") with lifetime " + + cur.getLifetime()); sent(cur, false, 0); } } } + + if (msg != null) + msg.timestamp("TCPConnection.getNextMessage retrieved"); return msg; } diff --git a/router/java/src/net/i2p/router/transport/tcp/TCPTransport.java b/router/java/src/net/i2p/router/transport/tcp/TCPTransport.java index 6adfee9a4..a16781b46 100644 --- a/router/java/src/net/i2p/router/transport/tcp/TCPTransport.java +++ b/router/java/src/net/i2p/router/transport/tcp/TCPTransport.java @@ -171,6 +171,8 @@ public class TCPTransport extends TransportImpl { if (msg.getTarget() == null) throw new IllegalStateException("Null target for a ready message?"); + msg.timestamp("TCPTransport.outboundMessageReady"); + TCPConnection con = null; boolean newPeer = false; synchronized (_connectionLock) {