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
This commit is contained in:
@ -68,7 +68,7 @@ public class BufferedStatLog implements StatLog {
|
|||||||
|
|
||||||
private boolean shouldLog(String stat) {
|
private boolean shouldLog(String stat) {
|
||||||
synchronized (_statFilters) {
|
synchronized (_statFilters) {
|
||||||
return _statFilters.contains(stat);
|
return _statFilters.contains(stat) || _statFilters.contains("*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
2004-10-03 jrandom
|
||||||
* Add a new stat logging component to optionally dump the raw stats to
|
* Add a new stat logging component to optionally dump the raw stats to
|
||||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RouterVersion {
|
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 String VERSION = "0.4.1.1";
|
||||||
public final static long BUILD = 6;
|
public final static long BUILD = 7;
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("I2P Router version: " + VERSION);
|
System.out.println("I2P Router version: " + VERSION);
|
||||||
System.out.println("Router ID: " + RouterVersion.ID);
|
System.out.println("Router ID: " + RouterVersion.ID);
|
||||||
|
@ -16,6 +16,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
|
import net.i2p.router.peermanager.PeerProfile;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,8 +63,16 @@ public class Shitlist {
|
|||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Shitlisting router " + peer.toBase64(), new Exception("Shitlist cause"));
|
_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) {
|
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);
|
wasAlready = (null == oldDate);
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
_shitlistCause.put(peer, reason);
|
_shitlistCause.put(peer, reason);
|
||||||
@ -85,6 +94,9 @@ public class Shitlist {
|
|||||||
_shitlist.remove(peer);
|
_shitlist.remove(peer);
|
||||||
_shitlistCause.remove(peer);
|
_shitlistCause.remove(peer);
|
||||||
}
|
}
|
||||||
|
PeerProfile prof = _context.profileOrganizer().getProfile(peer);
|
||||||
|
if (prof != null)
|
||||||
|
prof.unshitlist();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShitlisted(Hash peer) {
|
public boolean isShitlisted(Hash peer) {
|
||||||
@ -95,7 +107,7 @@ public class Shitlist {
|
|||||||
if (shitlistDate == null) return false;
|
if (shitlistDate == null) return false;
|
||||||
|
|
||||||
// check validity
|
// check validity
|
||||||
if (shitlistDate.getTime() > _context.clock().now() - SHITLIST_DURATION_MS) {
|
if (shitlistDate.getTime() > _context.clock().now()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
unshitlistRouter(peer);
|
unshitlistRouter(peer);
|
||||||
@ -115,7 +127,7 @@ public class Shitlist {
|
|||||||
shitlist = new HashMap(_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(); ) {
|
for (Iterator iter = shitlist.keySet().iterator(); iter.hasNext(); ) {
|
||||||
Hash key = (Hash)iter.next();
|
Hash key = (Hash)iter.next();
|
||||||
@ -146,7 +158,7 @@ public class Shitlist {
|
|||||||
Date shitDate = (Date)shitlist.get(key);
|
Date shitDate = (Date)shitlist.get(key);
|
||||||
buf.append("<li><b>").append(key.toBase64()).append("</b>");
|
buf.append("<li><b>").append(key.toBase64()).append("</b>");
|
||||||
buf.append(" <a href=\"netdb.jsp#").append(key.toBase64().substring(0, 6)).append("\">(?)</a>");
|
buf.append(" <a href=\"netdb.jsp#").append(key.toBase64().substring(0, 6)).append("\">(?)</a>");
|
||||||
buf.append(" was shitlisted on ");
|
buf.append(" expiring on ");
|
||||||
buf.append(shitDate);
|
buf.append(shitDate);
|
||||||
String cause = (String)causes.get(key);
|
String cause = (String)causes.get(key);
|
||||||
if (cause != null) {
|
if (cause != null) {
|
||||||
|
@ -44,6 +44,7 @@ public class PeerProfile {
|
|||||||
private DBHistory _dbHistory;
|
private DBHistory _dbHistory;
|
||||||
// does this peer profile contain expanded data, or just the basics?
|
// does this peer profile contain expanded data, or just the basics?
|
||||||
private boolean _expanded;
|
private boolean _expanded;
|
||||||
|
private int _consecutiveShitlists;
|
||||||
|
|
||||||
public PeerProfile(RouterContext context, Hash peer) {
|
public PeerProfile(RouterContext context, Hash peer) {
|
||||||
this(context, peer, true);
|
this(context, peer, true);
|
||||||
@ -57,6 +58,7 @@ public class PeerProfile {
|
|||||||
_capacityValue = 0;
|
_capacityValue = 0;
|
||||||
_integrationValue = 0;
|
_integrationValue = 0;
|
||||||
_isFailing = false;
|
_isFailing = false;
|
||||||
|
_consecutiveShitlists = 0;
|
||||||
_peer = peer;
|
_peer = peer;
|
||||||
if (expand)
|
if (expand)
|
||||||
expandProfile();
|
expandProfile();
|
||||||
@ -74,6 +76,9 @@ public class PeerProfile {
|
|||||||
*/
|
*/
|
||||||
public boolean getIsExpanded() { return _expanded; }
|
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
|
* Is this peer active at the moment (sending/receiving messages within the last
|
||||||
* 5 minutes)
|
* 5 minutes)
|
||||||
|
@ -226,9 +226,9 @@ public abstract class TransportImpl implements Transport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.statManager().addRateData("transport.sendProcessingTime", msg.getLifetime(), msg.getLifetime());
|
|
||||||
|
|
||||||
if (sendSuccessful) {
|
if (sendSuccessful) {
|
||||||
|
_context.statManager().addRateData("transport.sendProcessingTime", lifetime, lifetime);
|
||||||
_context.profileManager().messageSent(msg.getTarget().getIdentity().getHash(), getStyle(), sendTime, msg.getMessageSize());
|
_context.profileManager().messageSent(msg.getTarget().getIdentity().getHash(), getStyle(), sendTime, msg.getMessageSize());
|
||||||
_context.statManager().addRateData("transport.sendMessageSize", msg.getMessageSize(), sendTime);
|
_context.statManager().addRateData("transport.sendMessageSize", msg.getMessageSize(), sendTime);
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,9 +59,13 @@ class ConnectionRunner implements Runnable {
|
|||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("message " + msg.getMessageType() + "/" + msg.getMessageId()
|
_log.warn("message " + msg.getMessageType() + "/" + msg.getMessageId()
|
||||||
+ " expired before it could be sent");
|
+ " expired before it could be sent");
|
||||||
|
|
||||||
|
msg.timestamp("ConnectionRunner.sendMessage noData");
|
||||||
_con.sent(msg, false, 0);
|
_con.sent(msg, false, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg.timestamp("ConnectionRunner.sendMessage data");
|
||||||
|
|
||||||
OutputStream out = _con.getOutputStream();
|
OutputStream out = _con.getOutputStream();
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
|
@ -139,6 +139,7 @@ public class TCPConnection {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void addMessage(OutNetMessage msg) {
|
public void addMessage(OutNetMessage msg) {
|
||||||
|
msg.timestamp("TCPConnection.addMessage");
|
||||||
synchronized (_pendingMessages) {
|
synchronized (_pendingMessages) {
|
||||||
_pendingMessages.add(msg);
|
_pendingMessages.add(msg);
|
||||||
_pendingMessages.notifyAll();
|
_pendingMessages.notifyAll();
|
||||||
@ -157,7 +158,9 @@ public class TCPConnection {
|
|||||||
while ( (msg == null) && (!_closed) ) {
|
while ( (msg == null) && (!_closed) ) {
|
||||||
List expired = null;
|
List expired = null;
|
||||||
long now = _context.clock().now();
|
long now = _context.clock().now();
|
||||||
|
int queueSize = 0;
|
||||||
synchronized (_pendingMessages) {
|
synchronized (_pendingMessages) {
|
||||||
|
queueSize = _pendingMessages.size();
|
||||||
for (int i = 0; i < _pendingMessages.size(); i++) {
|
for (int i = 0; i < _pendingMessages.size(); i++) {
|
||||||
OutNetMessage cur = (OutNetMessage)_pendingMessages.get(i);
|
OutNetMessage cur = (OutNetMessage)_pendingMessages.get(i);
|
||||||
if (cur.getExpiration() < now) {
|
if (cur.getExpiration() < now) {
|
||||||
@ -182,10 +185,19 @@ public class TCPConnection {
|
|||||||
if (expired != null) {
|
if (expired != null) {
|
||||||
for (int i = 0; i < expired.size(); i++) {
|
for (int i = 0; i < expired.size(); i++) {
|
||||||
OutNetMessage cur = (OutNetMessage)expired.get(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);
|
sent(cur, false, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg != null)
|
||||||
|
msg.timestamp("TCPConnection.getNextMessage retrieved");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +171,8 @@ public class TCPTransport extends TransportImpl {
|
|||||||
if (msg.getTarget() == null)
|
if (msg.getTarget() == null)
|
||||||
throw new IllegalStateException("Null target for a ready message?");
|
throw new IllegalStateException("Null target for a ready message?");
|
||||||
|
|
||||||
|
msg.timestamp("TCPTransport.outboundMessageReady");
|
||||||
|
|
||||||
TCPConnection con = null;
|
TCPConnection con = null;
|
||||||
boolean newPeer = false;
|
boolean newPeer = false;
|
||||||
synchronized (_connectionLock) {
|
synchronized (_connectionLock) {
|
||||||
|
Reference in New Issue
Block a user