Changeset 172ffd04


Ignore:
Timestamp:
Sep 11, 2005 4:37:15 AM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ee921c2
Parents:
d9b4406
git-author:
jrandom <jrandom> (09/11/05 04:37:15)
git-committer:
zzz <zzz@…> (09/11/05 04:37:15)
Message:

use the OS time, since it doesn't skew as much (especially on startup)

Location:
router/java/src/net/i2p/router/transport
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java

    rd9b4406 r172ffd04  
    3636    private static int __id = 0;
    3737   
     38    static long now() {
     39        // dont use the clock().now(), since that may jump
     40        return System.currentTimeMillis();
     41    }
     42   
    3843    public FIFOBandwidthLimiter(I2PAppContext context) {
    3944        _context = context;
     
    5156        _sendBps = 0;
    5257        _recvBps = 0;
    53         _lastStatsUpdated = _context.clock().now();
     58        _lastStatsUpdated = now();
    5459        _lastRateUpdated = _lastStatsUpdated;
    5560        _refiller = new FIFOBandwidthRefiller(_context, this);
     
    153158   
    154159    private void updateStats() {
    155         long now = _context.clock().now();
     160        long now = now();
    156161        long time = now - _lastStatsUpdated;
    157162        if (time >= 1000) {
     
    171176            else
    172177                _recvBps = (0.9f)*_recvBps + (0.1f)*((float)recv*time)/1000f;
    173             if (_log.shouldLog(Log.INFO)) {
    174                 _log.info("BW: time = " + time + " sent: " + sent + " recv: " + recv);
     178            if (_log.shouldLog(Log.WARN)) {
     179                if (_log.shouldLog(Log.INFO))
     180                    _log.info("BW: time = " + time + " sent: " + sent + " recv: " + recv);
    175181                _context.statManager().getStatLog().addData("bw", "bw.sendBps1s", (long)_sendBps, sent);
    176182                _context.statManager().getStatLog().addData("bw", "bw.recvBps1s", (long)_recvBps, recv);
     
    230236            return 0;
    231237        else
    232             return _context.clock().now() - start;
     238            return now() - start;
    233239    }
    234240    private long locked_getLongestOutboundWait() {
     
    243249            return 0;
    244250        else
    245             return _context.clock().now() - start;
     251            return now() - start;
    246252    }
    247253   
     
    261267                satisfied = new ArrayList(2);
    262268            satisfied.add(req);
    263             long waited = _context.clock().now() - req.getRequestTime();
     269            long waited = now() - req.getRequestTime();
    264270            if (_log.shouldLog(Log.DEBUG))
    265271                 _log.debug("Granting inbound request " + req.getRequestName() + " fully for "
     
    286292            if (_availableInboundBytes <= 0) break;
    287293            SimpleRequest req = (SimpleRequest)_pendingInboundRequests.get(i);
    288             long waited = _context.clock().now() - req.getRequestTime();
     294            long waited = now() - req.getRequestTime();
    289295            if (req.getAborted()) {
    290296                // connection decided they dont want the data anymore
     
    385391                satisfied = new ArrayList(2);
    386392            satisfied.add(req);
    387             long waited = _context.clock().now() - req.getRequestTime();
     393            long waited = now() - req.getRequestTime();
    388394            if (_log.shouldLog(Log.DEBUG))
    389395                 _log.debug("Granting outbound request " + req.getRequestName() + " fully for "
     
    411417            if (_availableOutboundBytes <= 0) break;
    412418            SimpleRequest req = (SimpleRequest)_pendingOutboundRequests.get(i);
    413             long waited = _context.clock().now() - req.getRequestTime();
     419            long waited = now() - req.getRequestTime();
    414420            if (req.getAborted()) {
    415421                // connection decided they dont want the data anymore
     
    469475   
    470476    public void renderStatusHTML(Writer out) throws IOException {
    471         long now = _context.clock().now();
     477        long now = now();
    472478        StringBuffer buf = new StringBuffer(4096);
    473479        buf.append("<br /><b>Pending bandwidth requests (with ");
     
    521527            _target = target;
    522528            _requestId = ++__requestId;
    523             _requestTime = _context.clock().now();
     529            _requestTime = now();
    524530        }
    525531        public Object getAvailabilityMonitor() { return SimpleRequest.this; }
  • router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java

    rd9b4406 r172ffd04  
    5454    public void run() {
    5555        // bootstrap 'em with nothing
    56         _lastRefillTime = _context.clock().now();
     56        _lastRefillTime = _limiter.now();
    5757        while (true) {
    58             long now = _context.clock().now();
     58            long now = _limiter.now();
    5959            if (now >= _lastCheckConfigTime + _configCheckPeriodMs) {
    6060                checkConfig();
    61                 now = _context.clock().now();
     61                now = _limiter.now();
    6262                _lastCheckConfigTime = now;
    6363            }
     
    7373   
    7474    public void reinitialize() {
    75         _lastRefillTime = _context.clock().now();
     75        _lastRefillTime = _limiter.now();
    7676        checkConfig();
    7777        _lastCheckConfigTime = _lastRefillTime;
     
    261261        }
    262262    }
    263    
     263
    264264}
Note: See TracChangeset for help on using the changeset viewer.