I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Unverified Commit c4fd1b61 authored by zzz's avatar zzz
Browse files

Router: Simplify published stats values

to be only what stats.i2p needs
Disabled until next release, to preserve dev build anonymity,
tested while enabled
Commented out unsed code
ref: http://zzz.i2p/topics/3515
parent 841e2771
No related branches found
No related tags found
No related merge requests found
...@@ -35,16 +35,19 @@ public class StatisticsManager { ...@@ -35,16 +35,19 @@ public class StatisticsManager {
private final String _networkID; private final String _networkID;
public final static String PROP_PUBLISH_RANKINGS = "router.publishPeerRankings"; public final static String PROP_PUBLISH_RANKINGS = "router.publishPeerRankings";
private static final String PROP_CONTACT_NAME = "netdb.contact"; //private static final String PROP_CONTACT_NAME = "netdb.contact";
/** enhance anonymity by only including build stats one out of this many times */ /** enhance anonymity by only including build stats one out of this many times */
private static final int RANDOM_INCLUDE_STATS = 16; private static final int RANDOM_INCLUDE_STATS = 16;
//// remove after release ////
private static final boolean SIMPLE_STATS = CoreVersion.PUBLISHED_VERSION.equals("0.9.58");
private final DecimalFormat _fmt; private final DecimalFormat _fmt;
private final DecimalFormat _pct; private final DecimalFormat _pct;
public StatisticsManager(RouterContext context) { public StatisticsManager(RouterContext context) {
_context = context; _context = context;
_fmt = new DecimalFormat("###,##0.00", new DecimalFormatSymbols(Locale.UK)); _fmt = SIMPLE_STATS ? new DecimalFormat("0.00") :
new DecimalFormat("###,##0.00", new DecimalFormatSymbols(Locale.UK));
_pct = new DecimalFormat("#0.00%", new DecimalFormatSymbols(Locale.UK)); _pct = new DecimalFormat("#0.00%", new DecimalFormatSymbols(Locale.UK));
_log = context.logManager().getLog(StatisticsManager.class); _log = context.logManager().getLog(StatisticsManager.class);
// null for some tests // null for some tests
...@@ -238,7 +241,25 @@ public class StatisticsManager { ...@@ -238,7 +241,25 @@ public class StatisticsManager {
} }
} }
/**
* Simple format, only what stats.i2p needs:
*<pre>
* average
*</pre>
*
* Previous format:
*<pre>
* avg;extreme avg;pct of lifetime avg;
* if lifetime total event time greater than zero:
* lastEventSaturation;lastSaturationLimit;extremeEventSaturation;extremeSaturationLimit;
* event count;
* if number of periods greater than zero:
* avg freq;exteremeEventCount;lifetimeEventCount;
*</pre>
*/
private String renderRate(Rate rate, boolean fudgeQuantity) { private String renderRate(Rate rate, boolean fudgeQuantity) {
if (SIMPLE_STATS)
return num(rate.getAverageValue());
StringBuilder buf = new StringBuilder(128); StringBuilder buf = new StringBuilder(128);
buf.append(num(rate.getAverageValue())).append(';'); buf.append(num(rate.getAverageValue())).append(';');
buf.append(num(rate.getExtremeAverageValue())).append(';'); buf.append(num(rate.getExtremeAverageValue())).append(';');
...@@ -296,7 +317,17 @@ public class StatisticsManager { ...@@ -296,7 +317,17 @@ public class StatisticsManager {
} }
} }
/**
* Simple format, only what stats.i2p needs:
*<pre>
* 0;0;0;percent or event count
*</pre>
*
* Previous format: see above
*/
private String renderRate(Rate rate, double fudgeQuantity) { private String renderRate(Rate rate, double fudgeQuantity) {
if (SIMPLE_STATS)
return "0;0;0;" + num(fudgeQuantity);
StringBuilder buf = new StringBuilder(128); StringBuilder buf = new StringBuilder(128);
buf.append(num(rate.getAverageValue())).append(';'); buf.append(num(rate.getAverageValue())).append(';');
buf.append(num(rate.getExtremeAverageValue())).append(';'); buf.append(num(rate.getExtremeAverageValue())).append(';');
...@@ -310,6 +341,7 @@ public class StatisticsManager { ...@@ -310,6 +341,7 @@ public class StatisticsManager {
} }
/* report the same data for tx and rx, for enhanced anonymity */ /* report the same data for tx and rx, for enhanced anonymity */
/*
private void includeAverageThroughput(Properties stats) { private void includeAverageThroughput(Properties stats) {
RateStat sendRate = _context.statManager().getRate("bw.sendRate"); RateStat sendRate = _context.statManager().getRate("bw.sendRate");
RateStat recvRate = _context.statManager().getRate("bw.recvRate"); RateStat recvRate = _context.statManager().getRate("bw.recvRate");
...@@ -325,6 +357,7 @@ public class StatisticsManager { ...@@ -325,6 +357,7 @@ public class StatisticsManager {
stats.setProperty("stat_bandwidthSendBps.60m", str); stats.setProperty("stat_bandwidthSendBps.60m", str);
stats.setProperty("stat_bandwidthReceiveBps.60m", str); stats.setProperty("stat_bandwidthReceiveBps.60m", str);
} }
*/
private static String getPeriod(Rate rate) { return DataHelper.formatDuration(rate.getPeriod()); } private static String getPeriod(Rate rate) { return DataHelper.formatDuration(rate.getPeriod()); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment