forked from I2P_Developers/i2p.i2p
2005-04-17 zzz
* Added new user-editable eepproxy error page templates. 2005-04-17 jrandom * Revamp the tunnel building throttles, fixing a situation where the rebuild may not recover, and defaulting it to unthrottled (users with slow CPUs may want to set "router.tunnel.shouldThrottle=true" in their advanced router config)
This commit is contained in:
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
||||
*
|
||||
*/
|
||||
public class RouterVersion {
|
||||
public final static String ID = "$Revision: 1.184 $ $Date: 2005/04/12 10:22:12 $";
|
||||
public final static String ID = "$Revision: 1.185 $ $Date: 2005/04/16 19:59:51 $";
|
||||
public final static String VERSION = "0.5.0.6";
|
||||
public final static long BUILD = 2;
|
||||
public final static long BUILD = 3;
|
||||
public static void main(String args[]) {
|
||||
System.out.println("I2P Router version: " + VERSION);
|
||||
System.out.println("Router ID: " + RouterVersion.ID);
|
||||
|
@ -38,7 +38,7 @@ public class TunnelBuilder {
|
||||
return;
|
||||
}
|
||||
OnCreatedJob onCreated = new OnCreatedJob(ctx, pool, cfg);
|
||||
RetryJob onFailed= (zeroHop ? null : new RetryJob(ctx, pool));
|
||||
RetryJob onFailed= new RetryJob(ctx, pool);
|
||||
// queue up a job to request the endpoint to join the tunnel, which then
|
||||
// requeues up another job for earlier hops, etc, until it reaches the
|
||||
// gateway. after the gateway is confirmed, onCreated is fired
|
||||
|
@ -41,7 +41,7 @@ public class TunnelPool {
|
||||
* etc. On overflow, the necessary additional tunnels are built by the
|
||||
* RefreshJob
|
||||
*/
|
||||
private static final int MAX_BUILDS_PER_MINUTE = 5;
|
||||
private static final int MAX_BUILDS_PER_MINUTE = 10;
|
||||
|
||||
public TunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPeerSelector sel, TunnelBuilder builder) {
|
||||
_context = ctx;
|
||||
|
@ -41,6 +41,12 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
||||
/** max # of concurrent build requests */
|
||||
private int _maxOutstandingBuilds;
|
||||
|
||||
private static final String PROP_MAX_OUTSTANDING_BUILDS = "router.tunnel.maxConcurrentBuilds";
|
||||
private static final int DEFAULT_MAX_OUTSTANDING_BUILDS = 20;
|
||||
|
||||
private static final String PROP_THROTTLE_CONCURRENT_TUNNELS = "router.tunnel.shouldThrottle";
|
||||
private static final boolean DEFAULT_THROTTLE_CONCURRENT_TUNNELS = false;
|
||||
|
||||
public TunnelPoolManager(RouterContext ctx) {
|
||||
_context = ctx;
|
||||
_log = ctx.logManager().getLog(TunnelPoolManager.class);
|
||||
@ -54,13 +60,13 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
||||
_clientInboundPools = new HashMap(4);
|
||||
_clientOutboundPools = new HashMap(4);
|
||||
_outstandingBuilds = 0;
|
||||
_maxOutstandingBuilds = 20;
|
||||
String max = ctx.getProperty("router.tunnel.maxConcurrentBuilds", "20");
|
||||
_maxOutstandingBuilds = DEFAULT_MAX_OUTSTANDING_BUILDS;
|
||||
String max = ctx.getProperty(PROP_MAX_OUTSTANDING_BUILDS, String.valueOf(DEFAULT_MAX_OUTSTANDING_BUILDS));
|
||||
if (max != null) {
|
||||
try {
|
||||
_maxOutstandingBuilds = Integer.parseInt(max);
|
||||
} catch (NumberFormatException nfe) {
|
||||
_maxOutstandingBuilds = 20;
|
||||
_maxOutstandingBuilds = DEFAULT_MAX_OUTSTANDING_BUILDS;
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,6 +272,9 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
||||
* @return how many are allowed to be built
|
||||
*/
|
||||
int allocateBuilds(int wanted) {
|
||||
boolean shouldThrottle = shouldThrottleTunnels();
|
||||
if (!shouldThrottle) return wanted;
|
||||
|
||||
synchronized (this) {
|
||||
if (_outstandingBuilds >= _maxOutstandingBuilds) {
|
||||
// ok, as a failsafe, always let one through
|
||||
@ -284,6 +293,11 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldThrottleTunnels() {
|
||||
Boolean rv = Boolean.valueOf(_context.getProperty(PROP_THROTTLE_CONCURRENT_TUNNELS, ""+DEFAULT_THROTTLE_CONCURRENT_TUNNELS));
|
||||
return rv.booleanValue();
|
||||
}
|
||||
|
||||
void buildComplete() {
|
||||
synchronized (this) {
|
||||
|
Reference in New Issue
Block a user