Changeset e734a558


Ignore:
Timestamp:
Sep 15, 2008 4:19:08 PM (13 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
fcfe439
Parents:
825af3e
Message:
  • Router: Shutdown clients first
  • Throttle:
    • Use 60s rather than 10m tunnel.participatingMessageCount stat
    • Fix a summary bar message
  • Tunnel Dispatcher: Update tunnel.participatingMessageCount every 20s, rather than at tunnel expiration, to maintain a more current stat
Location:
router/java/src/net/i2p/router
Files:
4 edited

Legend:

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

    r825af3e re734a558  
    807807            _log.log(Log.CRIT, "Error running shutdown task", t);
    808808        }
     809        try { _context.clientManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the client manager", t); }
    809810        try { _context.jobQueue().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the job queue", t); }
    810811        //try { _context.adminManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the admin manager", t); }       
    811812        try { _context.statPublisher().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats manager", t); }
    812         try { _context.clientManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the client manager", t); }
    813813        try { _context.tunnelManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the tunnel manager", t); }
    814814        try { _context.tunnelDispatcher().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the tunnel dispatcher", t); }
     
    12001200        getContext().statManager().addRateData("bw.recvRate", (long)getContext().bandwidthLimiter().getReceiveBps(), 0);
    12011201       
     1202        getContext().tunnelDispatcher().updateParticipatingStats();
     1203
    12021204        getContext().statManager().coalesceStats();
    12031205
  • router/java/src/net/i2p/router/RouterThrottleImpl.java

    r825af3e re734a558  
    140140                                      + " current=" + numTunnels + ")");
    141141                        _context.statManager().addRateData("router.throttleTunnelProbTooFast", (long)(numTunnels-avg), 0);
    142                         setTunnelStatus("Rejecting " + ((int) probAccept*100) + "% of tunnels: High number of requests");
     142                        setTunnelStatus("Rejecting " + (100 - (int) probAccept*100) + "% of tunnels: High number of requests");
    143143                        return TunnelHistory.TUNNEL_REJECT_PROBABALISTIC_REJECT;
    144144                    }
     
    212212        double messagesPerTunnel = DEFAULT_MESSAGES_PER_TUNNEL_ESTIMATE;
    213213        if (rs != null) {
    214             r = rs.getRate(10*60*1000);
     214            r = rs.getRate(60*1000);
    215215            if (r != null) {
    216216                long count = r.getLastEventCount() + r.getCurrentEventCount();
  • router/java/src/net/i2p/router/tunnel/HopConfig.java

    r825af3e re734a558  
    2828    private Map _options;
    2929    private long _messagesProcessed;
     30    private long _oldMessagesProcessed;
    3031   
    3132    /** IV length for {@link #getReplyIV} */
     
    4344        _options = null;
    4445        _messagesProcessed = 0;
     46        _oldMessagesProcessed = 0;
    4547    }
    4648   
     
    116118    public void incrementProcessedMessages() { _messagesProcessed++; }
    117119    public long getProcessedMessagesCount() { return _messagesProcessed; }
     120    public long getRecentMessagesCount() {
     121        long rv = _messagesProcessed - _oldMessagesProcessed;
     122        _oldMessagesProcessed = _messagesProcessed;
     123        return rv;
     124    }
    118125   
    119126    public String toString() {
  • router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java

    r825af3e re734a558  
    201201            _participants.put(recvId, participant);
    202202        }
    203         int numParticipants = 0;
    204203        synchronized (_participatingConfig) {
    205204            _participatingConfig.put(recvId, cfg);
    206             numParticipants = _participatingConfig.size();
    207205        }
    208206        _context.messageHistory().tunnelJoined("participant", cfg);
    209         _context.statManager().addRateData("tunnel.participatingTunnels", numParticipants, 0);
    210207        _context.statManager().addRateData("tunnel.joinParticipant", 1, 0);
    211208        if (cfg.getExpiration() > _lastParticipatingExpiration)
     
    225222            _outboundEndpoints.put(recvId, endpoint);
    226223        }
    227         int numParticipants = 0;
    228224        synchronized (_participatingConfig) {
    229225            _participatingConfig.put(recvId, cfg);
    230             numParticipants = _participatingConfig.size();
    231226        }
    232227        _context.messageHistory().tunnelJoined("outboundEndpoint", cfg);
    233         _context.statManager().addRateData("tunnel.participatingTunnels", numParticipants, 0);
    234228        _context.statManager().addRateData("tunnel.joinOutboundEndpoint", 1, 0);
    235229
     
    255249            _inboundGateways.put(recvId, gw);
    256250        }
    257         int numParticipants = 0;
    258251        synchronized (_participatingConfig) {
    259252            _participatingConfig.put(recvId, cfg);
    260             numParticipants = _participatingConfig.size();
    261253        }
    262254        _context.messageHistory().tunnelJoined("inboundGateway", cfg);
    263         _context.statManager().addRateData("tunnel.participatingTunnels", numParticipants, 0);
    264255        _context.statManager().addRateData("tunnel.joinInboundGateway", 1, 0);
    265256
     
    339330       
    340331        boolean removed = false;
    341         int numParticipants = 0;
    342332        synchronized (_participatingConfig) {
    343333            removed = (null != _participatingConfig.remove(recvId));
    344             numParticipants = _participatingConfig.size();
    345334        }
    346335        if (!removed) {
     
    349338        }
    350339       
    351         _context.statManager().addRateData("tunnel.participatingTunnels", numParticipants, 0);
    352         _context.statManager().addRateData("tunnel.participatingMessageCount", cfg.getProcessedMessagesCount(), 10*60*1000);
    353 
    354340        synchronized (_participants) {
    355341            removed = (null != _participants.remove(recvId));
     
    548534    }
    549535
     536    /**
     537     * Generate a current estimate of usage per-participating-tunnel lifetime.
     538     * The stats code calls this every 20s.
     539     * This is better than waiting until the tunnel expires to update the rate,
     540     * as we want this to be current because it's an important part of
     541     * the throttle code.
     542     */
     543    public void updateParticipatingStats() {
     544        List participating = listParticipatingTunnels();
     545        int size = participating.size();
     546        long count = 0;
     547        long tcount = 0;
     548        long tooYoung = _context.clock().now() - 60*1000;
     549        long tooOld = tooYoung - 9*60*1000;
     550        for (int i = 0; i < size; i++) {
     551            HopConfig cfg = (HopConfig)participating.get(i);
     552            long c = cfg.getRecentMessagesCount();
     553            long created = cfg.getCreation();
     554            if (created > tooYoung || created < tooOld)
     555                continue;
     556            tcount++;
     557            count += c;
     558        }
     559        // This is called every 20s from Router.java, with 11m tunnel lifetime, so *= 33
     560        if (tcount > 0)
     561            count = count * 33 / tcount;
     562        _context.statManager().addRateData("tunnel.participatingMessageCount", count, 20*1000);
     563        _context.statManager().addRateData("tunnel.participatingTunnels", size, 0);
     564    }
    550565
    551566    private static final int DROP_BASE_INTERVAL = 40 * 1000;
Note: See TracChangeset for help on using the changeset viewer.