Changeset b3fcdb8


Ignore:
Timestamp:
Nov 30, 2011 11:17:40 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
080cc96
Parents:
f6cff78
Message:
  • Throttle: Update throttle status immediately on shutdown request;

clear starting-up message after 20 minutes

Location:
router/java/src/net/i2p/router
Files:
3 edited

Legend:

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

    rf6cff78 rb3fcdb8  
    10081008            return;
    10091009        _shutdownInProgress = true;
     1010        _context.throttle().setShutdownStatus();
    10101011        if (_shutdownHook != null) {
    10111012            try {
     
    11521153        _gracefulExitCode = exitCode;
    11531154        _config.put(PROP_SHUTDOWN_IN_PROGRESS, "true");
     1155        _context.throttle().setShutdownStatus();
    11541156        synchronized (_gracefulShutdownDetector) {
    11551157            _gracefulShutdownDetector.notifyAll();
     
    11641166        _gracefulExitCode = -1;
    11651167        _config.remove(PROP_SHUTDOWN_IN_PROGRESS);
     1168        _context.throttle().cancelShutdownStatus();
    11661169        synchronized (_gracefulShutdownDetector) {
    11671170            _gracefulShutdownDetector.notifyAll();
  • router/java/src/net/i2p/router/RouterThrottle.java

    rf6cff78 rb3fcdb8  
    4848    public String getTunnelStatus();
    4949    public void setTunnelStatus(String msg);
     50
     51    /** @since 0.8.12 */
     52    public void setShutdownStatus();
     53
     54    /** @since 0.8.12 */
     55    public void cancelShutdownStatus();
    5056}
  • router/java/src/net/i2p/router/RouterThrottleImpl.java

    rf6cff78 rb3fcdb8  
    66import net.i2p.stat.RateStat;
    77import net.i2p.util.Log;
     8import net.i2p.util.SimpleScheduler;
     9import net.i2p.util.SimpleTimer;
    810
    911/**
     
    4749    private static final int PREPROCESSED_SIZE = 1024;
    4850
     51    private static final long REJECT_STARTUP_TIME = 20*60*1000;
     52
    4953    public RouterThrottleImpl(RouterContext context) {
    5054        _context = context;
    5155        _log = context.logManager().getLog(RouterThrottleImpl.class);
    5256        setTunnelStatus();
     57        SimpleScheduler.getInstance().addEvent(new ResetStatus(), REJECT_STARTUP_TIME + 120*1000);
    5358        _context.statManager().createRateStat("router.throttleNetworkCause", "How lagged the jobQueue was when an I2NP was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
    5459        //_context.statManager().createRateStat("router.throttleNetDbCause", "How lagged the jobQueue was when a networkDb request was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
     
    6772    }
    6873   
     74    /**
     75     *  Reset status from starting up to not-starting up,
     76     *  in case we don't get a tunnel request soon after the 20 minutes is up.
     77     *
     78     *  @since 0.8.12
     79     */
     80    private class ResetStatus implements SimpleTimer.TimedEvent {
     81        public void timeReached() {
     82            if (_tunnelStatus.equals(_x("Rejecting tunnels: Starting up")))
     83                cancelShutdownStatus();
     84        }
     85    }
     86
    6987    public boolean acceptNetworkMessage() {
    7088        //if (true) return true;
     
    97115            if (_log.shouldLog(Log.WARN))
    98116                _log.warn("Refusing tunnel request since we are shutting down ASAP");
    99             setTunnelStatus(_x("Rejecting tunnels: Shutting down"));
     117            setShutdownStatus();
    100118            // Don't use CRIT because this tells everybody we are shutting down
    101119            return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
     
    103121       
    104122        // Don't use CRIT because we don't want peers to think we're failing
    105         if (_context.router().getUptime() < 20*60*1000)
     123        if (_context.router().getUptime() < REJECT_STARTUP_TIME) {
     124            setTunnelStatus(_x("Rejecting tunnels: Starting up"));
    106125            return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
     126        }
    107127
    108128        //long lag = _context.jobQueue().getMaxLag();
     
    502522//            setTunnelStatus("Not expecting tunnel requests: Advertised bandwidth too low");
    503523//        else
    504             setTunnelStatus(_x("Rejecting tunnels"));
     524            setTunnelStatus(_x("Rejecting tunnels: Starting up"));
     525    }
     526
     527    /** @since 0.8.12 */
     528    public void setShutdownStatus() {
     529        setTunnelStatus(_x("Rejecting tunnels: Shutting down"));
     530    }
     531
     532    /** @since 0.8.12 */
     533    public void cancelShutdownStatus() {
     534        setTunnelStatus(_x("Rejecting tunnels"));
    505535    }
    506536
Note: See TracChangeset for help on using the changeset viewer.