Changeset 4884148


Ignore:
Timestamp:
Dec 17, 2011 2:02:01 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
18b8ddc
Parents:
bf45e31
Message:

stalls in the transports during profile reorg

  • Make isFailing() non-blocking since it's always false
Location:
router/java/src/net/i2p/router
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/peermanager/ProfileManagerImpl.java

    rbf45e31 r4884148  
    2222import net.i2p.util.Log;
    2323
     24/**
     25 *  Methods to update profiles.
     26 *  Unless otherwise noted, methods are blocking on the reorganize lock.
     27 */
    2428public class ProfileManagerImpl implements ProfileManager {
    2529    private final Log _log;
     
    3438     * Note that it took msToSend to send a message of size bytesSent to the peer over the transport.
    3539     * This should only be called if the transport considered the send successful.
    36      *
     40     * Non-blocking. Will not update the profile if we can't get the lock.
    3741     */
    3842    public void messageSent(Hash peer, String transport, long msToSend, long bytesSent) {
    39         PeerProfile data = getProfile(peer);
     43        PeerProfile data = getProfileNonblocking(peer);
    4044        if (data == null) return;
    4145        data.setLastSendSuccessful(_context.clock().now());
     
    4448   
    4549    /**
    46      * Note that the router failed to send a message to the peer over the transport specified
    47      *
     50     * Note that the router failed to send a message to the peer over the transport specified.
     51     * Non-blocking. Will not update the profile if we can't get the lock.
    4852     */
    4953    public void messageFailed(Hash peer, String transport) {
    50         PeerProfile data = getProfile(peer);
     54        PeerProfile data = getProfileNonblocking(peer);
    5155        if (data == null) return;
    5256        data.setLastSendFailed(_context.clock().now());
     
    5458   
    5559    /**
    56      * Note that the router failed to send a message to the peer over any transport
    57      *
     60     * Note that the router failed to send a message to the peer over any transport.
     61     * Non-blocking. Will not update the profile if we can't get the lock.
    5862     */
    5963    public void messageFailed(Hash peer) {
    60         PeerProfile data = getProfile(peer);
     64        PeerProfile data = getProfileNonblocking(peer);
    6165        if (data == null) return;
    6266        data.setLastSendFailed(_context.clock().now());
     
    7175            _log.info("Comm error occurred for peer " + peer.toBase64(), new Exception("Comm error"));
    7276        PeerProfile data = getProfile(peer);
    73         if (data == null) return;
     77        //if (data == null) return;
    7478        data.setLastSendFailed(_context.clock().now());
    7579    }
     
    8185    public void tunnelJoined(Hash peer, long responseTimeMs) {
    8286        PeerProfile data = getProfile(peer);
    83         if (data == null) return;
     87        //if (data == null) return;
    8488        data.getTunnelCreateResponseTime().addData(responseTimeMs, responseTimeMs);
    8589        data.setLastHeardFrom(_context.clock().now());
     
    96100    public void tunnelRejected(Hash peer, long responseTimeMs, int severity) {
    97101        PeerProfile data = getProfile(peer);
    98         if (data == null) return;
     102        //if (data == null) return;
    99103        data.setLastHeardFrom(_context.clock().now());
    100104        data.getTunnelHistory().incrementRejected(severity);
     
    109113    public void tunnelTimedOut(Hash peer) {
    110114        PeerProfile data = getProfile(peer);
    111         if (data == null) return;
     115        //if (data == null) return;
    112116        data.getTunnelHistory().incrementRejected(TunnelHistory.TUNNEL_REJECT_BANDWIDTH);
    113117    }
     
    120124    public void tunnelTestSucceeded(Hash peer, long responseTimeMs) {
    121125        PeerProfile data = getProfile(peer);
    122         if (data == null) return;
     126        //if (data == null) return;
    123127        data.updateTunnelTestTimeAverage(responseTimeMs);
    124128        data.getTunnelTestResponseTime().addData(responseTimeMs, responseTimeMs);
     
    129133            return;
    130134        PeerProfile data = getProfile(peer);
    131         if (data != null)
     135        //if (data != null)
    132136            data.dataPushed(size); // ignore rtt, as we are averaging over a minute
    133137    }
     138
    134139    public void tunnelDataPushed1m(Hash peer, int size) {
    135140        if (_context.routerHash().equals(peer))
    136141            return;
    137142        PeerProfile data = getProfile(peer);
    138         if (data != null)
     143        //if (data != null)
    139144            data.dataPushed1m(size);
    140145    }
     
    145150            return;
    146151        PeerProfile data = getProfile(peer);
    147         if (data != null)
     152        //if (data != null)
    148153            data.tunnelDataTransferred(size);
    149154    }
     
    163168    public void tunnelFailed(Hash peer, int pct) {
    164169        PeerProfile data = getProfile(peer);
    165         if (data == null) return;
     170        //if (data == null) return;
    166171        data.setLastHeardFrom(_context.clock().now());
    167172        data.getTunnelHistory().incrementFailed(pct);
     
    175180    public void dbLookupSuccessful(Hash peer, long responseTimeMs) {
    176181        PeerProfile data = getProfile(peer);
    177         if (data == null) return;
     182        //if (data == null) return;
    178183        data.setLastHeardFrom(_context.clock().now());
    179184        if (!data.getIsExpandedDB())
     
    192197    public void dbLookupFailed(Hash peer) {
    193198        PeerProfile data = getProfile(peer);
    194         if (data == null) return;
     199        //if (data == null) return;
    195200        if (!data.getIsExpandedDB())
    196201            data.expandDBProfile();
     
    209214    public void dbLookupReply(Hash peer, int newPeers, int oldPeers, int invalid, int duplicate, long responseTimeMs) {
    210215        PeerProfile data = getProfile(peer);
    211         if (data == null) return;
     216        //if (data == null) return;
    212217        data.setLastHeardFrom(_context.clock().now());
    213218        if (!data.getIsExpandedDB())
     
    225230    public void dbLookupReceived(Hash peer) {
    226231        PeerProfile data = getProfile(peer);
    227         if (data == null) return;
     232        //if (data == null) return;
    228233        data.setLastHeardFrom(_context.clock().now());
    229234        if (!data.getIsExpandedDB())
     
    239244    public void dbStoreReceived(Hash peer, boolean wasNewKey) {
    240245        PeerProfile data = getProfile(peer);
    241         if (data == null) return;
     246        //if (data == null) return;
    242247        data.setLastHeardFrom(_context.clock().now());
    243248        if (!data.getIsExpandedDB())
     
    258263    public void dbStoreSent(Hash peer, long responseTimeMs) {
    259264        PeerProfile data = getProfile(peer);
    260         if (data == null) return;
     265        //if (data == null) return;
    261266        long now = _context.clock().now();
    262267        data.setLastHeardFrom(now);
     
    276281    public void dbStoreSuccessful(Hash peer) {
    277282        PeerProfile data = getProfile(peer);
    278         if (data == null) return;
     283        //if (data == null) return;
    279284        long now = _context.clock().now();
    280285        data.setLastHeardFrom(now);
     
    294299    public void dbStoreFailed(Hash peer) {
    295300        PeerProfile data = getProfile(peer);
    296         if (data == null) return;
     301        //if (data == null) return;
    297302        if (!data.getIsExpandedDB())
    298303            data.expandDBProfile();
     
    309314    public void heardAbout(Hash peer) {
    310315        PeerProfile data = getProfile(peer);
    311         if (data == null) return;
     316        //if (data == null) return;
    312317        data.setLastHeardAbout(_context.clock().now());
    313318    }
     
    319324    public void heardAbout(Hash peer, long when) {
    320325        PeerProfile data = getProfile(peer);
    321         if (data == null) return;
     326        //if (data == null) return;
    322327        if (when > data.getLastHeardAbout())
    323328            data.setLastHeardAbout(when);
     
    328333     * transport.  Messages received without any "from" information aren't recorded
    329334     * through this metric.  If msToReceive is negative, there was no timing information
    330      * available
    331      *
     335     * available.
     336     * Non-blocking. Will not update the profile if we can't get the lock.
    332337     */
    333338    public void messageReceived(Hash peer, String style, long msToReceive, int bytesRead) {
    334         PeerProfile data = getProfile(peer);
     339        PeerProfile data = getProfileNonblocking(peer);
    335340        if (data == null) return;
    336341        data.setLastHeardFrom(_context.clock().now());
     
    338343    }
    339344   
     345    /**
     346     *   Blocking.
     347     *   Creates a new profile if it didn't exist.
     348     *   @return non-null
     349     */
    340350    private PeerProfile getProfile(Hash peer) {
    341351        PeerProfile prof = _context.profileOrganizer().getProfile(peer);
     
    348358    }
    349359   
    350    
    351     /** provide a simple summary of a number of peers, suitable for publication in the netDb */
     360    /**
     361     *  Non-blocking.
     362     *  @return null if the profile doesn't exist, or the fetch would have blocked
     363     *  @since 0.8.12
     364     */
     365    private PeerProfile getProfileNonblocking(Hash peer) {
     366        return _context.profileOrganizer().getProfileNonblocking(peer);
     367    }
     368   
     369    /**
     370     *  provide a simple summary of a number of peers, suitable for publication in the netDb
     371     *  @deprecated unused
     372     */
    352373    public Properties summarizePeers(int numPeers) {
     374/****
    353375        Set peers = new HashSet(numPeers);
    354376        // lets get the fastest ones we've got (this fails over to include just plain reliable,
    355377        // or even notFailing peers if there aren't enough fast ones)
    356378        _context.profileOrganizer().selectFastPeers(numPeers, null, peers);
     379****/
    357380        Properties props = new Properties();
     381/****
    358382        for (Iterator iter  = peers.iterator(); iter.hasNext(); ) {
    359383            Hash peer = (Hash)iter.next();
     
    385409            props.setProperty("profile." + peer.toBase64().replace('=', '_'), buf.toString());
    386410        }
     411****/
    387412        return props;
    388413    }
    389414   
     415/****
    390416    private final static DecimalFormat _fmt = new DecimalFormat("##0.00", new DecimalFormatSymbols(Locale.UK));
    391417    private final static String num(double val) {
    392418        synchronized (_fmt) { return _fmt.format(val); }
    393419    }
     420****/
    394421}
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java

    rbf45e31 r4884148  
    5353    /** H(routerIdnetity), containing elements in _notFailingPeers */
    5454    private final List<Hash> _notFailingPeersList;
    55     /** H(routerIdentity) to PeerProfile for all peers that ARE failing horribly (but that we haven't dropped reference to yet) */
     55    /** TO BE REMOVED H(routerIdentity) to PeerProfile for all peers that ARE failing horribly (but that we haven't dropped reference to yet) */
    5656    private final Map<Hash, PeerProfile> _failingPeers;
    5757    /** who are we? */
     
    121121    }
    122122
     123    /**
     124     *  Get the lock if we can. Non-blocking.
     125     *  @return true if the lock was acquired
     126     *  @since 0.8.12
     127     */
     128    private boolean tryReadLock() {
     129        return _reorganizeLock.readLock().tryLock();
     130    }
     131
    123132    private void releaseReadLock() {
    124133        _reorganizeLock.readLock().unlock();
     
    148157   
    149158    /**
    150      * Retrieve the profile for the given peer, if one exists (else null)
    151      *
     159     * Retrieve the profile for the given peer, if one exists (else null).
     160     * Blocking if a reorganize is happening.
    152161     */
    153162    public PeerProfile getProfile(Hash peer) {
     
    156165            return locked_getProfile(peer);
    157166        } finally { releaseReadLock(); }
     167    }
     168   
     169    /**
     170     * Retrieve the profile for the given peer, if one exists (else null).
     171     * Non-blocking. Returns null if a reorganize is happening.
     172     * @since 0.8.12
     173     */
     174    public PeerProfile getProfileNonblocking(Hash peer) {
     175        if (tryReadLock()) {
     176            try {
     177                return locked_getProfile(peer);
     178            } finally { releaseReadLock(); }
     179        }
     180        return null;
    158181    }
    159182   
     
    244267    public boolean isHighCapacity(Hash peer) { return isX(_highCapacityPeers, peer); }
    245268    public boolean isWellIntegrated(Hash peer) { return isX(_wellIntegratedPeers, peer); }
    246     public boolean isFailing(Hash peer) { return isX(_failingPeers, peer); }
     269
     270    /**
     271     *  Deprecated for now, always false
     272     */
     273    public boolean isFailing(Hash peer) {
     274        // Always false so skip the lock
     275        //return isX(_failingPeers, peer);
     276        return false;
     277    }
    247278       
    248279    /** @since 0.8.8 */
  • router/java/src/net/i2p/router/transport/udp/IntroductionManager.java

    rbf45e31 r4884148  
    127127                continue;
    128128            }
    129             if (_context.profileOrganizer().isFailing(cur.getRemotePeer()) ||
     129            if ( /* _context.profileOrganizer().isFailing(cur.getRemotePeer()) || */
    130130                _context.shitlist().isShitlisted(cur.getRemotePeer()) ||
    131131                _transport.wasUnreachable(cur.getRemotePeer())) {
Note: See TracChangeset for help on using the changeset viewer.