diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java
index 4862b9199..4d69ecfed 100644
--- a/router/java/src/net/i2p/router/Router.java
+++ b/router/java/src/net/i2p/router/Router.java
@@ -74,15 +74,15 @@ public class Router {
public final static String PROP_KEYS_FILENAME_DEFAULT = "router.keys";
private Router() {
- _config = new Properties();
- _configFilename = System.getProperty(PROP_CONFIG_FILE, "router.config");
- _routerInfo = null;
- _higherVersionSeen = false;
- // grumble about sun's java caching DNS entries *forever*
- System.setProperty("sun.net.inetaddr.ttl", "0");
- System.setProperty("networkaddress.cache.ttl", "0");
- // (no need for keepalive)
- System.setProperty("http.keepAlive", "false");
+ _config = new Properties();
+ _configFilename = System.getProperty(PROP_CONFIG_FILE, "router.config");
+ _routerInfo = null;
+ _higherVersionSeen = false;
+ // grumble about sun's java caching DNS entries *forever*
+ System.setProperty("sun.net.inetaddr.ttl", "0");
+ System.setProperty("networkaddress.cache.ttl", "0");
+ // (no need for keepalive)
+ System.setProperty("http.keepAlive", "false");
}
public String getConfigFilename() { return _configFilename; }
@@ -95,9 +95,9 @@ public class Router {
public RouterInfo getRouterInfo() { return _routerInfo; }
public void setRouterInfo(RouterInfo info) {
- _routerInfo = info;
- if (info != null)
- JobQueue.getInstance().addJob(new PersistRouterInfoJob());
+ _routerInfo = info;
+ if (info != null)
+ JobQueue.getInstance().addJob(new PersistRouterInfoJob());
}
/**
@@ -113,21 +113,21 @@ public class Router {
public long getUptime() { return Clock.getInstance().now() - Clock.getInstance().getOffset() - _started; }
private void runRouter() {
- _started = Clock.getInstance().now();
- Runtime.getRuntime().addShutdownHook(new ShutdownHook());
- I2PThread.setOOMEventListener(new I2PThread.OOMEventListener() {
- public void outOfMemory(OutOfMemoryError oom) {
- _log.log(Log.CRIT, "Thread ran out of memory", oom);
- shutdown();
- }
- });
- setupHandlers();
- startupQueue();
- JobQueue.getInstance().addJob(new CoallesceStatsJob());
- JobQueue.getInstance().addJob(new UpdateRoutingKeyModifierJob());
- warmupCrypto();
- SessionKeyPersistenceHelper.getInstance().startup();
- JobQueue.getInstance().addJob(new StartupJob());
+ _started = Clock.getInstance().now();
+ Runtime.getRuntime().addShutdownHook(new ShutdownHook());
+ I2PThread.setOOMEventListener(new I2PThread.OOMEventListener() {
+ public void outOfMemory(OutOfMemoryError oom) {
+ _log.log(Log.CRIT, "Thread ran out of memory", oom);
+ shutdown();
+ }
+ });
+ setupHandlers();
+ startupQueue();
+ JobQueue.getInstance().addJob(new CoallesceStatsJob());
+ JobQueue.getInstance().addJob(new UpdateRoutingKeyModifierJob());
+ warmupCrypto();
+ SessionKeyPersistenceHelper.getInstance().startup();
+ JobQueue.getInstance().addJob(new StartupJob());
}
/**
@@ -135,11 +135,11 @@ public class Router {
*
*/
private final static class CoallesceStatsJob extends JobImpl {
- public String getName() { return "Coallesce stats"; }
- public void runJob() {
- StatManager.getInstance().coallesceStats();
- requeue(60*1000);
- }
+ public String getName() { return "Coallesce stats"; }
+ public void runJob() {
+ StatManager.getInstance().coallesceStats();
+ requeue(60*1000);
+ }
}
/**
@@ -148,278 +148,262 @@ public class Router {
* uses it.
*/
private final static class UpdateRoutingKeyModifierJob extends JobImpl {
- private Calendar _cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
- public String getName() { return "Update Routing Key Modifier"; }
- public void runJob() {
- RoutingKeyGenerator.getInstance().generateDateBasedModData();
- requeue(getTimeTillMidnight());
- }
- private long getTimeTillMidnight() {
- long now = Clock.getInstance().now();
- _cal.setTime(new Date(now));
- _cal.add(Calendar.DATE, 1);
- _cal.set(Calendar.HOUR_OF_DAY, 0);
- _cal.set(Calendar.MINUTE, 0);
- _cal.set(Calendar.SECOND, 0);
- _cal.set(Calendar.MILLISECOND, 0);
- long then = _cal.getTime().getTime();
+ private Calendar _cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+ public String getName() { return "Update Routing Key Modifier"; }
+ public void runJob() {
+ RoutingKeyGenerator.getInstance().generateDateBasedModData();
+ requeue(getTimeTillMidnight());
+ }
+ private long getTimeTillMidnight() {
+ long now = Clock.getInstance().now();
+ _cal.setTime(new Date(now));
+ _cal.add(Calendar.DATE, 1);
+ _cal.set(Calendar.HOUR_OF_DAY, 0);
+ _cal.set(Calendar.MINUTE, 0);
+ _cal.set(Calendar.SECOND, 0);
+ _cal.set(Calendar.MILLISECOND, 0);
+ long then = _cal.getTime().getTime();
_log.debug("Time till midnight: " + (then-now) + "ms");
if (then - now <= 60*1000) {
// everyone wave at kaffe.
// "Hi Kaffe"
return 60*1000;
} else {
- return then - now;
+ return then - now;
}
- }
+ }
}
private void warmupCrypto() {
- RandomSource.getInstance().nextBoolean();
- new DHSessionKeyBuilder(); // load the class so it starts the precalc process
+ RandomSource.getInstance().nextBoolean();
+ new DHSessionKeyBuilder(); // load the class so it starts the precalc process
}
private void startupQueue() {
- JobQueue.getInstance().runQueue(1);
+ JobQueue.getInstance().runQueue(1);
}
private void setupHandlers() {
- InNetMessagePool.getInstance().registerHandlerJobBuilder(GarlicMessage.MESSAGE_TYPE, new GarlicMessageHandler());
- InNetMessagePool.getInstance().registerHandlerJobBuilder(TunnelMessage.MESSAGE_TYPE, new TunnelMessageHandler());
- InNetMessagePool.getInstance().registerHandlerJobBuilder(SourceRouteReplyMessage.MESSAGE_TYPE, new SourceRouteReplyMessageHandler());
+ InNetMessagePool.getInstance().registerHandlerJobBuilder(GarlicMessage.MESSAGE_TYPE, new GarlicMessageHandler());
+ InNetMessagePool.getInstance().registerHandlerJobBuilder(TunnelMessage.MESSAGE_TYPE, new TunnelMessageHandler());
+ InNetMessagePool.getInstance().registerHandlerJobBuilder(SourceRouteReplyMessage.MESSAGE_TYPE, new SourceRouteReplyMessageHandler());
}
public String renderStatusHTML() {
- StringBuffer buf = new StringBuffer();
- buf.append("
I2P Router Console\n");
- buf.append("Router console
\n");
- buf.append("console | stats
\n");
-
- buf.append("");
-
- buf.append("
\n");
-
- if ( (_routerInfo != null) && (_routerInfo.getIdentity() != null) )
- buf.append("Router: ").append(_routerInfo.getIdentity().getHash().toBase64()).append("
\n");
- buf.append("As of: ").append(new Date(Clock.getInstance().now())).append(" (uptime: ").append(DataHelper.formatDuration(getUptime())).append(")
\n");
- buf.append("Started on: ").append(new Date(getWhenStarted())).append("
\n");
- buf.append("Clock offset: ").append(Clock.getInstance().getOffset()).append("ms (OS time: ").append(new Date(Clock.getInstance().now() - Clock.getInstance().getOffset())).append(")
\n");
- long tot = Runtime.getRuntime().totalMemory()/1024;
- long free = Runtime.getRuntime().freeMemory()/1024;
- buf.append("Memory: In use: ").append((tot-free)).append("KB Free: ").append(free).append("KB
\n");
- buf.append("Version: Router: ").append(RouterVersion.VERSION).append(" / SDK: ").append(CoreVersion.VERSION).append("
\n");
- if (_higherVersionSeen)
- buf.append("HIGHER VERSION SEEN - please check to see if there is a new release out
\n");
-
- buf.append("
Bandwidth
\n");
- long sent = BandwidthLimiter.getInstance().getTotalSendBytes();
- long received = BandwidthLimiter.getInstance().getTotalReceiveBytes();
- buf.append("");
-
- buf.append("- ").append(sent).append(" bytes sent, ");
- buf.append(received).append(" bytes received
");
-
- DecimalFormat fmt = new DecimalFormat("##0.00");
-
- // we use the unadjusted time, since thats what getWhenStarted is based off
- long lifetime = Clock.getInstance().now()-Clock.getInstance().getOffset() - getWhenStarted();
- lifetime /= 1000;
- if ( (sent > 0) && (received > 0) ) {
- double sendKBps = sent / (lifetime*1024.0);
- double receivedKBps = received / (lifetime*1024.0);
- buf.append("- Lifetime rate: ");
- buf.append(fmt.format(sendKBps)).append("KBps sent ");
- buf.append(fmt.format(receivedKBps)).append("KBps received");
- buf.append("
");
- }
+ StringBuffer buf = new StringBuffer();
+ buf.append("I2P Router Console\n");
+ buf.append("Router console
\n");
+ buf.append("console | stats
\n");
- RateStat sendRate = StatManager.getInstance().getRate("transport.sendMessageSize");
- for (int i = 0; i < sendRate.getPeriods().length; i++) {
- Rate rate = sendRate.getRate(sendRate.getPeriods()[i]);
- double bytes = rate.getLastTotalValue() + rate.getCurrentTotalValue();
- long ms = rate.getLastTotalEventTime() + rate.getLastTotalEventTime();
- if (ms <= 0) {
- bytes = 0;
- ms = 1;
- }
- buf.append("- ");
- buf.append(DataHelper.formatDuration(rate.getPeriod())).append(" instantaneous send avg: ");
- double bps = bytes*1000.0d/ms;
- if (bps > 2048) {
- bps /= 1024.0d;
- buf.append(fmt.format(bps)).append(" KBps");
- } else {
- buf.append(fmt.format(bps)).append(" Bps");
- }
- buf.append(" over ").append((long)bytes).append(" bytes");
- buf.append("
- ");
- buf.append(DataHelper.formatDuration(rate.getPeriod())).append(" period send avg: ");
- // we include lastPeriod + current *partial* period, and jrandom is too lazy to calculate how
- // much of that partial is contained here, so 2*period it is.
- bps = bytes*1000.0d/(2*rate.getPeriod());
- if (bps > 2048) {
- bps /= 1024.0d;
- buf.append(fmt.format(bps)).append(" KBps");
- } else {
- buf.append(fmt.format(bps)).append(" Bps");
- }
- buf.append(" over ").append((long)bytes).append(" bytes");
- buf.append("
");
- }
-
- RateStat receiveRate = StatManager.getInstance().getRate("transport.receiveMessageSize");
- for (int i = 0; i < receiveRate.getPeriods().length; i++) {
- Rate rate = receiveRate.getRate(receiveRate.getPeriods()[i]);
- double bytes = rate.getLastTotalValue() + rate.getCurrentTotalValue();
- long ms = rate.getLastTotalEventTime() + rate.getLastTotalEventTime();
- if (ms <= 0) {
- bytes = 0;
- ms = 1;
- }
- buf.append("- ");
- buf.append(DataHelper.formatDuration(rate.getPeriod())).append(" instantaneous receive avg: ");
- double bps = bytes*1000.0d/ms;
- if (bps > 2048) {
- bps /= 1024.0d;
- buf.append(fmt.format(bps)).append(" KBps ");
- } else {
- buf.append(fmt.format(bps)).append(" Bps ");
- }
- buf.append(" over ").append((long)bytes).append(" bytes");
- buf.append("
- ");
- buf.append(DataHelper.formatDuration(rate.getPeriod())).append(" period receive avg: ");
- // we include lastPeriod + current *partial* period, and jrandom is too lazy to calculate how
- // much of that partial is contained here, so 2*period it is.
- bps = bytes*1000.0d/(2*rate.getPeriod());
- if (bps > 2048) {
- bps /= 1024.0d;
- buf.append(fmt.format(bps)).append(" KBps");
- } else {
- buf.append(fmt.format(bps)).append(" Bps");
- }
- buf.append(" over ").append((long)bytes).append(" bytes");
- buf.append("
");
- }
-
- buf.append("
\n");
- buf.append("Instantaneous averages count how fast the transfers go when we're trying to transfer data, ");
- buf.append("while period averages count how fast the transfers go across the entire period, even when we're not ");
- buf.append("trying to transfer data. Lifetime averages count how many elephants there are on the moon [like anyone reads this text]");
- buf.append("\n");
-
- buf.append("
\n");
- buf.append(ClientManagerFacade.getInstance().renderStatusHTML());
- buf.append("\n
\n");
- buf.append(CommSystemFacade.getInstance().renderStatusHTML());
- buf.append("\n
\n");
- buf.append(PeerManagerFacade.getInstance().renderStatusHTML());
- buf.append("\n
\n");
- buf.append(TunnelManagerFacade.getInstance().renderStatusHTML());
- buf.append("\n
\n");
- buf.append(JobQueue.getInstance().renderStatusHTML());
- buf.append("\n
\n");
- buf.append(Shitlist.getInstance().renderStatusHTML());
- buf.append("\n
\n");
- buf.append(OutboundMessageRegistry.getInstance().renderStatusHTML());
- buf.append("\n
\n");
- buf.append(NetworkDatabaseFacade.getInstance().renderStatusHTML());
- buf.append("\n
\n");
- List msgs = LogConsoleBuffer.getInstance().getMostRecentMessages();
- buf.append("\nMost recent console messages:
\n");
- for (Iterator iter = msgs.iterator(); iter.hasNext(); ) {
- String msg = (String)iter.next();
- buf.append("").append(msg);
- buf.append(" |
\n");
- }
- buf.append("
");
- buf.append("\n");
- return buf.toString();
+ buf.append("");
+
+ buf.append("
\n");
+
+ if ( (_routerInfo != null) && (_routerInfo.getIdentity() != null) )
+ buf.append("Router: ").append(_routerInfo.getIdentity().getHash().toBase64()).append("
\n");
+ buf.append("As of: ").append(new Date(Clock.getInstance().now())).append(" (uptime: ").append(DataHelper.formatDuration(getUptime())).append(")
\n");
+ buf.append("Started on: ").append(new Date(getWhenStarted())).append("
\n");
+ buf.append("Clock offset: ").append(Clock.getInstance().getOffset()).append("ms (OS time: ").append(new Date(Clock.getInstance().now() - Clock.getInstance().getOffset())).append(")
\n");
+ long tot = Runtime.getRuntime().totalMemory()/1024;
+ long free = Runtime.getRuntime().freeMemory()/1024;
+ buf.append("Memory: In use: ").append((tot-free)).append("KB Free: ").append(free).append("KB
\n");
+ buf.append("Version: Router: ").append(RouterVersion.VERSION).append(" / SDK: ").append(CoreVersion.VERSION).append("
\n");
+ if (_higherVersionSeen)
+ buf.append("HIGHER VERSION SEEN - please check to see if there is a new release out
\n");
+
+ buf.append("
Bandwidth
\n");
+ long sent = BandwidthLimiter.getInstance().getTotalSendBytes();
+ long received = BandwidthLimiter.getInstance().getTotalReceiveBytes();
+ buf.append("");
+
+ buf.append("- ").append(sent).append(" bytes sent, ");
+ buf.append(received).append(" bytes received
");
+
+ DecimalFormat fmt = new DecimalFormat("##0.00");
+
+ // we use the unadjusted time, since thats what getWhenStarted is based off
+ long lifetime = Clock.getInstance().now()-Clock.getInstance().getOffset() - getWhenStarted();
+ lifetime /= 1000;
+ if ( (sent > 0) && (received > 0) ) {
+ double sendKBps = sent / (lifetime*1024.0);
+ double receivedKBps = received / (lifetime*1024.0);
+ buf.append("- Lifetime rate: ");
+ buf.append(fmt.format(sendKBps)).append("KBps sent ");
+ buf.append(fmt.format(receivedKBps)).append("KBps received");
+ buf.append("
");
+ }
+
+ RateStat sendRate = StatManager.getInstance().getRate("transport.sendMessageSize");
+ for (int i = 0; i < sendRate.getPeriods().length; i++) {
+ Rate rate = sendRate.getRate(sendRate.getPeriods()[i]);
+ double bytes = rate.getLastTotalValue() + rate.getCurrentTotalValue();
+ long ms = rate.getLastTotalEventTime() + rate.getLastTotalEventTime();
+ if (ms <= 0) {
+ bytes = 0;
+ ms = 1;
+ }
+ buf.append("- ");
+ buf.append(DataHelper.formatDuration(rate.getPeriod())).append(" instantaneous send avg: ");
+ double bps = bytes*1000.0d/ms;
+ if (bps > 2048) {
+ bps /= 1024.0d;
+ buf.append(fmt.format(bps)).append(" KBps");
+ } else {
+ buf.append(fmt.format(bps)).append(" Bps");
+ }
+ buf.append(" over ").append((long)bytes).append(" bytes");
+ buf.append("
- ");
+ buf.append(DataHelper.formatDuration(rate.getPeriod())).append(" period send avg: ");
+ // we include lastPeriod + current *partial* period, and jrandom is too lazy to calculate how
+ // much of that partial is contained here, so 2*period it is.
+ bps = bytes*1000.0d/(2*rate.getPeriod());
+ if (bps > 2048) {
+ bps /= 1024.0d;
+ buf.append(fmt.format(bps)).append(" KBps");
+ } else {
+ buf.append(fmt.format(bps)).append(" Bps");
+ }
+ buf.append(" over ").append((long)bytes).append(" bytes");
+ buf.append("
");
+ }
+
+ RateStat receiveRate = StatManager.getInstance().getRate("transport.receiveMessageSize");
+ for (int i = 0; i < receiveRate.getPeriods().length; i++) {
+ Rate rate = receiveRate.getRate(receiveRate.getPeriods()[i]);
+ double bytes = rate.getLastTotalValue() + rate.getCurrentTotalValue();
+ long ms = rate.getLastTotalEventTime() + rate.getLastTotalEventTime();
+ if (ms <= 0) {
+ bytes = 0;
+ ms = 1;
+ }
+ buf.append("- ");
+ buf.append(DataHelper.formatDuration(rate.getPeriod())).append(" instantaneous receive avg: ");
+ double bps = bytes*1000.0d/ms;
+ if (bps > 2048) {
+ bps /= 1024.0d;
+ buf.append(fmt.format(bps)).append(" KBps ");
+ } else {
+ buf.append(fmt.format(bps)).append(" Bps ");
+ }
+ buf.append(" over ").append((long)bytes).append(" bytes");
+ buf.append("
- ");
+ buf.append(DataHelper.formatDuration(rate.getPeriod())).append(" period receive avg: ");
+ // we include lastPeriod + current *partial* period, and jrandom is too lazy to calculate how
+ // much of that partial is contained here, so 2*period it is.
+ bps = bytes*1000.0d/(2*rate.getPeriod());
+ if (bps > 2048) {
+ bps /= 1024.0d;
+ buf.append(fmt.format(bps)).append(" KBps");
+ } else {
+ buf.append(fmt.format(bps)).append(" Bps");
+ }
+ buf.append(" over ").append((long)bytes).append(" bytes");
+ buf.append("
");
+ }
+
+ buf.append("
\n");
+ buf.append("Instantaneous averages count how fast the transfers go when we're trying to transfer data, ");
+ buf.append("while period averages count how fast the transfers go across the entire period, even when we're not ");
+ buf.append("trying to transfer data. Lifetime averages count how many elephants there are on the moon [like anyone reads this text]");
+ buf.append("\n");
+
+ buf.append("
\n");
+ buf.append(ClientManagerFacade.getInstance().renderStatusHTML());
+ buf.append("\n
\n");
+ buf.append(CommSystemFacade.getInstance().renderStatusHTML());
+ buf.append("\n
\n");
+ buf.append(PeerManagerFacade.getInstance().renderStatusHTML());
+ buf.append("\n
\n");
+ buf.append(TunnelManagerFacade.getInstance().renderStatusHTML());
+ buf.append("\n
\n");
+ buf.append(JobQueue.getInstance().renderStatusHTML());
+ buf.append("\n
\n");
+ buf.append(Shitlist.getInstance().renderStatusHTML());
+ buf.append("\n
\n");
+ buf.append(OutboundMessageRegistry.getInstance().renderStatusHTML());
+ buf.append("\n
\n");
+ buf.append(NetworkDatabaseFacade.getInstance().renderStatusHTML());
+ buf.append("\n
\n");
+ List msgs = LogConsoleBuffer.getInstance().getMostRecentMessages();
+ buf.append("\nMost recent console messages:
\n");
+ for (Iterator iter = msgs.iterator(); iter.hasNext(); ) {
+ String msg = (String)iter.next();
+ buf.append("").append(msg);
+ buf.append(" |
\n");
+ }
+ buf.append("
");
+ buf.append("\n");
+ return buf.toString();
}
public void shutdown() {
- try { JobQueue.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the job queue", t); }
- try { StatisticsManager.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats manager", t); }
- try { ClientManagerFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the client manager", t); }
- try { TunnelManagerFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the tunnel manager", t); }
- try { NetworkDatabaseFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the networkDb", t); }
- try { CommSystemFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the comm system", t); }
- try { PeerManagerFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the peer manager", t); }
- try { SessionKeyPersistenceHelper.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the session key manager", t); }
- dumpStats();
- _log.log(Log.CRIT, "Shutdown complete", new Exception("Shutdown"));
- try { LogManager.getInstance().shutdown(); } catch (Throwable t) { }
- try { Thread.sleep(1000); } catch (InterruptedException ie) {}
- Runtime.getRuntime().halt(-1);
+ try { JobQueue.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the job queue", t); }
+ try { StatisticsManager.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats manager", t); }
+ try { ClientManagerFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the client manager", t); }
+ try { TunnelManagerFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the tunnel manager", t); }
+ try { NetworkDatabaseFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the networkDb", t); }
+ try { CommSystemFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the comm system", t); }
+ try { PeerManagerFacade.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the peer manager", t); }
+ try { SessionKeyPersistenceHelper.getInstance().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the session key manager", t); }
+ dumpStats();
+ _log.log(Log.CRIT, "Shutdown complete", new Exception("Shutdown"));
+ try { LogManager.getInstance().shutdown(); } catch (Throwable t) { }
+ try { Thread.sleep(1000); } catch (InterruptedException ie) {}
+ Runtime.getRuntime().halt(-1);
}
private void dumpStats() {
- _log.log(Log.CRIT, "Lifetime stats:\n\n" + StatsGenerator.generateStatsPage());
+ _log.log(Log.CRIT, "Lifetime stats:\n\n" + StatsGenerator.generateStatsPage());
}
public static void main(String args[]) {
- Router.getInstance().runRouter();
- if (args.length > 0) {
- _log.info("Not interactive");
- } else {
- _log.info("Interactive");
- try {
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- String line = null;
- while ( (line = in.readLine()) != null) {
- ClientMessagePool.getInstance().dumpPoolInfo();
- OutNetMessagePool.getInstance().dumpPoolInfo();
- InNetMessagePool.getInstance().dumpPoolInfo();
- }
- } catch (IOException ioe) {
- _log.error("Error dumping queue", ioe);
- }
- }
+ Router.getInstance().runRouter();
}
private class ShutdownHook extends Thread {
- public void run() {
- _log.log(Log.CRIT, "Shutting down the router...", new Exception("Shutting down"));
- shutdown();
- }
+ public void run() {
+ _log.log(Log.CRIT, "Shutting down the router...", new Exception("Shutting down"));
+ shutdown();
+ }
}
/** update the router.info file whenever its, er, updated */
private static class PersistRouterInfoJob extends JobImpl {
- public String getName() { return "Persist Updated Router Information"; }
- public void runJob() {
- if (_log.shouldLog(Log.DEBUG))
- _log.debug("Persisting updated router info");
-
- String infoFilename = Router.getInstance().getConfigSetting(PROP_INFO_FILENAME);
- if (infoFilename == null)
- infoFilename = PROP_INFO_FILENAME_DEFAULT;
-
- RouterInfo info = Router.getInstance().getRouterInfo();
-
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(infoFilename);
- info.writeBytes(fos);
- } catch (DataFormatException dfe) {
- _log.error("Error rebuilding the router information", dfe);
- } catch (IOException ioe) {
- _log.error("Error writing out the rebuilt router information", ioe);
- } finally {
- if (fos != null) try { fos.close(); } catch (IOException ioe) {}
- }
- }
+ public String getName() { return "Persist Updated Router Information"; }
+ public void runJob() {
+ if (_log.shouldLog(Log.DEBUG))
+ _log.debug("Persisting updated router info");
+
+ String infoFilename = Router.getInstance().getConfigSetting(PROP_INFO_FILENAME);
+ if (infoFilename == null)
+ infoFilename = PROP_INFO_FILENAME_DEFAULT;
+
+ RouterInfo info = Router.getInstance().getRouterInfo();
+
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(infoFilename);
+ info.writeBytes(fos);
+ } catch (DataFormatException dfe) {
+ _log.error("Error rebuilding the router information", dfe);
+ } catch (IOException ioe) {
+ _log.error("Error writing out the rebuilt router information", ioe);
+ } finally {
+ if (fos != null) try { fos.close(); } catch (IOException ioe) {}
+ }
+ }
}
}