Changeset 896ba7a


Ignore:
Timestamp:
Aug 27, 2008 7:58:13 PM (13 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c321251
Parents:
2c48831
Message:
  • Floodfill Peer Selector: Prefer already-connected floodfill peer for direct RouterInfo? stores, to mimimize floodfill connections
  • Peer Profiles: Classify connected peers as "active", which will help improve the fast pool
  • Transport Manager: Add isEstablished(Hash)
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r2c48831 r896ba7a  
     12008-08-27 zzz
     2    * Floodfill Peer Selector: Prefer already-connected floodfill
     3      peer for direct RouterInfo stores, to mimimize floodfill
     4      connections
     5    * Peer Profiles: Classify connected peers as "active",
     6      which will help improve the fast pool
     7    * Transport Manager: Add isEstablished(Hash)
     8    * NTCP: Reduce max idle time from 20m to 15m
     9    * NetDb stats: Post-0.6.3 clean up
     10
    111* 2008-08-24  0.6.3 released
    212
  • router/java/src/net/i2p/router/CommSystemFacade.java

    r2c48831 r896ba7a  
    5757    public boolean isBacklogged(Hash dest) { return false; }
    5858    public boolean wasUnreachable(Hash dest) { return false; }
     59    public boolean isEstablished(Hash dest) { return false; }
    5960   
    6061    /**
  • router/java/src/net/i2p/router/RouterVersion.java

    r2c48831 r896ba7a  
    1818    public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
    1919    public final static String VERSION = "0.6.3";
    20     public final static long BUILD = 0;
     20    public final static long BUILD = 1;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java

    r2c48831 r896ba7a  
    3232     * @return List of Hash for the peers selected
    3333     */
     34    public List selectMostReliablePeers(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) {
     35        return selectNearestExplicitThin(key, maxNumRouters, peersToIgnore, kbuckets, true);
     36    }
     37
    3438    public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) {
     39        return selectNearestExplicitThin(key, maxNumRouters, peersToIgnore, kbuckets, false);
     40    }
     41
     42    public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets, boolean preferConnected) {
    3543        if (peersToIgnore == null)
    3644            peersToIgnore = new HashSet(1);
     
    3947        if (kbuckets == null) return new ArrayList();
    4048        kbuckets.getAll(matches);
    41         List rv = matches.get(maxNumRouters);
     49        List rv = matches.get(maxNumRouters, preferConnected);
    4250        if (_log.shouldLog(Log.DEBUG))
    4351            _log.debug("Searching for " + maxNumRouters + " peers close to " + key + ": "
     
    101109        /** get the first $howMany entries matching */
    102110        public List get(int howMany) {
     111            return get(howMany, false);
     112        }
     113
     114        public List get(int howMany, boolean preferConnected) {
    103115            Collections.shuffle(_floodfillMatches, _context.random());
    104116            List rv = new ArrayList(howMany);
    105117            List badff = new ArrayList(howMany);
     118            List unconnectedff = new ArrayList(howMany);
    106119            int found = 0;
    107120            long now = _context.clock().now();
     
    122135                        if (_log.shouldLog(Log.DEBUG))
    123136                            _log.debug("Skipping, recent failed send: " + entry);
     137                    } else if (preferConnected && !_context.commSystem().isEstablished(entry)) {
     138                        unconnectedff.add(entry);
     139                        if (_log.shouldLog(Log.DEBUG))
     140                            _log.debug("Skipping, unconnected: " + entry);
    124141                    } else {
    125142                        rv.add(entry);
     
    127144                    }
    128145                }
     146            }
     147            // Put the unconnected floodfills after the connected floodfills
     148            for (int i = 0; found < howMany && i < unconnectedff.size(); i++) {
     149                rv.add(unconnectedff.get(i));
     150                found++;
    129151            }
    130152            // Put the "bad" floodfills at the end of the floodfills but before the kademlias
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    r2c48831 r896ba7a  
    142142            toCheck = getParallelization();
    143143
    144         List closestHashes = getClosestRouters(_state.getTarget(), toCheck, _state.getAttempted());
     144        // We are going to send the RouterInfo directly, rather than through a lease,
     145        // so select a floodfill peer we are already connected to.
     146        // This will help minimize active connections for floodfill peers and allow
     147        // the network to scale.
     148        // Perhaps the ultimate solution is to send RouterInfos through a lease also.
     149        List closestHashes;
     150        if (_state.getData() instanceof RouterInfo)
     151            closestHashes = getMostReliableRouters(_state.getTarget(), toCheck, _state.getAttempted());
     152        else
     153            closestHashes = getClosestRouters(_state.getTarget(), toCheck, _state.getAttempted());
    145154        if ( (closestHashes == null) || (closestHashes.size() <= 0) ) {
    146155            if (_state.getPending().size() <= 0) {
     
    217226    }
    218227
     228    private List getMostReliableRouters(Hash key, int numClosest, Set alreadyChecked) {
     229        Hash rkey = getContext().routingKeyGenerator().getRoutingKey(key);
     230        KBucketSet ks = _facade.getKBuckets();
     231        if (ks == null) return new ArrayList();
     232        return _peerSelector.selectMostReliablePeers(rkey, numClosest, alreadyChecked, ks);
     233    }
     234
    219235    /**
    220236     * Send a store to the given peer through a garlic route, including a reply
  • router/java/src/net/i2p/router/peermanager/PeerProfile.java

    r2c48831 r896ba7a  
    9595     * Is this peer active at the moment (sending/receiving messages within the
    9696     * given period?)
     97     * Also mark active if it is connected, as this will tend to encourage use
     98     * of already-connected peers.
    9799     */
    98100    public boolean getIsActive(long period) {
     
    100102             (getSendSuccessSize().getRate(period).getLastEventCount() > 0) ||
    101103             (getReceiveSize().getRate(period).getCurrentEventCount() > 0) ||
    102              (getReceiveSize().getRate(period).getLastEventCount() > 0) )
     104             (getReceiveSize().getRate(period).getLastEventCount() > 0) ||
     105             _context.commSystem().isEstablished(_peer) )
    103106            return true;
    104107        else
  • router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java

    r2c48831 r896ba7a  
    124124    public boolean isBacklogged(Hash dest) {
    125125        return _manager.isBacklogged(dest);
     126    }
     127   
     128    public boolean isEstablished(Hash dest) {
     129        return _manager.isEstablished(dest);
    126130    }
    127131   
  • router/java/src/net/i2p/router/transport/Transport.java

    r2c48831 r896ba7a  
    5151   
    5252    public boolean isUnreachable(Hash peer);
     53    public boolean isEstablished(Hash peer);
    5354}
  • router/java/src/net/i2p/router/transport/TransportImpl.java

    r2c48831 r896ba7a  
    396396    public void recheckReachability() {}
    397397    public boolean isBacklogged(Hash dest) { return false; }
     398    public boolean isEstablished(Hash dest) { return false; }
    398399   
    399400    private static final long UNREACHABLE_PERIOD = 5*60*1000;
  • router/java/src/net/i2p/router/transport/TransportManager.java

    r2c48831 r896ba7a  
    204204    }   
    205205   
     206    public boolean isEstablished(Hash dest) {
     207        for (int i = 0; i < _transports.size(); i++) {
     208            Transport t = (Transport)_transports.get(i);
     209            if (t.isEstablished(dest))
     210                return true;
     211        }
     212        return false;
     213    }   
     214   
    206215    /**
    207216     * Was the peer UNreachable (outbound only) on any transport,
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r2c48831 r896ba7a  
    337337
    338338    private boolean isEstablished(RouterIdentity peer) {
     339        return isEstablished(peer.calculateHash());
     340    }
     341   
     342    public boolean isEstablished(Hash dest) {
    339343        synchronized (_conLock) {
    340             NTCPConnection con = (NTCPConnection)_conByIdent.get(peer.calculateHash());
     344            NTCPConnection con = (NTCPConnection)_conByIdent.get(dest);
    341345            return (con != null) && con.isEstablished() && !con.isClosed();
    342346        }
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r2c48831 r896ba7a  
    12671267    }
    12681268   
     1269    public boolean isEstablished(Hash dest) {
     1270        return getPeerState(dest) != null;
     1271    }
     1272
    12691273    /**
    12701274     * Return our peer clock skews on this transport.
Note: See TracChangeset for help on using the changeset viewer.