Changeset 78d5080


Ignore:
Timestamp:
Jan 31, 2009 3:36:24 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
6f948df, ac7ea4a
Parents:
395baf0
Message:
  • Tunnel Pool:
    • Remove tunnel from participating if can't contact next hop
    • Fail outbound build faster if can't contact first hop
Location:
router/java/src/net/i2p/router/tunnel/pool
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java

    r395baf0 r78d5080  
    4747        _context.statManager().createRateStat("tunnel.buildRequestZeroHopTime", "How long it takes to build a zero hop tunnel", "Tunnels", new long[] { 60*1000, 10*60*1000 });
    4848        _context.statManager().createRateStat("tunnel.pendingRemaining", "How many inbound requests are pending after a pass (period is how long the pass takes)?", "Tunnels", new long[] { 60*1000, 10*60*1000 });
     49        _context.statManager().createRateStat("tunnel.buildFailFirstHop", "How often we fail to build a OB tunnel because we can't contact the first hop", "Tunnels", new long[] { 60*1000, 10*60*1000 });
    4950
    5051        // Get stat manager, get recognized bandwidth tiers
  • router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java

    r395baf0 r78d5080  
    6262        _context.statManager().createRateStat("tunnel.decryptRequestTime", "How long it takes to decrypt a new tunnel build request", "Tunnels", new long[] { 60*1000, 10*60*1000 });
    6363        _context.statManager().createRateStat("tunnel.rejectTimeout", "How often we reject a tunnel because we can't find the next hop", "Tunnels", new long[] { 60*1000, 10*60*1000 });
     64        _context.statManager().createRateStat("tunnel.rejectTimeout2", "How often we fail a tunnel because we can't contact the next hop", "Tunnels", new long[] { 60*1000, 10*60*1000 });
    6465
    6566        _context.statManager().createRateStat("tunnel.rejectOverloaded", "How long we had to wait before processing the request (when it was rejected)", "Tunnels", new long[] { 60*1000, 10*60*1000 });
     
    414415    }
    415416
    416     private class TimeoutReq extends JobImpl {
     417    private static class TimeoutReq extends JobImpl {
    417418        private BuildMessageState _state;
    418419        private BuildRequestRecord _req;
     
    426427        public String getName() { return "Timeout looking for next peer for tunnel join"; }
    427428        public void runJob() {
    428             getContext().statManager().addRateData("tunnel.rejectTimeout", 1, 1);
    429             if (_log.shouldLog(Log.WARN))
    430                 _log.warn("Request " + _state.msg.getUniqueId()
    431                           + " could no be satisfied, as the next peer could not be found: " + _nextPeer.toBase64());
     429            getContext().statManager().addRateData("tunnel.rejectTimeout", 1, 0);
     430            // logging commented out so class can be static
     431            //if (_log.shouldLog(Log.WARN))
     432            //    _log.warn("Request " + _state.msg.getUniqueId()
     433            //              + " could no be satisfied, as the next peer could not be found: " + _nextPeer.toBase64());
     434
    432435            // ???  should we blame the peer here?   getContext().profileManager().tunnelTimedOut(_nextPeer);
    433436            getContext().messageHistory().tunnelRejected(_state.fromHash, new TunnelId(_req.readReceiveTunnelId()), _nextPeer,
     
    517520                                     state.from != null ? state.from.calculateHash().toBase64() : "tunnel"));
    518521
     522        HopConfig cfg = null;
    519523        if (response == 0) {
    520             HopConfig cfg = new HopConfig();
     524            cfg = new HopConfig();
    521525            cfg.setCreation(_context.clock().now());
    522526            cfg.setExpiration(_context.clock().now() + 10*60*1000);
     
    594598            msg.setPriority(300);
    595599            msg.setTarget(nextPeerInfo);
     600            if (response == 0)
     601                msg.setOnFailedSendJob(new TunnelBuildNextHopFailJob(_context, cfg));
    596602            _context.outNetMessagePool().add(msg);
    597603        } else {
     
    620626                outMsg.setPriority(300);
    621627                outMsg.setTarget(nextPeerInfo);
     628                if (response == 0)
     629                    outMsg.setOnFailedSendJob(new TunnelBuildNextHopFailJob(_context, cfg));
    622630                _context.outNetMessagePool().add(outMsg);
    623631            }
     
    763771   
    764772    /** normal inbound requests from other people */
    765     private class BuildMessageState {
     773    private static class BuildMessageState {
    766774        TunnelBuildMessage msg;
    767775        RouterIdentity from;
     
    776784    }
    777785    /** replies for outbound tunnels that we have created */
    778     private class BuildReplyMessageState {
     786    private static class BuildReplyMessageState {
    779787        TunnelBuildReplyMessage msg;
    780788        long recvTime;
     
    785793    }
    786794    /** replies for inbound tunnels we have created */
    787     private class BuildEndMessageState {
     795    private static class BuildEndMessageState {
    788796        TunnelBuildMessage msg;
    789797        PooledTunnelCreatorConfig cfg;
     
    797805
    798806    // noop
    799     private class TunnelBuildMessageHandlerJob extends JobImpl {
     807    private static class TunnelBuildMessageHandlerJob extends JobImpl {
    800808        private TunnelBuildMessageHandlerJob(RouterContext ctx) { super(ctx); }
    801809        public void runJob() {}
     
    803811    }
    804812    // noop
    805     private class TunnelBuildReplyMessageHandlerJob extends JobImpl {
     813    private static class TunnelBuildReplyMessageHandlerJob extends JobImpl {
    806814        private TunnelBuildReplyMessageHandlerJob(RouterContext ctx) { super(ctx); }
    807815        public void runJob() {}
    808816        public String getName() { return "Receive tunnel build reply message"; }
    809817    }
     818
     819    /**
     820     *  Remove the participating tunnel if we can't contact the next hop
     821     *  Not strictly necessary, as the entry doesn't use that much space,
     822     *  but it affects capacity calculations
     823     */
     824    private static class TunnelBuildNextHopFailJob extends JobImpl {
     825        HopConfig _cfg;
     826        private TunnelBuildNextHopFailJob(RouterContext ctx, HopConfig cfg) {
     827            super(ctx);
     828            _cfg = cfg;
     829        }
     830        public String getName() { return "Timeout contacting next peer for tunnel join"; }
     831        public void runJob() {
     832            getContext().tunnelDispatcher().remove(_cfg);
     833            getContext().statManager().addRateData("tunnel.rejectTimeout2", 1, 0);
     834            // static, no _log
     835            //_log.error("Cant contact next hop for " + _cfg);
     836        }
     837    }
    810838}
  • router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java

    r395baf0 r78d5080  
    1313import net.i2p.data.i2np.I2NPMessage;
    1414import net.i2p.data.i2np.TunnelBuildMessage;
     15import net.i2p.router.JobImpl;
    1516import net.i2p.router.OutNetMessage;
    1617import net.i2p.router.RouterContext;
     
    137138            }
    138139            outMsg.setTarget(peer);
     140            outMsg.setOnFailedSendJob(new TunnelBuildFirstHopFailJob(ctx, pool, cfg, exec));
    139141            ctx.outNetMessagePool().add(outMsg);
    140142        }
     
    214216        // can it get much easier?
    215217    }
     218
     219    /**
     220     *  Do two important things if we can't get the build msg to the
     221     *  first hop on an outbound tunnel -
     222     *  - Call buildComplete() so we can get started on the next build
     223     *    without waiting for the full expire time
     224     *  - Blame the first hop in the profile
     225     *  Most likely to happen on an exploratory tunnel, obviously.
     226     *  Can't do this for inbound tunnels since the msg goes out an expl. tunnel.
     227     */
     228    private static class TunnelBuildFirstHopFailJob extends JobImpl {
     229        TunnelPool _pool;
     230        PooledTunnelCreatorConfig _cfg;
     231        BuildExecutor _exec;
     232        private TunnelBuildFirstHopFailJob(RouterContext ctx, TunnelPool pool, PooledTunnelCreatorConfig cfg, BuildExecutor exec) {
     233            super(ctx);
     234            _cfg = cfg;
     235            _exec = exec;
     236            _pool = pool;
     237        }
     238        public String getName() { return "Timeout contacting first peer for OB tunnel"; }
     239        public void runJob() {
     240            _exec.buildComplete(_cfg, _pool);
     241            getContext().profileManager().tunnelTimedOut(_cfg.getPeer(1));
     242            getContext().statManager().addRateData("tunnel.buildFailFirstHop", 1, 0);
     243            // static, no _log
     244            //System.err.println("Cant contact first hop for " + _cfg);
     245        }
     246    }
    216247}
Note: See TracChangeset for help on using the changeset viewer.