mirror of
https://github.com/i2p/i2p.i2p.git
synced 2026-10-23 15:12:56 +00:00
* 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
This commit is contained in:
1 parent
6074a02cf5
commit
43044586d1
21 files changed
+124
-26
No files matched your search
@@ -32,6 +32,13 @@ public class ClientMessagePool {
|
||||
OutboundClientMessageOneShotJob.init(_context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.8.8
|
||||
*/
|
||||
public void shutdown() {
|
||||
OutboundClientMessageOneShotJob.clearAllCaches();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new message to the pool. The message can either be locally or
|
||||
* remotely destined.
|
||||
|
||||
@@ -258,7 +258,7 @@ public class Router {
|
||||
// but this is the same method used in LogsHelper and we have no complaints.
|
||||
// (we could look for the wrapper.config file and parse it I guess...)
|
||||
// If we don't have a wrapper, RouterLaunch does this for us.
|
||||
if (System.getProperty("wrapper.version") != null) {
|
||||
if (_context.hasWrapper()) {
|
||||
File f = new File(System.getProperty("java.io.tmpdir"), "wrapper.log");
|
||||
if (!f.exists())
|
||||
f = new File(_context.getBaseDir(), "wrapper.log");
|
||||
@@ -650,7 +650,7 @@ public class Router {
|
||||
}
|
||||
_context.removeShutdownTasks();
|
||||
// hard and ugly
|
||||
if (System.getProperty("wrapper.version") != null)
|
||||
if (_context.hasWrapper())
|
||||
_log.log(Log.CRIT, "Restarting with new router identity");
|
||||
else
|
||||
_log.log(Log.CRIT, "Shutting down because old router identity was invalid - restart I2P");
|
||||
@@ -981,7 +981,8 @@ public class Router {
|
||||
try { _context.namingService().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the naming service", t); }
|
||||
try { _context.jobQueue().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the job queue", t); }
|
||||
//try { _context.adminManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the admin manager", t); }
|
||||
try { _context.statPublisher().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats manager", t); }
|
||||
try { _context.statPublisher().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats publisher", t); }
|
||||
try { _context.statManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats manager", t); }
|
||||
try { _context.tunnelManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the tunnel manager", t); }
|
||||
try { _context.tunnelDispatcher().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the tunnel dispatcher", t); }
|
||||
try { _context.netDb().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the networkDb", t); }
|
||||
@@ -991,7 +992,8 @@ public class Router {
|
||||
try { _context.messageRegistry().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the message registry", t); }
|
||||
try { _context.messageValidator().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the message validator", t); }
|
||||
try { _context.inNetMessagePool().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the inbound net pool", t); }
|
||||
//try { _sessionKeyPersistenceHelper.shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the session key manager", t); }
|
||||
try { _context.clientMessagePool().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the client msg pool", t); }
|
||||
try { _context.sessionKeyManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the session key manager", t); }
|
||||
_context.deleteTempDir();
|
||||
List<RouterContext> contexts = RouterContext.getContexts();
|
||||
contexts.remove(_context);
|
||||
@@ -1054,6 +1056,8 @@ public class Router {
|
||||
if (_killVMOnEnd) {
|
||||
try { Thread.sleep(1000); } catch (InterruptedException ie) {}
|
||||
Runtime.getRuntime().halt(exitCode);
|
||||
} else {
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1301,7 +1305,7 @@ public class Router {
|
||||
}
|
||||
}
|
||||
// exit whether ok or not
|
||||
if (System.getProperty("wrapper.version") != null)
|
||||
if (_context.hasWrapper())
|
||||
System.out.println("INFO: Restarting after update");
|
||||
else
|
||||
System.out.println("WARNING: Exiting after update, restart I2P");
|
||||
|
||||
@@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 3;
|
||||
public final static long BUILD = 4;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
||||
@@ -711,6 +711,22 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.8.8
|
||||
*/
|
||||
public static void clearAllCaches() {
|
||||
synchronized(_leaseSetCache) {
|
||||
_leaseSetCache.clear();
|
||||
}
|
||||
synchronized(_leaseCache) {
|
||||
_leaseCache.clear();
|
||||
}
|
||||
synchronized(_tunnelCache) {
|
||||
_backloggedTunnelCache.clear();
|
||||
_tunnelCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean out old leaseSets
|
||||
* Caller must synchronize on tc.
|
||||
|
||||
@@ -90,6 +90,15 @@ class KBucketSet {
|
||||
return removed;
|
||||
}
|
||||
|
||||
/** @since 0.8.8 */
|
||||
public void clear() {
|
||||
for (int i = 0; i < _buckets.length; i++) {
|
||||
_buckets[i].setEntries(Collections.EMPTY_SET);
|
||||
}
|
||||
_size = 0;
|
||||
_us.clearXorCache();
|
||||
}
|
||||
|
||||
public Set<Hash> getAll() { return getAll(Collections.EMPTY_SET); };
|
||||
public Set<Hash> getAll(Set<Hash> toIgnore) {
|
||||
Set<Hash> all = new HashSet(1024);
|
||||
|
||||
@@ -193,6 +193,8 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
|
||||
public void shutdown() {
|
||||
_initialized = false;
|
||||
if (_kb != null)
|
||||
_kb.clear();
|
||||
// don't null out _kb, it can cause NPEs in concurrent operations
|
||||
//_kb = null;
|
||||
if (_ds != null)
|
||||
|
||||
@@ -107,9 +107,10 @@ class LocalHash extends Hash {
|
||||
return distance;
|
||||
}
|
||||
|
||||
/** @deprecated unused */
|
||||
public void clearXorCache() {
|
||||
_xorCache = null;
|
||||
synchronized (_xorCache) {
|
||||
_xorCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/********
|
||||
|
||||
@@ -229,7 +229,8 @@ public class ProfileOrganizer {
|
||||
|
||||
/** @since 0.8.8 */
|
||||
void clearProfiles() {
|
||||
getReadLock();
|
||||
if (!getWriteLock())
|
||||
return;
|
||||
try {
|
||||
_failingPeers.clear();
|
||||
_fastPeers.clear();
|
||||
@@ -237,7 +238,8 @@ public class ProfileOrganizer {
|
||||
_notFailingPeers.clear();
|
||||
_notFailingPeersList.clear();
|
||||
_wellIntegratedPeers.clear();
|
||||
} finally { releaseReadLock(); }
|
||||
_strictCapacityOrder.clear();
|
||||
} finally { releaseWriteLock(); }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -722,7 +722,13 @@ public class TunnelDispatcher implements Service {
|
||||
_validator.destroy();
|
||||
_validator = null;
|
||||
_pumper.stopPumping();
|
||||
_outboundGateways.clear();
|
||||
_outboundEndpoints.clear();
|
||||
_participants.clear();
|
||||
_inboundGateways.clear();
|
||||
_participatingConfig.clear();
|
||||
}
|
||||
|
||||
public void restart() {
|
||||
shutdown();
|
||||
startup();
|
||||
|
||||
Reference in new issue
Block a user