Changeset 4304458


Ignore:
Timestamp:
Jul 3, 2011 1:46:29 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d4b2805
Parents:
6074a02
Message:
  • AppContext?: Add hasWrapper() method
  • Shutdown:
    • Clear more resources in peer manager, netdb, stat manager, session key manager, naming service, tunnel dispatcher, OCMOSJ (result of testing with jvisualvm)
    • Don't call wrapper on shutdown (starting two threads) if we were started with runplain
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java

    r6074a02 r4304458  
    272272            hiddenSwitch();
    273273        } else if (restartRequired) {
    274             if (System.getProperty("wrapper.version") == null) {
     274            if (_context.hasWrapper()) {
    275275                // Wow this dumps all conns immediately and really isn't nice
    276276                addFormNotice("Performing a soft restart");
     
    290290                // But it would be hard to get right, so just do a restart.
    291291                addFormError(_("Gracefully restarting I2P to change published router address"));
    292                 _context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
     292                if (_context.hasWrapper())
     293                    _context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
    293294                _context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
    294295            }
     
    298299    private void hiddenSwitch() {
    299300        // Full restart required to generate new keys
     301        // FIXME don't call wrapper if not present, only rekey
    300302        _context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL_RESTART));
    301303        _context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigRestartBean.java

    r6074a02 r4304458  
    3131            // Normal browsers send value, IE sends button label
    3232            if ("shutdownImmediate".equals(action) || _("Shutdown immediately", ctx).equals(action)) {
    33                 ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD));
     33                if (ctx.hasWrapper())
     34                    ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD));
    3435                //ctx.router().shutdown(Router.EXIT_HARD); // never returns
    3536                ctx.router().shutdownGracefully(Router.EXIT_HARD); // give the UI time to respond
     
    3839                ctx.router().cancelGracefulShutdown();
    3940            } else if ("restartImmediate".equals(action) || _("Restart immediately", ctx).equals(action)) {
    40                 ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
     41                if (ctx.hasWrapper())
     42                    ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
    4143                //ctx.router().shutdown(Router.EXIT_HARD_RESTART); // never returns
    4244                ctx.router().shutdownGracefully(Router.EXIT_HARD_RESTART); // give the UI time to respond
    4345            } else if ("restart".equals(action) || _("Restart", ctx).equals(action)) {
    44                 ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
     46                if (ctx.hasWrapper())
     47                    ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
    4548                ctx.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
    4649            } else if ("shutdown".equals(action) || _("Shutdown", ctx).equals(action)) {
    47                 ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
     50                if (ctx.hasWrapper())
     51                    ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
    4852                ctx.router().shutdownGracefully();
    4953            }
     
    7276            buttons(ctx, buf, urlBase, systemNonce, SET2);
    7377        } else {
    74             if (System.getProperty("wrapper.version") != null)
     78            if (ctx.hasWrapper())
    7579                buttons(ctx, buf, urlBase, systemNonce, SET3);
    7680            else
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java

    r6074a02 r4304458  
    5252       
    5353        if (_("Shutdown gracefully").equals(_action)) {
    54             _context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
     54            if (_context.hasWrapper())
     55                _context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
    5556            _context.router().shutdownGracefully();
    5657            addFormNotice(_("Graceful shutdown initiated"));
    5758        } else if (_("Shutdown immediately").equals(_action)) {
    58             _context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD));
     59            if (_context.hasWrapper())
     60                _context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD));
    5961            _context.router().shutdown(Router.EXIT_HARD);
    6062            addFormNotice(_("Shutdown immediately!  boom bye bye bad bwoy"));
     
    6365            addFormNotice(_("Graceful shutdown cancelled"));
    6466        } else if (_("Graceful restart").equals(_action)) {
    65             _context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
     67            // should have wrapper if restart button is visible
     68            if (_context.hasWrapper())
     69                _context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
    6670            _context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
    6771            addFormNotice(_("Graceful restart requested"));
    6872        } else if (_("Hard restart").equals(_action)) {
    69             _context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
     73            // should have wrapper if restart button is visible
     74            if (_context.hasWrapper())
     75                _context.addShutdownTask(new UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
    7076            _context.router().shutdown(Router.EXIT_HARD_RESTART);
    7177            addFormNotice(_("Hard restart requested"));
    7278        } else if (_("Rekey and Restart").equals(_action)) {
    7379            addFormNotice(_("Rekeying after graceful restart"));
     80            // FIXME don't call wrapper if not present, only rekey
    7481            _context.addShutdownTask(new UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL_RESTART));
    7582            _context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
    7683        } else if (_("Rekey and Shutdown").equals(_action)) {
    7784            addFormNotice(_("Rekeying after graceful shutdown"));
     85            // FIXME don't call wrapper if not present, only rekey
    7886            _context.addShutdownTask(new UpdateWrapperManagerAndRekeyTask(Router.EXIT_GRACEFUL));
    7987            _context.router().shutdownGracefully(Router.EXIT_GRACEFUL);
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java

    r6074a02 r4304458  
    118118        buf.append('>').append(_("Download and verify only")).append("</option>");
    119119       
    120         if (System.getProperty("wrapper.version") != null) {
     120        if (_context.hasWrapper()) {
    121121            buf.append("<option value=\"install\"");
    122122            if (_dontInstall)
  • apps/routerconsole/java/src/net/i2p/router/web/UnsignedUpdateHandler.java

    r6074a02 r4304458  
    116116                    StringBuilder buf = new StringBuilder(64);
    117117                    buf.append("<b>").append(_("Update downloaded")).append("</b><br>");
    118                     if (System.getProperty("wrapper.version") != null)
     118                    if (_context.hasWrapper())
    119119                        buf.append(_("Click Restart to install"));
    120120                    else
  • apps/routerconsole/java/src/net/i2p/router/web/UpdateHandler.java

    r6074a02 r4304458  
    286286                    StringBuilder buf = new StringBuilder(64);
    287287                    buf.append("<b>").append(_("Update downloaded")).append("<br>");
    288                     if (System.getProperty("wrapper.version") != null)
     288                    if (_context.hasWrapper())
    289289                        buf.append(_("Click Restart to install"));
    290290                    else
     
    313313   
    314314    protected void restart() {
    315         _context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
     315        if (_context.hasWrapper())
     316            _context.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
    316317        _context.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
    317318    }
  • core/java/src/net/i2p/I2PAppContext.java

    r6074a02 r4304458  
    889889        return null;
    890890    }
     891
     892    /**
     893     *  Is the wrapper present?
     894     *  @since 0.8.8
     895     */
     896    public boolean hasWrapper() {
     897        return System.getProperty("wrapper.version") != null;
     898    }
    891899}
  • core/java/src/net/i2p/client/naming/BlockfileNamingService.java

    r6074a02 r4304458  
    109109     *  If not in router context, the database will be opened read-only
    110110     *  unless the property i2p.naming.blockfile.writeInAppContext is true.
    111      *  Not designed for simultaneous access by multiple processes.
     111     *  Not designed for multiple instantiations or simultaneous use by multple JVMs.
    112112     *
    113113     *  @throws RuntimeException on fatal error
     
    781781            _isClosed = true;
    782782        }
     783        clearCache();
    783784    }
    784785
  • core/java/src/net/i2p/stat/StatManager.java

    r6074a02 r4304458  
    5858    }
    5959   
     60    /** @since 0.8.8 */
     61    public void shutdown() {
     62        _frequencyStats.clear();
     63        _rateStats.clear();
     64    }
     65
    6066    /** may be null */
    6167    public StatLog getStatLog() { return _statLog; }
  • core/java/src/net/i2p/util/LogConsoleBuffer.java

    r6074a02 r4304458  
    7878            return new ArrayList(_critBuffer);
    7979    }
     80
     81    /**
     82     *  @since 0.8.8
     83     */
     84    public void clear() {
     85        _buffer.clear();
     86        _critBuffer.clear();
     87    }
    8088}
  • core/java/src/net/i2p/util/LogManager.java

    r6074a02 r4304458  
    661661            }
    662662        }
     663        _records.clear();
     664        _limits.clear();
     665        _logs.clear();
     666        _consoleBuffer.clear();
    663667    }
    664668
  • history.txt

    r6074a02 r4304458  
     12011-07-03 zzz
     2  * AppContext: Add hasWrapper() method
     3  * Shutdown:
     4    - Clear more resources in peer manager, netdb, stat manager,
     5      session key manager, naming service, tunnel dispatcher,
     6      OCMOSJ (result of testing with jvisualvm)
     7    - Don't call wrapper on shutdown (starting two threads) if we
     8      were started with runplain
     9
    1102011-07-01 zzz
    211  * EepGet:
  • router/java/src/net/i2p/router/ClientMessagePool.java

    r6074a02 r4304458  
    3333    }
    3434 
     35    /**
     36     *  @since 0.8.8
     37     */
     38    public void shutdown() {
     39        OutboundClientMessageOneShotJob.clearAllCaches();
     40    }
     41
    3542    /**
    3643     * Add a new message to the pool.  The message can either be locally or
  • router/java/src/net/i2p/router/Router.java

    r6074a02 r4304458  
    259259        // (we could look for the wrapper.config file and parse it I guess...)
    260260        // If we don't have a wrapper, RouterLaunch does this for us.
    261         if (System.getProperty("wrapper.version") != null) {
     261        if (_context.hasWrapper()) {
    262262            File f = new File(System.getProperty("java.io.tmpdir"), "wrapper.log");
    263263            if (!f.exists())
     
    651651        _context.removeShutdownTasks();
    652652        // hard and ugly
    653         if (System.getProperty("wrapper.version") != null)
     653        if (_context.hasWrapper())
    654654            _log.log(Log.CRIT, "Restarting with new router identity");
    655655        else
     
    982982        try { _context.jobQueue().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the job queue", t); }
    983983        //try { _context.adminManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the admin manager", t); }       
    984         try { _context.statPublisher().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats manager", t); }
     984        try { _context.statPublisher().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats publisher", t); }
     985        try { _context.statManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats manager", t); }
    985986        try { _context.tunnelManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the tunnel manager", t); }
    986987        try { _context.tunnelDispatcher().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the tunnel dispatcher", t); }
     
    992993        try { _context.messageValidator().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the message validator", t); }
    993994        try { _context.inNetMessagePool().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the inbound net pool", t); }
    994         //try { _sessionKeyPersistenceHelper.shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the session key manager", t); }
     995        try { _context.clientMessagePool().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the client msg pool", t); }
     996        try { _context.sessionKeyManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the session key manager", t); }
    995997        _context.deleteTempDir();
    996998        List<RouterContext> contexts = RouterContext.getContexts();
     
    10551057            try { Thread.sleep(1000); } catch (InterruptedException ie) {}
    10561058            Runtime.getRuntime().halt(exitCode);
     1059        } else {
     1060            Runtime.getRuntime().gc();
    10571061        }
    10581062    }
     
    13021306                }
    13031307                // exit whether ok or not
    1304                 if (System.getProperty("wrapper.version") != null)
     1308                if (_context.hasWrapper())
    13051309                    System.out.println("INFO: Restarting after update");
    13061310                else
  • router/java/src/net/i2p/router/RouterVersion.java

    r6074a02 r4304458  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 3;
     21    public final static long BUILD = 4;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java

    r6074a02 r4304458  
    713713
    714714    /**
     715     *  @since 0.8.8
     716     */
     717    public static void clearAllCaches() {
     718        synchronized(_leaseSetCache) {
     719            _leaseSetCache.clear();
     720        }
     721        synchronized(_leaseCache) {
     722            _leaseCache.clear();
     723        }
     724        synchronized(_tunnelCache) {
     725            _backloggedTunnelCache.clear();
     726            _tunnelCache.clear();
     727        }
     728    }
     729
     730    /**
    715731     * Clean out old leaseSets
    716732     * Caller must synchronize on tc.
  • router/java/src/net/i2p/router/networkdb/kademlia/KBucketSet.java

    r6074a02 r4304458  
    9191    }
    9292   
     93    /** @since 0.8.8 */
     94    public void clear() {
     95        for (int i = 0; i < _buckets.length; i++) {
     96            _buckets[i].setEntries(Collections.EMPTY_SET);
     97        }
     98        _size = 0;
     99        _us.clearXorCache();
     100    }
     101   
    93102    public Set<Hash> getAll() { return getAll(Collections.EMPTY_SET); };
    94103    public Set<Hash> getAll(Set<Hash> toIgnore) {
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    r6074a02 r4304458  
    194194    public void shutdown() {
    195195        _initialized = false;
     196        if (_kb != null)
     197            _kb.clear();
    196198        // don't null out _kb, it can cause NPEs in concurrent operations
    197199        //_kb = null;
  • router/java/src/net/i2p/router/networkdb/kademlia/LocalHash.java

    r6074a02 r4304458  
    108108    }
    109109   
    110     /** @deprecated unused */
    111110    public void clearXorCache() {
    112         _xorCache = null;
     111        synchronized (_xorCache) {
     112            _xorCache.clear();
     113        }
    113114    }
    114115   
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java

    r6074a02 r4304458  
    230230    /** @since 0.8.8 */
    231231    void clearProfiles() {
    232         getReadLock();
     232        if (!getWriteLock())
     233            return;
    233234        try {
    234235            _failingPeers.clear();
     
    238239            _notFailingPeersList.clear();
    239240            _wellIntegratedPeers.clear();
    240         } finally { releaseReadLock(); }
     241            _strictCapacityOrder.clear();
     242        } finally { releaseWriteLock(); }
    241243    }
    242244
  • router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java

    r6074a02 r4304458  
    723723        _validator = null;
    724724        _pumper.stopPumping();
    725     }
     725        _outboundGateways.clear();
     726        _outboundEndpoints.clear();
     727        _participants.clear();
     728        _inboundGateways.clear();
     729        _participatingConfig.clear();
     730    }
     731
    726732    public void restart() {
    727733        shutdown();
Note: See TracChangeset for help on using the changeset viewer.