* Router: Set killVMOnEnd before runRouter() (for azi2phelper)

* RoutingKeyGenerator: Don't assume UTC (for azi2phelper)
This commit is contained in:
zzz
2014-04-27 14:53:15 +00:00
parent 3f56ce206d
commit f5661da595
2 changed files with 29 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
@ -64,7 +65,11 @@ public class RoutingKeyGenerator {
private final static Calendar _cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); private final static Calendar _cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
private static final String FORMAT = "yyyyMMdd"; private static final String FORMAT = "yyyyMMdd";
private static final int LENGTH = FORMAT.length(); private static final int LENGTH = FORMAT.length();
private final static SimpleDateFormat _fmt = new SimpleDateFormat(FORMAT); private final static SimpleDateFormat _fmt = new SimpleDateFormat(FORMAT, Locale.US);
static {
// make sure GMT is set, azi2phelper Vuze plugin is disabling static JVM TZ setting in Router.java
_fmt.setCalendar(_cal);
}
/** /**
* The current (today's) mod data. * The current (today's) mod data.

View File

@ -138,11 +138,27 @@ public class Router implements RouterClock.ClockShiftListener {
*/ */
public Router() { this(null, null); } public Router() { this(null, null); }
/**
* Instantiation only. Starts no threads. Does not install updates.
* RouterContext is created but not initialized.
* You must call runRouter() after any constructor to start things up.
*/
public Router(Properties envProps) { this(null, envProps); } public Router(Properties envProps) { this(null, envProps); }
/**
* Instantiation only. Starts no threads. Does not install updates.
* RouterContext is created but not initialized.
* You must call runRouter() after any constructor to start things up.
*/
public Router(String configFilename) { this(configFilename, null); } public Router(String configFilename) { this(configFilename, null); }
/**
* Instantiation only. Starts no threads. Does not install updates.
* RouterContext is created but not initialized.
* You must call runRouter() after any constructor to start things up.
*/
public Router(String configFilename, Properties envProps) { public Router(String configFilename, Properties envProps) {
_killVMOnEnd = true;
_gracefulExitCode = -1; _gracefulExitCode = -1;
_config = new ConcurrentHashMap<String, String>(); _config = new ConcurrentHashMap<String, String>();
@ -307,7 +323,6 @@ public class Router implements RouterClock.ClockShiftListener {
_log = _context.logManager().getLog(Router.class); _log = _context.logManager().getLog(Router.class);
_log.info("New router created with config file " + _configFilename); _log.info("New router created with config file " + _configFilename);
//_sessionKeyPersistenceHelper = new SessionKeyPersistenceHelper(_context); //_sessionKeyPersistenceHelper = new SessionKeyPersistenceHelper(_context);
_killVMOnEnd = true;
_oomListener = new OOMListener(_context); _oomListener = new OOMListener(_context);
_shutdownHook = new ShutdownHook(_context); _shutdownHook = new ShutdownHook(_context);
@ -333,7 +348,7 @@ public class Router implements RouterClock.ClockShiftListener {
/** /**
* Configure the router to kill the JVM when the router shuts down, as well * Configure the router to kill the JVM when the router shuts down, as well
* as whether to explicitly halt the JVM during the hard fail process. * as whether to explicitly halt the JVM during the hard fail process.
* * Defaults to true. Set to false for embedded before calling runRouter()
*/ */
public void setKillVMOnEnd(boolean shouldDie) { _killVMOnEnd = shouldDie; } public void setKillVMOnEnd(boolean shouldDie) { _killVMOnEnd = shouldDie; }
@ -429,7 +444,10 @@ public class Router implements RouterClock.ClockShiftListener {
/** /**
* This must be called after instantiation. * This must be called after instantiation.
* Starts the threads. Does not install updates. * Starts the threads. Does not install updates.
* Most users will just call main() instead. * This is for embedded use.
* Standard standalone installation uses main() instead, which
* checks for updates and then calls this.
*
* @since public as of 0.9 for Android and other embedded uses * @since public as of 0.9 for Android and other embedded uses
*/ */
public synchronized void runRouter() { public synchronized void runRouter() {
@ -1108,6 +1126,8 @@ public class Router implements RouterClock.ClockShiftListener {
/** /**
* Usage: Router [rebuild] * Usage: Router [rebuild]
* No other options allowed, for now * No other options allowed, for now
* Instantiates Router(), and either installs updates and exits,
* or calls runRouter().
* *
* @param args null ok * @param args null ok
* @throws IllegalArgumentException * @throws IllegalArgumentException