schedule the outbound rather than sleep the thread for 3 seconds
This commit is contained in:
@ -29,6 +29,8 @@ import net.i2p.stat.RateStat;
|
|||||||
import net.i2p.util.I2PThread;
|
import net.i2p.util.I2PThread;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.ObjectCounter;
|
import net.i2p.util.ObjectCounter;
|
||||||
|
import net.i2p.util.SimpleScheduler;
|
||||||
|
import net.i2p.util.SimpleTimer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -42,7 +44,7 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
|||||||
private final Map<Hash, TunnelPool> _clientOutboundPools;
|
private final Map<Hash, TunnelPool> _clientOutboundPools;
|
||||||
private TunnelPool _inboundExploratory;
|
private TunnelPool _inboundExploratory;
|
||||||
private TunnelPool _outboundExploratory;
|
private TunnelPool _outboundExploratory;
|
||||||
private BuildExecutor _executor;
|
private final BuildExecutor _executor;
|
||||||
private boolean _isShutdown;
|
private boolean _isShutdown;
|
||||||
|
|
||||||
public TunnelPoolManager(RouterContext ctx) {
|
public TunnelPoolManager(RouterContext ctx) {
|
||||||
@ -263,6 +265,7 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
|||||||
TunnelPool inbound = null;
|
TunnelPool inbound = null;
|
||||||
TunnelPool outbound = null;
|
TunnelPool outbound = null;
|
||||||
// should we share the clientPeerSelector across both inbound and outbound?
|
// should we share the clientPeerSelector across both inbound and outbound?
|
||||||
|
// or just one for all clients? why separate?
|
||||||
synchronized (_clientInboundPools) {
|
synchronized (_clientInboundPools) {
|
||||||
inbound = _clientInboundPools.get(dest);
|
inbound = _clientInboundPools.get(dest);
|
||||||
if (inbound == null) {
|
if (inbound == null) {
|
||||||
@ -284,11 +287,22 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
inbound.startup();
|
inbound.startup();
|
||||||
try { Thread.sleep(3*1000); } catch (InterruptedException ie) {}
|
SimpleScheduler.getInstance().addEvent(new DelayedStartup(outbound), 3*1000);
|
||||||
outbound.startup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class DelayedStartup implements SimpleTimer.TimedEvent {
|
||||||
|
private TunnelPool pool;
|
||||||
|
|
||||||
|
public DelayedStartup(TunnelPool p) {
|
||||||
|
this.pool = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void timeReached() {
|
||||||
|
this.pool.startup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeTunnels(Hash destination) {
|
public void removeTunnels(Hash destination) {
|
||||||
if (destination == null) return;
|
if (destination == null) return;
|
||||||
if (_context.clientManager().isLocal(destination)) {
|
if (_context.clientManager().isLocal(destination)) {
|
||||||
@ -361,12 +375,11 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
|||||||
_inboundExploratory = new TunnelPool(_context, this, inboundSettings, selector);
|
_inboundExploratory = new TunnelPool(_context, this, inboundSettings, selector);
|
||||||
_inboundExploratory.startup();
|
_inboundExploratory.startup();
|
||||||
|
|
||||||
try { Thread.sleep(3*1000); } catch (InterruptedException ie) {}
|
|
||||||
TunnelPoolSettings outboundSettings = new TunnelPoolSettings();
|
TunnelPoolSettings outboundSettings = new TunnelPoolSettings();
|
||||||
outboundSettings.setIsExploratory(true);
|
outboundSettings.setIsExploratory(true);
|
||||||
outboundSettings.setIsInbound(false);
|
outboundSettings.setIsInbound(false);
|
||||||
_outboundExploratory = new TunnelPool(_context, this, outboundSettings, selector);
|
_outboundExploratory = new TunnelPool(_context, this, outboundSettings, selector);
|
||||||
_outboundExploratory.startup();
|
SimpleScheduler.getInstance().addEvent(new DelayedStartup(_outboundExploratory), 3*1000);
|
||||||
|
|
||||||
// try to build up longer tunnels
|
// try to build up longer tunnels
|
||||||
_context.jobQueue().addJob(new BootstrapPool(_context, _inboundExploratory));
|
_context.jobQueue().addJob(new BootstrapPool(_context, _inboundExploratory));
|
||||||
|
Reference in New Issue
Block a user