Changeset c5e74fe


Ignore:
Timestamp:
Aug 19, 2011 3:34:30 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2159862
Parents:
26c744c
Message:
  • Soft restart:
    • Allow NTP to reinitialize clock after the comm system in the first minute of uptime
    • Fix i2ptunnels not restarting
    • Increase minimum forward clock shift for soft restart
    • Reduce minimum backward clock shift for soft restart
    • Signal the I2CP client with a different message when restarting
    • I2CP client reconnects when receiving restart message
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/client/DisconnectMessageHandler.java

    r26c744c rc5e74fe  
    1313import net.i2p.data.i2cp.DisconnectMessage;
    1414import net.i2p.data.i2cp.I2CPMessage;
     15import net.i2p.util.I2PAppThread;
    1516import net.i2p.util.Log;
    1617
     
    2829        if (_log.shouldLog(Log.DEBUG))
    2930            _log.debug("Handle message " + message);
    30         session.propogateError(((DisconnectMessage)message).getReason(), new I2PSessionException("Disconnect Message received"));
     31        String reason = ((DisconnectMessage)message).getReason();
     32        session.propogateError(reason, new I2PSessionException("Disconnect Message received"));
    3133        session.destroySession(false);
     34        if (reason.contains("restart")) {
     35            Thread t = new I2PAppThread(new Reconnector(session), "Reconnect " + session, true);
     36            t.start();
     37        }
     38    }
     39
     40    /** @since 0.8.8 */
     41    private static class Reconnector implements Runnable {
     42        private final I2PSessionImpl _session;
     43
     44        public Reconnector(I2PSessionImpl session) {
     45             _session = session;
     46        }
     47
     48        public void run() {
     49            try { Thread.sleep(10*1000); } catch (InterruptedException ie) {}
     50            _session.reconnect();
     51        }
    3252    }
    3353}
  • history.txt

    r26c744c rc5e74fe  
     12011-08-19 zzz
     2  * Soft restart:
     3    - Allow NTP to reinitialize clock after the comm system
     4      in the first minute of uptime
     5    - Fix i2ptunnels not restarting
     6    - Increase minimum forward clock shift for soft restart
     7    - Reduce minimum backward clock shift for soft restart
     8    - Signal the I2CP client with a different message when restarting
     9    - I2CP client reconnects when receiving restart message
     10
    1112011-08-17 kytv
    212  * Fix #506: Don't attempt to load systray4j when using a 64bit JVM
  • router/java/src/net/i2p/router/ClientManagerFacade.java

    r26c744c rc5e74fe  
    9595    public abstract SessionKeyManager getClientSessionKeyManager(Hash dest);
    9696    public void renderStatusHTML(Writer out) throws IOException { }
     97
     98    /** @since 0.8.8 */
     99    public abstract void shutdown(String msg);
    97100}
  • router/java/src/net/i2p/router/DummyClientManagerFacade.java

    r26c744c rc5e74fe  
    3737    public void stopAcceptingClients() { }
    3838    public void shutdown() {}
     39    public void shutdown(String msg) {}
    3940    public void restart() {}
    4041   
  • router/java/src/net/i2p/router/Router.java

    r26c744c rc5e74fe  
    13091309            _log.error("Stopping the router for a restart...");
    13101310            _log.logAlways(Log.WARN, "Stopping the client manager");
    1311             try { _context.clientManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error stopping the client manager", t); }
     1311            // NOTE: DisconnectMessageHandler keys off "restart"
     1312            try { _context.clientManager().shutdown("Router restart"); } catch (Throwable t) { _log.log(Log.CRIT, "Error stopping the client manager", t); }
    13121313            _log.logAlways(Log.WARN, "Stopping the comm system");
    13131314            try { _context.messageRegistry().restart(); } catch (Throwable t) { _log.log(Log.CRIT, "Error restarting the message registry", t); }
  • router/java/src/net/i2p/router/RouterClock.java

    r26c744c rc5e74fe  
    4141
    4242    /**
    43      *  If the system clock shifts by this much (positive or negative),
     43     *  If the system clock shifts by this much,
    4444     *  call the callback, we probably need a soft restart.
    4545     *  @since 0.8.8
    4646     */
    47     private static final long MASSIVE_SHIFT = 75*1000;
     47    private static final long MASSIVE_SHIFT_FORWARD = 150*1000;
     48    private static final long MASSIVE_SHIFT_BACKWARD = 61*1000;
     49
    4850    private final Set<ClockShiftListener> _shiftListeners;
    4951    private volatile long _lastShiftNanos;
     
    138140        }
    139141
    140         if (_alreadyChanged) {
     142        // In first minute, allow a lower (better) stratum to do a step adjustment after
     143        // a previous step adjustment.
     144        // This allows NTP to trump a peer offset after a soft restart
     145        if (_alreadyChanged &&
     146            (stratum >= _lastStratum || _startedOn - System.currentTimeMillis() > 60*1000)) {
    141147            // Update the target offset, slewing will take care of the rest
    142148            if (delta > 15*1000)
     
    193199        long offset = _offset;
    194200        long sinceLastSlewed = systemNow - _lastSlewed;
    195         if (sinceLastSlewed >= MASSIVE_SHIFT ||
    196             sinceLastSlewed <= 0 - MASSIVE_SHIFT) {
     201        if (sinceLastSlewed >= MASSIVE_SHIFT_FORWARD ||
     202            sinceLastSlewed <= 0 - MASSIVE_SHIFT_BACKWARD) {
    197203            _lastSlewed = systemNow;
    198204            notifyMassive(sinceLastSlewed);
     
    225231        // try to prevent dups, not guaranteed
    226232        // nanoTime() isn't guaranteed to be monotonic either :(
    227         if (nowNanos < _lastShiftNanos + MASSIVE_SHIFT)
     233        if (nowNanos < _lastShiftNanos + MASSIVE_SHIFT_FORWARD)
    228234            return;
    229235        _lastShiftNanos = nowNanos;
  • router/java/src/net/i2p/router/RouterVersion.java

    r26c744c rc5e74fe  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 22;
     21    public final static long BUILD = 23;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/client/ClientManager.java

    r26c744c rc5e74fe  
    8787   
    8888    public void restart() {
    89         shutdown();
     89        shutdown("Router restart");
    9090       
    9191        // to let the old listener die
     
    9797    }
    9898   
    99     public void shutdown() {
     99    /**
     100     *  @param msg message to send to the clients
     101     */
     102    public void shutdown(String msg) {
    100103        _isStarted = false;
    101104        _log.info("Shutting down the ClientManager");
     
    117120        for (Iterator<ClientConnectionRunner> iter = runners.iterator(); iter.hasNext(); ) {
    118121            ClientConnectionRunner runner = iter.next();
    119             runner.disconnectClient("Router shutdown", Log.WARN);
     122            runner.disconnectClient(msg, Log.WARN);
    120123        }
    121124    }
  • router/java/src/net/i2p/router/client/ClientManagerFacadeImpl.java

    r26c744c rc5e74fe  
    5959   
    6060    public void shutdown() {
    61         if (_manager != null)
    62             _manager.shutdown();
     61        shutdown("Router shutdown");
     62    }
     63
     64    /**
     65     *  @param msg message to send to the clients
     66     *  @since 0.8.8
     67     */
     68    public void shutdown(String msg) {
     69        if (_manager != null)
     70            _manager.shutdown(msg);
    6371    }
    6472   
Note: See TracChangeset for help on using the changeset viewer.