From ef93532c9615d5bf350c5ea5f54a98fe8c282d99 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Tue, 25 Oct 2011 21:36:52 +0000 Subject: [PATCH] dont require restart after changing router.publishPeerRankings --- .../src/net/i2p/router/StatisticsManager.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/router/java/src/net/i2p/router/StatisticsManager.java b/router/java/src/net/i2p/router/StatisticsManager.java index 63ac29cfb2..75dcd5ecd3 100644 --- a/router/java/src/net/i2p/router/StatisticsManager.java +++ b/router/java/src/net/i2p/router/StatisticsManager.java @@ -22,16 +22,14 @@ import net.i2p.stat.RateStat; import net.i2p.util.Log; /** - * Maintain the statistics about the router + * Publishes some statistics about the router in the netDB. * */ public class StatisticsManager implements Service { - private Log _log; - private RouterContext _context; - private boolean _includePeerRankings; + private final Log _log; + private final RouterContext _context; public final static String PROP_PUBLISH_RANKINGS = "router.publishPeerRankings"; - public final static String DEFAULT_PROP_PUBLISH_RANKINGS = "true"; private final DecimalFormat _fmt; private final DecimalFormat _pct; @@ -41,17 +39,16 @@ public class StatisticsManager implements Service { _fmt = new DecimalFormat("###,##0.00", new DecimalFormatSymbols(Locale.UK)); _pct = new DecimalFormat("#0.00%", new DecimalFormatSymbols(Locale.UK)); _log = context.logManager().getLog(StatisticsManager.class); - _includePeerRankings = false; } + /** noop */ public void shutdown() {} - public void restart() { - startup(); - } - public void startup() { - String val = _context.getProperty(PROP_PUBLISH_RANKINGS, DEFAULT_PROP_PUBLISH_RANKINGS); - _includePeerRankings = Boolean.valueOf(val); - } + + /** noop */ + public void restart() {} + + /** noop */ + public void startup() {} /** Retrieve a snapshot of the statistics that should be published */ public Properties publishStatistics() { @@ -85,7 +82,7 @@ public class StatisticsManager implements Service { stats.setProperty("stat_identities", newlines+""); ***/ - if (_includePeerRankings) { + if (_context.getBooleanPropertyDefaultTrue(PROP_PUBLISH_RANKINGS)) { long publishedUptime = _context.router().getUptime(); // Don't publish these for first hour if (publishedUptime > 62*60*1000) @@ -287,6 +284,7 @@ public class StatisticsManager implements Service { if (num < 0) num = 0; synchronized (_fmt) { return _fmt.format(num); } } + private final String pct(double num) { if (num < 0) num = 0; synchronized (_pct) { return _pct.format(num); } -- GitLab