propagate from branch 'i2p.i2p.zzz.test' (head 177f3f7dbb937e60486cb90da7bbcdf9987ffced)

to branch 'i2p.i2p' (head d2424406b9f3877644a1334df71313b6cba018e4)
This commit is contained in:
zzz
2009-05-30 16:28:51 +00:00
27 changed files with 893 additions and 259 deletions

View File

@ -10,6 +10,11 @@
<name>i2p_router</name>
<properties/>
<folders>
<source-folder>
<label>i2p_router</label>
<location>.</location>
<encoding>UTF-8</encoding>
</source-folder>
<source-folder>
<label>src</label>
<type>java</type>
@ -22,11 +27,6 @@
<location>test</location>
<encoding>UTF-8</encoding>
</source-folder>
<source-folder>
<label>i2p_router</label>
<location>.</location>
<encoding>UTF-8</encoding>
</source-folder>
</folders>
<ide-actions>
<action name="build">
@ -73,6 +73,7 @@
<ide-action name="test"/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
<compilation-unit>

View File

@ -33,6 +33,8 @@ class RouterThrottleImpl implements RouterThrottle {
private static final String PROP_MAX_TUNNELS = "router.maxParticipatingTunnels";
private static final int DEFAULT_MAX_TUNNELS = 2000;
private static final String PROP_DEFAULT_KBPS_THROTTLE = "router.defaultKBpsThrottle";
private static final String PROP_MAX_PROCESSINGTIME = "router.defaultProcessingTimeThrottle";
private static final int DEFAULT_MAX_PROCESSINGTIME = 1500;
/** tunnel acceptance */
public static final int TUNNEL_ACCEPT = 0;
@ -96,19 +98,48 @@ class RouterThrottleImpl implements RouterThrottle {
return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
long lag = _context.jobQueue().getMaxLag();
// reject here if lag too high???
// reject here if lag too high???
RateStat rs = _context.statManager().getRate("transport.sendProcessingTime");
Rate r = null;
if (rs != null)
r = rs.getRate(60*1000);
double processTime = (r != null ? r.getAverageValue() : 0);
if (processTime > 5000) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Refusing tunnel request with the job lag of " + lag
+ "since the 1 minute message processing time is too slow (" + processTime + ")");
_context.statManager().addRateData("router.throttleTunnelProcessingTime1m", (long)processTime, (long)processTime);
setTunnelStatus("Rejecting tunnels: High message delay");
return TunnelHistory.TUNNEL_REJECT_TRANSIENT_OVERLOAD;
//Reject tunnels if the time to process messages and send them is too large. Too much time implies congestion.
if(r != null) {
double totalSendProcessingTimeEvents = r.getCurrentEventCount() + r.getLastEventCount();
double avgSendProcessingTime = 0;
double currentSendProcessingTime = 0;
double lastSendProcessingTime = 0;
//Calculate times
if(r.getCurrentEventCount() > 0) {
currentSendProcessingTime = r.getCurrentTotalValue()/r.getCurrentEventCount();
}
if(r.getLastEventCount() > 0) {
lastSendProcessingTime = r.getLastTotalValue()/r.getLastEventCount();
}
if(totalSendProcessingTimeEvents > 0) {
avgSendProcessingTime = (r.getCurrentTotalValue() + r.getLastTotalValue())/totalSendProcessingTimeEvents;
}
else {
avgSendProcessingTime = r.getAverageValue();
if(_log.shouldLog(Log.WARN)) {
_log.warn("No events occurred. Using 1 minute average to look at message delay.");
}
}
int maxProcessingTime = _context.getProperty(PROP_MAX_PROCESSINGTIME, DEFAULT_MAX_PROCESSINGTIME);
//Set throttling if necessary
if((avgSendProcessingTime > maxProcessingTime*0.9
|| currentSendProcessingTime > maxProcessingTime
|| lastSendProcessingTime > maxProcessingTime)) {
if(_log.shouldLog(Log.WARN)) {
_log.warn("Refusing tunnel request due to sendProcessingTime of " + avgSendProcessingTime
+ " ms over the last two minutes, which is too much.");
}
setTunnelStatus("Rejecting tunnels: congestion");
return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
}
}
int numTunnels = _context.tunnelManager().getParticipatingCount();

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 1;
public final static long BUILD = 9;
/** for example "-test" */
public final static String EXTRA = "";
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;

View File

@ -1067,6 +1067,11 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
else
buf.append("Published: <i>in ").append(DataHelper.formatDuration(0-age)).append("???</i><br />\n");
buf.append("Address(es): <i>");
String country = _context.commSystem().getCountry(info.getIdentity().getHash());
if(country != null) {
buf.append(" <img alt=\"").append(country.toUpperCase()).append("\"");
buf.append(" src=\"/flags.jsp?c=").append(country).append("\">");
}
for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) {
RouterAddress addr = (RouterAddress)iter.next();
buf.append(addr.getTransportStyle()).append(": ");