Changeset 4426cc3


Ignore:
Timestamp:
May 21, 2009 12:34:10 AM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d927f8b
Parents:
b1465b7
Message:
Location:
router/java/src/net/i2p/router
Files:
4 edited

Legend:

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

    rb1465b7 r4426cc3  
    2828    public TunnelInfo selectOutboundTunnel() { return null; }
    2929    public TunnelInfo selectOutboundTunnel(Hash destination) { return null; }
    30     public boolean isInUse(Hash peer) { return false; }
    3130    public boolean isValidTunnel(Hash client, TunnelInfo tunnel) { return false; }
    3231    public int getParticipatingCount() { return 0; }
  • router/java/src/net/i2p/router/TunnelManagerFacade.java

    rb1465b7 r4426cc3  
    3636    TunnelInfo selectOutboundTunnel(Hash destination);
    3737   
    38     /**
    39      * True if the peer currently part of a tunnel
    40      *
    41      */
    42     boolean isInUse(Hash peer);
    43 
    4438    /** Is a tunnel a valid member of the pool? */
    4539    public boolean isValidTunnel(Hash client, TunnelInfo tunnel);
  • router/java/src/net/i2p/router/networkdb/kademlia/ExpireRoutersJob.java

    rb1465b7 r4426cc3  
    99 */
    1010
     11import java.util.Collections;
    1112import java.util.Date;
    1213import java.util.HashSet;
     
    2122
    2223/**
    23  * Go through the routing table pick routers that are performing poorly or
    24  * is out of date, but don't expire routers we're actively tunneling through.
    25  * If a peer is performing worse than some threshold (via profile.rankLiveliness)
    26  * drop it and don't ask any questions.  If a peer isn't ranked really poorly, but
    27  * we just haven't heard from it in a while, drop it and add it to the set of
    28  * keys we want the netDb to explore.
     24 * Go through the routing table pick routers that are
     25 * is out of date, but don't expire routers we're actively connected to.
     26 *
     27 * We could in the future use profile data, netdb total size, a Kademlia XOR distance,
     28 * or other criteria to minimize netdb size, but for now we just use _facade's
     29 * validate(), which is a sliding expriation based on netdb size.
    2930 *
    3031 */
     
    3334    private KademliaNetworkDatabaseFacade _facade;
    3435   
     36    /** rerun fairly often, so the fails don't queue up too many netdb searches at once */
    3537    private final static long RERUN_DELAY_MS = 120*1000;
    36     /**
    37      * If a routerInfo structure isn't updated within an hour, drop it
    38      * and search for a later version.  This value should be large enough
    39      * to deal with the Router.CLOCK_FUDGE_FACTOR.
    40      */
    41     public final static long EXPIRE_DELAY = 60*60*1000;
    4238   
    4339    public ExpireRoutersJob(RouterContext ctx, KademliaNetworkDatabaseFacade facade) {
     
    6359    /**
    6460     * Run through all of the known peers and pick ones that have really old
    65      * routerInfo publish dates, excluding ones that are in use by some tunnels,
     61     * routerInfo publish dates, excluding ones that we are connected to,
    6662     * so that they can be failed & queued for searching
    6763     *
     64     * @return nothing for now
    6865     */
    6966    private Set selectKeysToExpire() {
    70         Set possible = getNotInUse();
    71         Set expiring = new HashSet(16);
    72        
    73         for (Iterator iter = possible.iterator(); iter.hasNext(); ) {
     67        for (Iterator iter = _facade.getAllRouters().iterator(); iter.hasNext(); ) {
    7468            Hash key = (Hash)iter.next();
    75             RouterInfo ri = _facade.lookupRouterInfoLocally(key);
    76             if (ri != null) {
    77                 if (!ri.isCurrent(EXPIRE_DELAY)) {
    78                     if (_log.shouldLog(Log.INFO))
    79                         _log.info("Expiring RouterInfo for " + key.toBase64() + " [published on " + new Date(ri.getPublished()) + "]");
    80                     expiring.add(key);
    81                 } else {
    82                     if (_log.shouldLog(Log.DEBUG))
    83                         _log.debug("Not expiring routerInfo for " + key.toBase64() + " [published on " + new Date(ri.getPublished()) + "]");
    84                 }
     69            // Don't expire anybody we are connected to
     70            if (!getContext().commSystem().isEstablished(key)) {
     71                // This does a _facade.validate() and fail() which is sufficient...
     72                // no need to impose our own expiration here.
     73                // One issue is this will queue a ton of floodfill queries the first time it is run
     74                // after the 1h router startup grace period.
     75                RouterInfo ri = _facade.lookupRouterInfoLocally(key);
    8576            }
    8677        }
    8778       
    88         return expiring;
    89     }
    90    
    91     /** all peers not in use by tunnels */
    92     private Set getNotInUse() {
    93         Set possible = new HashSet(16);
    94         for (Iterator iter = _facade.getAllRouters().iterator(); iter.hasNext(); ) {
    95             Hash peer = (Hash)iter.next();
    96             if (!getContext().tunnelManager().isInUse(peer)) {
    97                 possible.add(peer);
    98             } else {
    99                 if (_log.shouldLog(Log.DEBUG))
    100                     _log.debug("Peer is in use: " + peer.toBase64());
    101             }
    102         }
    103         return possible;
     79        // let _facade do all the work for now
     80        return Collections.EMPTY_SET;
    10481    }
    10582}
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java

    rb1465b7 r4426cc3  
    195195    public int getParticipatingCount() { return _context.tunnelDispatcher().getParticipatingCount(); }
    196196    public long getLastParticipatingExpiration() { return _context.tunnelDispatcher().getLastParticipatingExpiration(); }
    197    
    198     public boolean isInUse(Hash peer) {
    199         // this lets peers that are in our tunnels expire (forcing us to refetch them)
    200         // if the info is old
    201         //!! no, dont.  bad.
    202         return true;
    203     }
    204197   
    205198    public boolean isValidTunnel(Hash client, TunnelInfo tunnel) {
     
    572565            List pending = outPool.listPending();
    573566            if (pending.size() > 0)
    574                 out.write("In progress: " + pending.size() + " outbound<br />\n");
     567                out.write("Build in progress: " + pending.size() + " outbound<br />\n");
    575568            live += pending.size();
    576569        }
Note: See TracChangeset for help on using the changeset viewer.