Changeset 20855c9


Ignore:
Timestamp:
Aug 29, 2011 5:51:00 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
a6728a3
Parents:
92ffea2
Message:
  • Tunnels:
    • Increase timeouts on all deferred netdb lookups to 15s; add lookup stats
    • Cleanups, javadocs, log tweaks
Location:
router/java/src/net/i2p/router/tunnel
Files:
9 edited

Legend:

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

    r92ffea2 r20855c9  
    4747public class BatchedPreprocessor extends TrivialPreprocessor {
    4848    private long _pendingSince;
    49     private String _name;
     49    private final String _name;
    5050   
    5151    public BatchedPreprocessor(RouterContext ctx, String name) {
    5252        super(ctx);
    53         _log = ctx.logManager().getLog(BatchedPreprocessor.class);
    5453        _name = name;
    55         _pendingSince = 0;
    56         ctx.statManager().createRateStat("tunnel.batchMultipleCount", "How many messages are batched into a tunnel message", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
    57         ctx.statManager().createRateStat("tunnel.batchDelay", "How many messages were pending when the batching waited", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
    58         ctx.statManager().createRateStat("tunnel.batchDelaySent", "How many messages were flushed when the batching delay completed", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
    59         ctx.statManager().createRateStat("tunnel.batchCount", "How many groups of messages were flushed together", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
    60         ctx.statManager().createRateStat("tunnel.batchDelayAmount", "How long we should wait before flushing the batch", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
    61         ctx.statManager().createRateStat("tunnel.batchFlushRemaining", "How many messages remain after flushing", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
    62         ctx.statManager().createRateStat("tunnel.writeDelay", "How long after a message reaches the gateway is it processed (lifetime is size)", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
    63         ctx.statManager().createRateStat("tunnel.batchSmallFragments", "How many outgoing pad bytes are in small fragments?",
    64                                          "Tunnels", new long[] { 10*60*1000l, 60*60*1000l });
    65         ctx.statManager().createRateStat("tunnel.batchFullFragments", "How many outgoing tunnel messages use the full data area?",
    66                                          "Tunnels", new long[] { 10*60*1000l, 60*60*1000l });
    67         ctx.statManager().createRateStat("tunnel.batchFragmentation", "Avg. number of fragments per msg", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
     54        // all createRateStat() moved to TunnelDispatcher
    6855    }
    6956   
     
    427414                    if (later > 0)
    428415                        frag--;
    429                     _log.debug("writing " + msg.getMessageId() + " fragment " + frag
     416                    if (_log.shouldLog(Log.DEBUG))
     417                        _log.debug("writing " + msg.getMessageId() + " fragment " + frag
    430418                               + ", ending at " + offset + " prev " + prevOffset
    431419                               + " leaving " + later + " bytes for later");
  • router/java/src/net/i2p/router/tunnel/InboundGatewayReceiver.java

    r92ffea2 r20855c9  
    88
    99/**
    10  *
     10 *  Handle messages at the IBGW
    1111 */
    12 public class InboundGatewayReceiver implements TunnelGateway.Receiver {
    13     private RouterContext _context;
    14     private HopConfig _config;
     12class InboundGatewayReceiver implements TunnelGateway.Receiver {
     13    private final RouterContext _context;
     14    private final HopConfig _config;
    1515    private RouterInfo _target;
    1616   
     17    private static final long MAX_LOOKUP_TIME = 15*1000;
     18
    1719    public InboundGatewayReceiver(RouterContext ctx, HopConfig cfg) {
    1820        _context = ctx;
    1921        _config = cfg;
     22        // all createRateStat() in TunnelDispatcher
    2023    }
     24
    2125    public long receiveEncrypted(byte[] encrypted) {
    2226        return receiveEncrypted(encrypted, false);
    2327    }
     28
    2429    public long receiveEncrypted(byte[] encrypted, boolean alreadySearched) {
    2530        if (!alreadySearched)
     
    2833            _target = _context.netDb().lookupRouterInfoLocally(_config.getSendTo());
    2934            if (_target == null) {
     35                // It should be rare to forget the router info for the next peer
    3036                ReceiveJob j = null;
    31                 if (!alreadySearched)
     37                if (alreadySearched)
     38                    _context.statManager().addRateData("tunnel.inboundLookupSuccess", 0, 0);
     39                else
    3240                    j = new ReceiveJob(_context, encrypted);
    33                 _context.netDb().lookupRouterInfo(_config.getSendTo(), j, j, 5*1000);
     41                _context.netDb().lookupRouterInfo(_config.getSendTo(), j, j, MAX_LOOKUP_TIME);
    3442                return -1;
    3543            }
    3644        }
     45        if (alreadySearched)
     46            _context.statManager().addRateData("tunnel.inboundLookupSuccess", 1, 0);
    3747       
    3848        // We do this before the preprocessor now (i.e. before fragmentation)
     
    5464   
    5565    private class ReceiveJob extends JobImpl {
    56         private byte[] _encrypted;
     66        private final byte[] _encrypted;
     67
    5768        public ReceiveJob(RouterContext ctx, byte data[]) {
    5869            super(ctx);
    5970            _encrypted = data;
    6071        }
    61         public String getName() { return "lookup first hop"; }
     72
     73        public String getName() { return "IBGW lookup first hop"; }
     74
    6275        public void runJob() {
    6376            receiveEncrypted(_encrypted, true);
  • router/java/src/net/i2p/router/tunnel/OutboundMessageDistributor.java

    r92ffea2 r20855c9  
    2020    private final Log _log;
    2121   
    22     private static final int MAX_DISTRIBUTE_TIME = 10*1000;
     22    private static final long MAX_DISTRIBUTE_TIME = 15*1000;
    2323   
    2424    public OutboundMessageDistributor(RouterContext ctx, int priority) {
     
    2626        _priority = priority;
    2727        _log = ctx.logManager().getLog(OutboundMessageDistributor.class);
     28        // all createRateStat() in TunnelDispatcher
    2829    }
    2930   
     
    3536        RouterInfo info = _context.netDb().lookupRouterInfoLocally(target);
    3637        if (info == null) {
    37             if (_log.shouldLog(Log.DEBUG))
    38                 _log.debug("outbound distributor to " + target.toBase64().substring(0,4)
     38            if (_log.shouldLog(Log.INFO))
     39                _log.info("outbound distributor to " + target
    3940                           + "." + (tunnel != null ? tunnel.getTunnelId() + "" : "")
    4041                           + ": no info locally, searching...");
     42            // TODO - should we set the search timeout based on the message timeout,
     43            // or is that a bad idea due to clock skews?
    4144            _context.netDb().lookupRouterInfo(target, new DistributeJob(_context, msg, target, tunnel), null, MAX_DISTRIBUTE_TIME);
    4245            return;
     
    6972
    7073            if (_log.shouldLog(Log.DEBUG))
    71                 _log.debug("queueing outbound message to " + target.getIdentity().calculateHash().toBase64().substring(0,4));
     74                _log.debug("queueing outbound message to " + target.getIdentity().calculateHash());
    7275            _context.outNetMessagePool().add(out);
    7376        }
     
    8689        }
    8790
    88         public String getName() { return "Distribute outbound message"; }
     91        public String getName() { return "OBEP distribute after lookup"; }
    8992
    9093        public void runJob() {
    9194            RouterInfo info = getContext().netDb().lookupRouterInfoLocally(_target);
     95            int stat;
    9296            if (info != null) {
    9397                if (_log.shouldLog(Log.DEBUG))
    94                     _log.debug("outbound distributor to " + _target.toBase64().substring(0,4)
     98                    _log.debug("outbound distributor to " + _target
    9599                           + "." + (_tunnel != null ? _tunnel.getTunnelId() + "" : "")
    96100                           + ": found on search");
    97101                distribute(_message, info, _tunnel);
     102                stat = 1;
    98103            } else {
    99                 // TODO add a stat here
    100104                if (_log.shouldLog(Log.WARN))
    101                     _log.warn("outbound distributor to " + _target.toBase64().substring(0,4)
     105                    _log.warn("outbound distributor to " + _target
    102106                           + "." + (_tunnel != null ? _tunnel.getTunnelId() + "" : "")
    103107                           + ": NOT found on search");
     108                stat = 0;
    104109            }
     110            _context.statManager().addRateData("tunnel.distributeLookupSuccess", stat, 0);
    105111        }
    106        
    107112    }
    108113}
  • router/java/src/net/i2p/router/tunnel/OutboundReceiver.java

    r92ffea2 r20855c9  
    99
    1010/**
     11 * We are the outbound gateway - we created this outbound tunnel.
    1112 * Receive the outbound message after it has been preprocessed and encrypted,
    1213 * then forward it on to the first hop in the tunnel.
     
    1920    private RouterInfo _nextHopCache;
    2021   
     22    private static final long MAX_LOOKUP_TIME = 15*1000;
     23
    2124    public OutboundReceiver(RouterContext ctx, TunnelCreatorConfig cfg) {
    2225        _context = ctx;
     
    2427        _config = cfg;
    2528        _nextHopCache = _context.netDb().lookupRouterInfoLocally(_config.getPeer(1));
     29        // all createRateStat() in TunnelDispatcher
    2630    }
    2731   
     
    4145            return msg.getUniqueId();
    4246        } else {
    43             // TODO add a stat here
     47            // It should be rare to forget the router info for a peer in our own tunnel.
    4448            if (_log.shouldLog(Log.WARN))
    45                 _log.warn("lookup of " + _config.getPeer(1).toBase64().substring(0,4)
     49                _log.warn("lookup of " + _config.getPeer(1)
    4650                           + " required for " + msg);
    47             _context.netDb().lookupRouterInfo(_config.getPeer(1), new SendJob(_context, msg), new FailedJob(_context), 10*1000);
     51            _context.netDb().lookupRouterInfo(_config.getPeer(1), new SendJob(_context, msg),
     52                                              new FailedJob(_context), MAX_LOOKUP_TIME);
    4853            return -1;
    4954        }
     
    7075        }
    7176
    72         public String getName() { return "forward a tunnel message"; }
     77        public String getName() { return "OBGW send after lookup"; }
    7378
    7479        public void runJob() {
    7580            RouterInfo ri = _context.netDb().lookupRouterInfoLocally(_config.getPeer(1));
    7681            if (_log.shouldLog(Log.DEBUG))
    77                 _log.debug("lookup of " + _config.getPeer(1).toBase64().substring(0,4)
     82                _log.debug("lookup of " + _config.getPeer(1)
    7883                           + " successful? " + (ri != null));
     84            int stat;
    7985            if (ri != null) {
    8086                _nextHopCache = ri;
    8187                send(_msg, ri);
     88                stat = 1;
     89            } else {
     90                stat = 0;
    8291            }
     92            _context.statManager().addRateData("tunnel.outboundLookupSuccess", stat, 0);
    8393        }
    8494    }
     
    8999        }
    90100
    91         public String getName() { return "failed looking for our outbound gateway"; }
     101        public String getName() { return "OBGW lookup fail"; }
    92102
    93103        public void runJob() {
    94             // TODO add a stat here
    95104            if (_log.shouldLog(Log.WARN))
    96                 _log.warn("lookup of " + _config.getPeer(1).toBase64().substring(0,4)
     105                _log.warn("lookup of " + _config.getPeer(1)
    97106                           + " failed for " + _config);
     107            _context.statManager().addRateData("tunnel.outboundLookupSuccess", 0, 0);
    98108        }
    99109    }
  • router/java/src/net/i2p/router/tunnel/TrivialPreprocessor.java

    r92ffea2 r20855c9  
    2121 */
    2222public class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor {
    23     protected RouterContext _context;
    24     protected Log _log;
     23    protected final RouterContext _context;
     24    protected final Log _log;
    2525   
    2626    public static final int PREPROCESSED_SIZE = 1024;
     
    4040    public TrivialPreprocessor(RouterContext ctx) {
    4141        _context = ctx;
    42         _log = ctx.logManager().getLog(TrivialPreprocessor.class);
     42        _log = ctx.logManager().getLog(getClass());
    4343    }
    4444 
  • router/java/src/net/i2p/router/tunnel/TrivialRouterPreprocessor.java

    r92ffea2 r20855c9  
    1111 */
    1212public class TrivialRouterPreprocessor extends TrivialPreprocessor {
    13     private RouterContext _routerContext;
    1413   
    1514    public TrivialRouterPreprocessor(RouterContext ctx) {
    1615        super(ctx);
    17         _routerContext = ctx;
    1816    }
    1917
    2018    protected void notePreprocessing(long messageId, int numFragments, int totalLength, List<Long> messageIds) {
    21         _routerContext.messageHistory().fragmentMessage(messageId, numFragments, totalLength, messageIds, null);
     19        _context.messageHistory().fragmentMessage(messageId, numFragments, totalLength, messageIds, null);
    2220    }
    2321}
  • router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java

    r92ffea2 r20855c9  
    5353        _inboundGateways = new ConcurrentHashMap();
    5454        _participatingConfig = new ConcurrentHashMap();
    55         _lastParticipatingExpiration = 0;
    56         _lastDropTime = 0;
    57         _validator = null;
    5855        _pumper = new TunnelGatewayPumper(ctx);
    5956        _leaveJob = new LeaveTunnel(ctx);
     
    108105        ctx.statManager().createRateStat("tunnel.dispatchOutboundZeroHopTime",
    109106                                         "How long it takes to dispatch an outbound message through a zero hop tunnel", "Tunnels",
    110                                          new long[] { 60*1000l, 60*60*1000l });
     107                                         new long[] { 60*60*1000l });
    111108        ctx.statManager().createRequiredRateStat("tunnel.participatingBandwidth",
    112109                                         "Participating traffic received (Bytes/sec)", "Tunnels",
     
    130127                                         "How many messages are sent through a tunnel that only failed partially (period == failures)?", "Tunnels",
    131128                                         new long[] { 60*1000l, 10*60*1000l, 60*60*1000l });
     129        // following are for BatchedPreprocessor
     130        ctx.statManager().createRateStat("tunnel.batchMultipleCount", "How many messages are batched into a tunnel message", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
     131        ctx.statManager().createRateStat("tunnel.batchDelay", "How many messages were pending when the batching waited", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
     132        ctx.statManager().createRateStat("tunnel.batchDelaySent", "How many messages were flushed when the batching delay completed", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
     133        ctx.statManager().createRateStat("tunnel.batchCount", "How many groups of messages were flushed together", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
     134        ctx.statManager().createRateStat("tunnel.batchDelayAmount", "How long we should wait before flushing the batch", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
     135        ctx.statManager().createRateStat("tunnel.batchFlushRemaining", "How many messages remain after flushing", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
     136        ctx.statManager().createRateStat("tunnel.writeDelay", "How long after a message reaches the gateway is it processed (lifetime is size)", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
     137        ctx.statManager().createRateStat("tunnel.batchSmallFragments", "How many outgoing pad bytes are in small fragments?",
     138                                         "Tunnels", new long[] { 10*60*1000l, 60*60*1000l });
     139        ctx.statManager().createRateStat("tunnel.batchFullFragments", "How many outgoing tunnel messages use the full data area?",
     140                                         "Tunnels", new long[] { 10*60*1000l, 60*60*1000l });
     141        ctx.statManager().createRateStat("tunnel.batchFragmentation", "Avg. number of fragments per msg", "Tunnels", new long[] { 10*60*1000, 60*60*1000 });
     142        // following is for OutboundMessageDistributor
     143        ctx.statManager().createRateStat("tunnel.distributeLookupSuccess", "Was a deferred lookup successful?", "Tunnels", new long[] { 60*60*1000 });
     144        // following is for OutboundReceiver
     145        ctx.statManager().createRateStat("tunnel.outboundLookupSuccess", "Was a deferred lookup successful?", "Tunnels", new long[] { 60*60*1000 });
     146        // following is for InboundGatewayReceiver
     147        ctx.statManager().createRateStat("tunnel.inboundLookupSuccess", "Was a deferred lookup successful?", "Tunnels", new long[] { 60*60*1000 });
     148        // following is for TunnelParticipant
     149        ctx.statManager().createRateStat("tunnel.participantLookupSuccess", "Was a deferred lookup successful?", "Tunnels", new long[] { 60*60*1000 });
    132150    }
    133151
     
    172190        }
    173191    }
     192
    174193    /**
    175194     * We are the inbound endpoint - we created this tunnel
     
    211230        _leaveJob.add(cfg);
    212231    }
     232
    213233    /**
    214234     * We are the outbound endpoint in this tunnel, and did not create it
  • router/java/src/net/i2p/router/tunnel/TunnelParticipant.java

    r92ffea2 r20855c9  
    1919 */
    2020public class TunnelParticipant {
    21     private RouterContext _context;
    22     private Log _log;
    23     private HopConfig _config;
    24     private HopProcessor _processor;
    25     private InboundEndpointProcessor _inboundEndpointProcessor;
    26     private InboundMessageDistributor _inboundDistributor;
    27     private FragmentHandler _handler;
     21    private final RouterContext _context;
     22    private final Log _log;
     23    private final HopConfig _config;
     24    private final HopProcessor _processor;
     25    private final InboundEndpointProcessor _inboundEndpointProcessor;
     26    private final InboundMessageDistributor _inboundDistributor;
     27    private final FragmentHandler _handler;
    2828    private RouterInfo _nextHopCache;
    2929
     30    private static final long MAX_LOOKUP_TIME = 15*1000;
     31    /** for next hop when a tunnel is first created */
     32    private static final long LONG_MAX_LOOKUP_TIME = 30*1000;
     33
     34    /** not an inbound endpoint */
    3035    public TunnelParticipant(RouterContext ctx, HopConfig config, HopProcessor processor) {
    3136        this(ctx, config, processor, null);
    3237    }
     38
     39    /** inbound endpoint */
    3340    public TunnelParticipant(RouterContext ctx, InboundEndpointProcessor inEndProc) {
    3441        this(ctx, null, null, inEndProc);
    3542    }
     43
     44    /**
     45     * @param config may be null (inbound endpoint if null)
     46     * @param processor may be null (inbound endpoint if null)
     47     * @param inEndProc may be null (inbound endpoint if non-null)
     48     */
    3649    private TunnelParticipant(RouterContext ctx, HopConfig config, HopProcessor processor, InboundEndpointProcessor inEndProc) {
    3750        _context = ctx;
     
    4154        if ( (config == null) || (config.getSendTo() == null) )
    4255            _handler = new RouterFragmentHandler(ctx, new DefragmentedHandler());
     56        else
     57            _handler = null; // final
     58
    4359        _inboundEndpointProcessor = inEndProc;
    4460        if (inEndProc != null)
    4561            _inboundDistributor = new InboundMessageDistributor(ctx, inEndProc.getDestination());
     62        else
     63            _inboundDistributor = null; // final
    4664
    4765        if ( (_config != null) && (_config.getSendTo() != null) ) {
    4866            _nextHopCache = _context.netDb().lookupRouterInfoLocally(_config.getSendTo());
    4967            if (_nextHopCache == null)
    50                 _context.netDb().lookupRouterInfo(_config.getSendTo(), new Found(_context), null, 60*1000);
    51         }
     68                _context.netDb().lookupRouterInfo(_config.getSendTo(), new Found(_context), null, LONG_MAX_LOOKUP_TIME);
     69        }
     70        // all createRateStat() in TunnelDispatcher
    5271    }
    5372   
     
    5675        public String getName() { return "Next hop info found"; }
    5776        public void runJob() {
    58             if (_nextHopCache == null)
     77            if (_nextHopCache == null) {
    5978                _nextHopCache = _context.netDb().lookupRouterInfoLocally(_config.getSendTo());
     79                // nothing for failure since fail job is null
     80                _context.statManager().addRateData("tunnel.participantLookupSuccess", 1, 0);
     81            }
    6082        }
    6183    }
     
    85107            if (ri != null) {
    86108                if (_log.shouldLog(Log.DEBUG))
    87                     _log.debug("Send off to nextHop directly (" + _config.getSendTo().toBase64().substring(0,4)
     109                    _log.debug("Send off to nextHop directly (" + _config.getSendTo()
    88110                              + " for " + msg);
    89111                send(_config, msg, ri);
     
    92114                //    incrementThroughput(_config.getReceiveFrom());
    93115            } else {
     116                // It should be rare to forget the router info for the next peer
    94117                if (_log.shouldLog(Log.WARN))
    95                     _log.warn("Lookup the nextHop (" + _config.getSendTo().toBase64().substring(0,4)
     118                    _log.warn("Lookup the nextHop (" + _config.getSendTo()
    96119                              + " for " + msg);
    97                 _context.netDb().lookupRouterInfo(_config.getSendTo(), new SendJob(_context, msg), new TimeoutJob(_context, msg), 10*1000);
     120                _context.netDb().lookupRouterInfo(_config.getSendTo(), new SendJob(_context, msg),
     121                                                  new TimeoutJob(_context, msg), MAX_LOOKUP_TIME);
    98122            }
    99123        } else {
     
    140164            return 0;
    141165    }
     166
    142167    public int getFailedCount() {
    143168        if (_handler != null)
     
    177202
    178203    private class SendJob extends JobImpl {
    179         private TunnelDataMessage _msg;
     204        private final TunnelDataMessage _msg;
     205
    180206        public SendJob(RouterContext ctx, TunnelDataMessage msg) {
    181207            super(ctx);
    182208            _msg = msg;
    183209        }
    184         public String getName() { return "forward a tunnel message"; }
     210
     211        public String getName() { return "Participant send after lookup"; }
     212
    185213        public void runJob() {
    186214            if (_nextHopCache != null) {
     
    188216            } else {
    189217                RouterInfo ri = _context.netDb().lookupRouterInfoLocally(_config.getSendTo());
     218                int stat;
    190219                if (ri != null) {
    191220                    _nextHopCache = ri;
    192221                    send(_config, _msg, ri);
     222                    stat = 1;
    193223                } else {
    194                     if (_log.shouldLog(Log.ERROR))
    195                         _log.error("Lookup the nextHop (" + _config.getSendTo().toBase64().substring(0,4)
     224                    if (_log.shouldLog(Log.WARN))
     225                        _log.warn("Lookup the nextHop (" + _config.getSendTo()
    196226                                  + " failed!  where do we go for " + _config + "?  msg dropped: " + _msg);
     227                    stat = 0;
    197228                }
     229                _context.statManager().addRateData("tunnel.participantLookupSuccess", stat, 0);
    198230            }
    199231        }
     
    201233
    202234    private class TimeoutJob extends JobImpl {
    203         private TunnelDataMessage _msg;
     235        private final TunnelDataMessage _msg;
     236
    204237        public TimeoutJob(RouterContext ctx, TunnelDataMessage msg) {
    205238            super(ctx);
    206239            _msg = msg;
    207240        }
    208         public String getName() { return "timeout looking for next hop info"; }
     241
     242        public String getName() { return "Participant next hop lookup timeout"; }
     243
    209244        public void runJob() {
    210245            if (_nextHopCache != null)
     
    214249            if (ri != null) {
    215250                _nextHopCache = ri;
    216                 if (_log.shouldLog(Log.ERROR))
    217                     _log.error("Lookup the nextHop (" + _config.getSendTo().toBase64().substring(0,4)
     251                if (_log.shouldLog(Log.WARN))
     252                    _log.warn("Lookup the nextHop (" + _config.getSendTo()
    218253                              + " failed, but we found it!!  where do we go for " + _config + "?  msg dropped: " + _msg);
    219254            } else {
    220                 if (_log.shouldLog(Log.ERROR))
    221                     _log.error("Lookup the nextHop (" + _config.getSendTo().toBase64().substring(0,4)
     255                if (_log.shouldLog(Log.WARN))
     256                    _log.warn("Lookup the nextHop (" + _config.getSendTo()
    222257                              + " failed!  where do we go for " + _config + "?  msg dropped: " + _msg);
    223258            }
     259            _context.statManager().addRateData("tunnel.participantLookupSuccess", 0, 0);
    224260        }
    225261    }
  • router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java

    r92ffea2 r20855c9  
    9191
    9292        _context.statManager().createRateStat("tunnel.corruptBuildReply", "", "Tunnels", new long[] { 24*60*60*1000l });
     93        ctx.statManager().createRateStat("tunnel.buildLookupSuccess", "Was a deferred lookup successful?", "Tunnels", new long[] { 60*60*1000 });
    9394       
    9495        _processor = new BuildMessageProcessor(ctx);
     
    105106   
    106107    private static final int MAX_HANDLE_AT_ONCE = 2;
    107     private static final int NEXT_HOP_LOOKUP_TIMEOUT = 5*1000;
     108    private static final int NEXT_HOP_LOOKUP_TIMEOUT = 15*1000;
    108109   
    109110    /**
     
    198199                    }
    199200                    if (_log.shouldLog(Log.INFO))
    200                         _log.info(msg.getUniqueId() + ": Peer " + peer.toBase64() + " replied with status " + howBad);
     201                        _log.info(msg.getUniqueId() + ": Peer " + peer + " replied with status " + howBad);
    201202
    202203                if (howBad == 0) {
     
    301302            if (_log.shouldLog(Log.DEBUG))
    302303                _log.debug("Request " + state.msg.getUniqueId() + "/" + req.readReceiveTunnelId() + "/" + req.readNextTunnelId()
    303                            + " handled, looking for the next peer " + nextPeer.toBase64());
    304             _context.netDb().lookupRouterInfo(nextPeer, new HandleReq(_context, state, req, nextPeer), new TimeoutReq(_context, state, req, nextPeer), NEXT_HOP_LOOKUP_TIMEOUT);
     304                           + " handled, looking for the next peer " + nextPeer);
     305            _context.netDb().lookupRouterInfo(nextPeer, new HandleReq(_context, state, req, nextPeer),
     306                                              new TimeoutReq(_context, state, req, nextPeer), NEXT_HOP_LOOKUP_TIMEOUT);
    305307            return -1;
    306308        } else {
     
    310312            if (_log.shouldLog(Log.DEBUG))
    311313                _log.debug("Request " + state.msg.getUniqueId() + " handled and we know the next peer "
    312                            + nextPeer.toBase64() + " after " + handleTime
     314                           + nextPeer + " after " + handleTime
    313315                           + "/" + decryptTime + "/" + lookupTime + "/" + timeSinceReceived);
    314316            return handleTime;
     
    345347        public void runJob() {
    346348            if (_log.shouldLog(Log.DEBUG))
    347                 _log.debug("Request " + _state.msg.getUniqueId() + " handled with a successful deferred lookup for the next peer " + _nextPeer.toBase64());
     349                _log.debug("Request " + _state.msg.getUniqueId() + " handled with a successful deferred lookup for the next peer " + _nextPeer);
    348350
    349351            RouterInfo ri = getContext().netDb().lookupRouterInfoLocally(_nextPeer);
    350             if (ri != null)
     352            if (ri != null) {
    351353                handleReq(ri, _state, _req, _nextPeer);
    352             else if (_log.shouldLog(Log.WARN))
    353                 _log.warn("Deferred successfully, but we couldnt find " + _nextPeer.toBase64() + "?");
     354                getContext().statManager().addRateData("tunnel.buildLookupSuccess", 1, 0);
     355            } else {
     356                if (_log.shouldLog(Log.WARN))
     357                    _log.warn("Deferred successfully, but we couldnt find " + _nextPeer);
     358                getContext().statManager().addRateData("tunnel.buildLookupSuccess", 0, 0);
     359            }
    354360        }
    355361    }
     
    368374        public void runJob() {
    369375            getContext().statManager().addRateData("tunnel.rejectTimeout", 1, 0);
     376            getContext().statManager().addRateData("tunnel.buildLookupSuccess", 0, 0);
    370377            // logging commented out so class can be static
    371378            //if (_log.shouldLog(Log.WARN))
     
    375382            // ???  should we blame the peer here?   getContext().profileManager().tunnelTimedOut(_nextPeer);
    376383            getContext().messageHistory().tunnelRejected(_state.fromHash, new TunnelId(_req.readReceiveTunnelId()), _nextPeer,
    377                                                          "rejected because we couldn't find " + _nextPeer.toBase64() + ": " +
     384                                                         "rejected because we couldn't find " + _nextPeer + ": " +
    378385                                                         _state.msg.getUniqueId() + "/" + _req.readNextTunnelId());
    379386        }
     
    525532            _log.debug("Responding to " + state.msg.getUniqueId() + "/" + ourId
    526533                       + " after " + recvDelay + "/" + proactiveDrops + " with " + response
    527                        + " from " + (state.fromHash != null ? state.fromHash.toBase64() :
    528                                      state.from != null ? state.from.calculateHash().toBase64() : "tunnel"));
     534                       + " from " + (state.fromHash != null ? state.fromHash :
     535                                     state.from != null ? state.from.calculateHash() : "tunnel"));
    529536
    530537        HopConfig cfg = null;
     
    601608
    602609        if (_log.shouldLog(Log.DEBUG))
    603             _log.debug("Read slot " + ourSlot + " containing our hop @ " + _context.routerHash().toBase64()
     610            _log.debug("Read slot " + ourSlot + " containing our hop @ " + _context.routerHash()
    604611                      + " accepted? " + response + " receiving on " + ourId
    605612                      + " sending to " + nextId
    606                       + " on " + nextPeer.toBase64()
     613                      + " on " + nextPeer
    607614                      + " inGW? " + isInGW + " outEnd? " + isOutEnd + " time difference " + (now-time)
    608615                      + " recvDelay " + recvDelay + " replyMessage " + req.readReplyMessageId()
    609                       + " replyKey " + req.readReplyKey().toBase64() + " replyIV " + Base64.encode(req.readReplyIV()));
     616                      + " replyKey " + req.readReplyKey() + " replyIV " + Base64.encode(req.readReplyIV()));
    610617
    611618        // now actually send the response
     
    673680            if (_log.shouldLog(Log.DEBUG))
    674681                _log.debug("Receive tunnel build message " + reqId + " from "
    675                            + (from != null ? from.calculateHash().toBase64() : fromHash != null ? fromHash.toBase64() : "tunnels")
     682                           + (from != null ? from.calculateHash() : fromHash != null ? fromHash : "tunnels")
    676683                           + ", found matching tunnel? " + (cfg != null));
    677684            if (cfg != null) {
     
    763770            if (_log.shouldLog(Log.DEBUG))
    764771                _log.debug("Receive tunnel build reply message " + receivedMessage.getUniqueId() + " from "
    765                            + (fromHash != null ? fromHash.toBase64() : from != null ? from.calculateHash().toBase64() : "a tunnel"));
     772                           + (fromHash != null ? fromHash : from != null ? from.calculateHash() : "a tunnel"));
    766773            handleReply(new BuildReplyMessageState(receivedMessage));
    767774            return _buildReplyMessageHandlerJob;
Note: See TracChangeset for help on using the changeset viewer.