Changeset 51e45d12


Ignore:
Timestamp:
Aug 21, 2014 11:55:03 AM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
915e003
Parents:
57650ef
Message:
  • Tunnels: Debug code and other cleanups
Location:
router/java/src/net/i2p/router/tunnel
Files:
5 edited

Legend:

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

    r57650ef r51e45d12  
    4949    private final String _name;
    5050   
     51    private static final boolean DEBUG = false;
     52
    5153    public BatchedPreprocessor(RouterContext ctx, String name) {
    5254        super(ctx);
     
    176178                        if (timingBuf != null)
    177179                            timingBuf.append(" sent " + cur);
    178                         notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed allocated");
     180                        if (DEBUG)
     181                            notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed allocated");
    179182                        _context.statManager().addRateData("tunnel.batchFragmentation", cur.getFragmentNumber() + 1);
    180183                        _context.statManager().addRateData("tunnel.writeDelay", cur.getLifetime(), cur.getData().length);
     
    185188                        if (timingBuf != null)
    186189                            timingBuf.append(" sent perfect fit " + cur).append(".");
    187                         notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), msg.getData().length, msg.getMessageIds(), "flushed tail, remaining: " + pending);
     190                        if (DEBUG)
     191                            notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), msg.getData().length, msg.getMessageIds(), "flushed tail, remaining: " + pending);
    188192                        _context.statManager().addRateData("tunnel.batchFragmentation", cur.getFragmentNumber() + 1);
    189193                        _context.statManager().addRateData("tunnel.writeDelay", cur.getLifetime(), cur.getData().length);
     
    235239                            break;
    236240                        pending.remove(0);
    237                         notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed remaining");
     241                        if (DEBUG)
     242                            notePreprocessing(cur.getMessageId(), cur.getFragmentNumber(), cur.getData().length, cur.getMessageIds(), "flushed remaining");
    238243                        _context.statManager().addRateData("tunnel.batchFragmentation", cur.getFragmentNumber() + 1);
    239244                        _context.statManager().addRateData("tunnel.writeDelay", cur.getLifetime(), cur.getData().length);
     
    384389
    385390        long msgId = sender.sendPreprocessed(preprocessed, rec);
    386         for (int i = 0; i < pending.size(); i++) {
    387             PendingGatewayMessage cur = pending.get(i);
    388             cur.addMessageId(msgId);
     391        if (DEBUG) {
     392            // creates a list in PGM
     393            for (int i = 0; i < pending.size(); i++) {
     394                PendingGatewayMessage cur = pending.get(i);
     395                cur.addMessageId(msgId);
     396            }
    389397        }
    390398        if (_log.shouldLog(Log.DEBUG))
  • router/java/src/net/i2p/router/tunnel/BatchedRouterPreprocessor.java

    r57650ef r51e45d12  
    1212 */
    1313class BatchedRouterPreprocessor extends BatchedPreprocessor {
    14     private TunnelCreatorConfig _config;
    15     protected HopConfig _hopConfig;
     14    private final TunnelCreatorConfig _config;
     15    protected final HopConfig _hopConfig;
    1616    private final long _sendDelay;
    1717   
     
    3535        super(ctx, getName(cfg));
    3636        _config = cfg;
     37        _hopConfig = null;
    3738        _sendDelay = initialSendDelay();
    3839    }
     
    4142    public BatchedRouterPreprocessor(RouterContext ctx, HopConfig cfg) {
    4243        super(ctx, getName(cfg));
     44        _config = null;
    4345        _hopConfig = cfg;
    4446        _sendDelay = initialSendDelay();
  • router/java/src/net/i2p/router/tunnel/OutboundSender.java

    r57650ef r51e45d12  
    1111 */
    1212class OutboundSender implements TunnelGateway.Sender {
    13     private final I2PAppContext _context;
    14     private final Log _log;
     13    //private final I2PAppContext _context;
     14    //private final Log _log;
    1515    private final TunnelCreatorConfig _config;
    1616    private final OutboundGatewayProcessor _processor;
     
    1919   
    2020    public OutboundSender(I2PAppContext ctx, TunnelCreatorConfig config) {
    21         _context = ctx;
    22         _log = ctx.logManager().getLog(OutboundSender.class);
     21        //_context = ctx;
     22        //_log = ctx.logManager().getLog(OutboundSender.class);
    2323        _config = config;
    24         _processor = new OutboundGatewayProcessor(_context, config);
     24        _processor = new OutboundGatewayProcessor(ctx, config);
    2525    }
    2626   
    2727    public long sendPreprocessed(byte[] preprocessed, TunnelGateway.Receiver receiver) {
    28         if (_log.shouldLog(Log.DEBUG))
    29             _log.debug("preprocessed data going out " + _config + ": " + Base64.encode(preprocessed));
     28        //if (_log.shouldLog(Log.DEBUG))
     29        //    _log.debug("preprocessed data going out " + _config + ": " + Base64.encode(preprocessed));
    3030        //if (USE_ENCRYPTION)
    3131            _processor.process(preprocessed, 0, preprocessed.length);
    32         if (_log.shouldLog(Log.DEBUG))
    33             _log.debug("after wrapping up the preprocessed data on " + _config);
     32        //if (_log.shouldLog(Log.DEBUG))
     33        //    _log.debug("after wrapping up the preprocessed data on " + _config);
    3434        long rv = receiver.receiveEncrypted(preprocessed);
    35         if (_log.shouldLog(Log.DEBUG))
    36             _log.debug("after receiving on " + _config + ": receiver = " + receiver);
     35        //if (_log.shouldLog(Log.DEBUG))
     36        //    _log.debug("after receiving on " + _config + ": receiver = " + receiver);
    3737        return rv;
    3838    }
  • router/java/src/net/i2p/router/tunnel/TrivialPreprocessor.java

    r57650ef r51e45d12  
    1919 * See FragmentHandler Javadoc for tunnel message fragment format
    2020 */
    21 class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor {
     21abstract class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor {
    2222    protected final RouterContext _context;
    2323    protected final Log _log;
     
    4949     */
    5050    public boolean preprocessQueue(List<PendingGatewayMessage> pending, TunnelGateway.Sender sender, TunnelGateway.Receiver rec) {
    51         throw new IllegalArgumentException("unused, right?");
     51        throw new UnsupportedOperationException("unused, right?");
    5252    }
    5353   
     
    266266     *  call getInstructionAugmentationSize() for that.
    267267     */
    268     protected int getInstructionsSize(PendingGatewayMessage msg) {
     268    protected static int getInstructionsSize(PendingGatewayMessage msg) {
    269269        if (msg.getFragmentNumber() > 0)
    270270            return 7;
     
    284284   
    285285    /** @return 0 or 4 */
    286     protected int getInstructionAugmentationSize(PendingGatewayMessage msg, int offset, int instructionsSize) {
     286    protected static int getInstructionAugmentationSize(PendingGatewayMessage msg, int offset, int instructionsSize) {
    287287        int payloadLength = msg.getData().length - msg.getOffset();
    288288        if (offset + payloadLength + instructionsSize + IV_SIZE + 1 + 4 > PREPROCESSED_SIZE) {
  • router/java/src/net/i2p/router/tunnel/TunnelGateway.java

    r57650ef r51e45d12  
    3434 * Unused directly - see PumpedTunnelGateway, ThrottledPumpedTunnelGateway, and TunnelGatewayZeroHop overrides.
    3535 */
    36 class TunnelGateway {
     36abstract class TunnelGateway {
    3737    protected final RouterContext _context;
    3838    protected final Log _log;
Note: See TracChangeset for help on using the changeset viewer.