Changeset a0418be


Ignore:
Timestamp:
Sep 1, 2012 8:47:22 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f44eeaf
Parents:
5eff26e
Message:

OutNetMessage?:

  • Centralize priority definitions
  • Raise netdb store and reply priority

GarlicMessage?:

Location:
router/java/src/net/i2p/router
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/OutNetMessage.java

    r5eff26e ra0418be  
    5959    private Object _preparationBuf;
    6060   
     61    /**
     62     *  Priorities, higher is higher priority.
     63     *  @since 0.9.3
     64     */
     65    public static final int PRIORITY_HIGHEST = 1000;
     66    public static final int PRIORITY_MY_BUILD_REQUEST = 500;
     67    public static final int PRIORITY_MY_NETDB_LOOKUP = 500;
     68    public static final int PRIORITY_MY_NETDB_STORE = 400;
     69    public static final int PRIORITY_MY_DATA = 400;
     70    public static final int PRIORITY_MY_NETDB_STORE_LOW = 300;
     71    public static final int PRIORITY_HIS_BUILD_REQUEST = 300;
     72    public static final int PRIORITY_BUILD_REPLY = 300;
     73    public static final int PRIORITY_NETDB_REPLY = 300;
     74    public static final int PRIORITY_HIS_NETDB_STORE = 200;
     75    public static final int PRIORITY_NETDB_FLOOD = 200;
     76    public static final int PRIORITY_PARTICIPATING = 200;
     77    public static final int PRIORITY_NETDB_EXPLORE = 100;
     78    public static final int PRIORITY_NETDB_HARVEST = 100;
     79    public static final int PRIORITY_LOWEST = 100;
     80
    6181    public OutNetMessage(RouterContext context) {
    6282        _context = context;
  • router/java/src/net/i2p/router/message/GarlicMessageHandler.java

    r5eff26e ra0418be  
    2020 * HandlerJobBuilder to build jobs to handle GarlicMessages
    2121 *
     22 * This is essentially unused, as InNetMessagePool short circuits tunnel messages,
     23 * and the garlics are handled in InboundMessageDistributor.
     24 * Unless we get a garlic message not down a tunnel?
    2225 */
    2326public class GarlicMessageHandler implements HandlerJobBuilder {
  • router/java/src/net/i2p/router/message/GarlicMessageReceiver.java

    r5eff26e ra0418be  
    9898    private void handleClove(GarlicClove clove) {
    9999        if (!isValid(clove)) {
    100             if (_log.shouldLog(Log.DEBUG))
    101                 _log.warn("Invalid clove " + clove);
     100            //if (_log.shouldLog(Log.WARN))
     101            //    _log.warn("Invalid clove " + clove);
    102102            return;
    103103        }
     104        //if (_log.shouldLog(Log.DEBUG))
     105        //    _log.debug("valid clove " + clove);
    104106        _receiver.handleClove(clove.getInstructions(), clove.getData());
    105107    }
  • router/java/src/net/i2p/router/message/HandleGarlicMessageJob.java

    r5eff26e ra0418be  
    1616import net.i2p.data.i2np.TunnelGatewayMessage;
    1717import net.i2p.router.JobImpl;
     18import net.i2p.router.OutNetMessage;
    1819import net.i2p.router.RouterContext;
    1920import net.i2p.util.Log;
     
    2526 * need to be. soon)
    2627 *
     28 * This is essentially unused, as InNetMessagePool short circuits tunnel messages,
     29 * and the garlics are handled in InboundMessageDistributor.
     30 * Unless we get a garlic message not down a tunnel?
    2731 */
    2832class HandleGarlicMessageJob extends JobImpl implements GarlicMessageReceiver.CloveReceiver {
     
    3539    //private GarlicMessageParser _parser;
    3640   
     41    private final static int ROUTER_PRIORITY = OutNetMessage.PRIORITY_LOWEST;
     42    private final static int TUNNEL_PRIORITY = OutNetMessage.PRIORITY_LOWEST;
     43
    3744    /**
    3845     *  @param from ignored
     
    4350        _log = context.logManager().getLog(HandleGarlicMessageJob.class);
    4451        getContext().statManager().createRateStat("crypto.garlic.decryptFail", "How often garlic messages are undecryptable", "Encryption", new long[] { 5*60*1000, 60*60*1000, 24*60*60*1000 });
    45         if (_log.shouldLog(Log.DEBUG))
    46             _log.debug("New handle garlicMessageJob called w/ message from [" + from + "]", new Exception("Debug"));
     52        if (_log.shouldLog(Log.WARN))
     53            _log.warn("Garlic Message not down a tunnel??? from [" + from + "]", new Exception("I did it"));
    4754        _message = msg;
    4855        //_from = from;
     
    7986                    if (_log.shouldLog(Log.DEBUG))
    8087                        _log.debug("router delivery instructions targetting "
    81                                    + instructions.getRouter().toBase64().substring(0,4));
     88                                   + instructions.getRouter().toBase64().substring(0,4) + " for " + data);
    8289                    SendMessageDirectJob j = new SendMessageDirectJob(getContext(), data,
    8390                                                                      instructions.getRouter(),
    84                                                                       10*1000, 100);
     91                                                                      10*1000, ROUTER_PRIORITY);
    8592                    // run it inline (adds to the outNetPool if it has the router info, otherwise queue a lookup)
    8693                    j.runJob();
     
    93100                gw.setTunnelId(instructions.getTunnelId());
    94101                gw.setMessageExpiration(data.getMessageExpiration());
     102                if (_log.shouldLog(Log.DEBUG))
     103                    _log.debug("tunnel delivery instructions targetting "
     104                               + instructions.getRouter().toBase64().substring(0,4) + " for " + data);
    95105                SendMessageDirectJob job = new SendMessageDirectJob(getContext(), gw,
    96106                                                                    instructions.getRouter(),
    97                                                                     10*1000, 100);
     107                                                                    10*1000, TUNNEL_PRIORITY);
    98108                // run it inline (adds to the outNetPool if it has the router info, otherwise queue a lookup)
    99109                job.runJob();
  • router/java/src/net/i2p/router/networkdb/HandleDatabaseLookupMessageJob.java

    r5eff26e ra0418be  
    2525import net.i2p.router.Job;
    2626import net.i2p.router.JobImpl;
     27import net.i2p.router.OutNetMessage;
    2728import net.i2p.router.Router;
    2829import net.i2p.router.RouterContext;
     
    4142    private final static int CLOSENESS_THRESHOLD = 8; // FNDF.MAX_TO_FLOOD + 1
    4243    private final static int REPLY_TIMEOUT = 60*1000;
    43     private final static int MESSAGE_PRIORITY = 300;
     44    private final static int MESSAGE_PRIORITY = OutNetMessage.PRIORITY_NETDB_REPLY;
    4445   
    4546    /**
     
    284285            m.setMessageExpiration(message.getMessageExpiration());
    285286            m.setTunnelId(replyTunnel);
    286             SendMessageDirectJob j = new SendMessageDirectJob(getContext(), m, toPeer, 10*1000, 100);
     287            SendMessageDirectJob j = new SendMessageDirectJob(getContext(), m, toPeer, 10*1000, MESSAGE_PRIORITY);
    287288            j.runJob();
    288289            //getContext().jobQueue().addJob(j);
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java

    r5eff26e ra0418be  
    4141     */
    4242    private static final int MAX_TO_FLOOD = 4;
     43   
     44    private static final int FLOOD_PRIORITY = OutNetMessage.PRIORITY_NETDB_FLOOD;
     45    private static final int FLOOD_TIMEOUT = 30*1000;
    4346   
    4447    public FloodfillNetworkDatabaseFacade(RouterContext context) {
     
    225228    }
    226229
    227     private static final int FLOOD_PRIORITY = 200;
    228     private static final int FLOOD_TIMEOUT = 30*1000;
    229    
    230230    @Override
    231231    protected PeerSelector createPeerSelector() { return new FloodfillPeerSelector(_context); }
  • router/java/src/net/i2p/router/networkdb/kademlia/HarvesterJob.java

    r5eff26e ra0418be  
    1212import net.i2p.data.i2np.DatabaseLookupMessage;
    1313import net.i2p.router.JobImpl;
     14import net.i2p.router.OutNetMessage;
    1415import net.i2p.router.RouterContext;
    1516import net.i2p.router.TunnelInfo;
     
    4041    private static final int MAX_PER_RUN = 5;
    4142    /** background job, who cares */
    42     private static final int PRIORITY = 100;
     43    private static final int PRIORITY = OutNetMessage.PRIORITY_NETDB_HARVEST;
    4344   
    4445    public static final String PROP_ENABLED = "netDb.shouldHarvest";
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java

    r5eff26e ra0418be  
    2626import net.i2p.router.Job;
    2727import net.i2p.router.JobImpl;
     28import net.i2p.router.OutNetMessage;
    2829import net.i2p.router.RouterContext;
    2930import net.i2p.router.TunnelInfo;
     
    7980     */
    8081    private static final long REQUEUE_DELAY = 1000;
     82
     83    // TODO pass to the tunnel dispatcher
     84    //private final static int LOOKUP_PRIORITY = OutNetMessage.PRIORITY_MY_NETDB_LOOKUP;
     85    //private final static int STORE_PRIORITY = OutNetMessage.PRIORITY_HIS_NETDB_STORE;
    8186   
    8287    /**
     
    446451            _floodfillSearchesOutstanding++;
    447452        getContext().messageRegistry().registerPending(sel, reply, new FailedJob(getContext(), router), timeout);
     453        // TODO pass a priority to the dispatcher
    448454        getContext().tunnelDispatcher().dispatchOutbound(msg, outTunnelId, to);
    449455    }
     
    653659            if (_log.shouldLog(Log.DEBUG))
    654660                _log.debug("resending leaseSet out to " + to + " through " + outTunnel + ": " + msg);
     661            // TODO pass a priority to the dispatcher
    655662            getContext().tunnelDispatcher().dispatchOutbound(msg, outTunnel.getSendTunnelId(0), null, to);
    656663            return true;
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    r5eff26e ra0418be  
    4444    private final static int PARALLELIZATION = 4; // how many sent at a time
    4545    private final static int REDUNDANCY = 4; // we want the data sent to 6 peers
    46     private final static int STORE_PRIORITY = 100;
     46    private final static int STORE_PRIORITY = OutNetMessage.PRIORITY_MY_NETDB_STORE;
    4747   
    4848    /**
  • router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java

    r5eff26e ra0418be  
    138138    public static final int MAX_MSG_SIZE = BUFFER_SIZE - (2 + 4);
    139139   
     140    private static final int PRIORITY = OutNetMessage.PRIORITY_MY_NETDB_STORE_LOW;
     141
    140142    /**
    141143     * Create an inbound connected (though not established) NTCP connection
     
    398400        dsm.setEntry(_context.router().getRouterInfo());
    399401        infoMsg.setMessage(dsm);
    400         infoMsg.setPriority(100);
     402        infoMsg.setPriority(PRIORITY);
    401403        RouterInfo target = _context.netDb().lookupRouterInfoLocally(_remotePeer.calculateHash());
    402404        if (target != null) {
  • router/java/src/net/i2p/router/tunnel/InboundGatewayReceiver.java

    r5eff26e ra0418be  
    1616   
    1717    private static final long MAX_LOOKUP_TIME = 15*1000;
     18    private static final int PRIORITY = OutNetMessage.PRIORITY_PARTICIPATING;
    1819
    1920    public InboundGatewayReceiver(RouterContext ctx, HopConfig cfg) {
     
    5960        out.setTarget(_target);
    6061        out.setExpiration(msg.getMessageExpiration());
    61         out.setPriority(200);
     62        out.setPriority(PRIORITY);
    6263        _context.outNetMessagePool().add(out);
    6364        return msg.getUniqueId();
  • router/java/src/net/i2p/router/tunnel/OutboundReceiver.java

    r5eff26e ra0418be  
    2121   
    2222    private static final long MAX_LOOKUP_TIME = 15*1000;
     23    private static final int PRIORITY = OutNetMessage.PRIORITY_MY_DATA;
    2324
    2425    public OutboundReceiver(RouterContext ctx, TunnelCreatorConfig cfg) {
     
    6263        m.setExpiration(msg.getMessageExpiration());
    6364        m.setTarget(ri);
    64         m.setPriority(400);
     65        m.setPriority(PRIORITY);
    6566        _context.outNetMessagePool().add(m);
    6667        _config.incrementProcessedMessages();
  • router/java/src/net/i2p/router/tunnel/TunnelParticipant.java

    r5eff26e ra0418be  
    3131    /** for next hop when a tunnel is first created */
    3232    private static final long LONG_MAX_LOOKUP_TIME = 30*1000;
     33    private static final int PRIORITY = OutNetMessage.PRIORITY_PARTICIPATING;
    3334
    3435    /** not an inbound endpoint */
     
    197198        m.setExpiration(msg.getMessageExpiration());
    198199        m.setTarget(ri);
    199         m.setPriority(200);
     200        m.setPriority(PRIORITY);
    200201        if (_log.shouldLog(Log.DEBUG))
    201202            _log.debug("Forward on from " + _config + ": " + msg);
  • router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java

    r5eff26e ra0418be  
    6262
    6363    private static final int NEXT_HOP_LOOKUP_TIMEOUT = 15*1000;
     64    private static final int PRIORITY = OutNetMessage.PRIORITY_BUILD_REPLY;
    6465   
    6566    /**
     
    690691            msg.setMessage(state.msg);
    691692            msg.setExpiration(state.msg.getMessageExpiration());
    692             msg.setPriority(300);
     693            msg.setPriority(PRIORITY);
    693694            msg.setTarget(nextPeerInfo);
    694695            if (response == 0)
     
    723724                outMsg.setExpiration(m.getMessageExpiration());
    724725                outMsg.setMessage(m);
    725                 outMsg.setPriority(300);
     726                outMsg.setPriority(PRIORITY);
    726727                outMsg.setTarget(nextPeerInfo);
    727728                if (response == 0)
  • router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java

    r5eff26e ra0418be  
    3030            ORDER.add(Integer.valueOf(i));
    3131    }
    32     private static final int PRIORITY = 500;
     32
     33    private static final int PRIORITY = OutNetMessage.PRIORITY_MY_BUILD_REQUEST;
     34
    3335    /**
    3436     *  At 10 seconds, we were receiving about 20% of replies after expiration
Note: See TracChangeset for help on using the changeset viewer.