forked from I2P_Developers/i2p.i2p
@ -171,7 +171,8 @@ class SummaryRenderer {
|
||||
def.setMinValue(0d);
|
||||
String name = _listener.getRate().getRateStat().getName();
|
||||
// heuristic to set K=1024
|
||||
if ((name.startsWith("bw.") || name.indexOf("Size") >= 0 || name.indexOf("Bps") >= 0 || name.indexOf("memory") >= 0)
|
||||
//if ((name.startsWith("bw.") || name.indexOf("Size") >= 0 || name.indexOf("Bps") >= 0 || name.indexOf("memory") >= 0)
|
||||
if ((name.indexOf("Size") >= 0 || name.indexOf("memory") >= 0)
|
||||
&& !showEvents)
|
||||
def.setBase(1024);
|
||||
if (titleOverride != null) {
|
||||
@ -192,8 +193,8 @@ class SummaryRenderer {
|
||||
}
|
||||
String path = _listener.getData().getPath();
|
||||
String dsNames[] = _listener.getData().getDsNames();
|
||||
String plotName = null;
|
||||
String descr = null;
|
||||
String plotName;
|
||||
String descr;
|
||||
if (showEvents) {
|
||||
// include the average event count on the plot
|
||||
plotName = dsNames[1];
|
||||
|
@ -24,7 +24,7 @@ public class ConfigLoggingHelper extends HelperBase {
|
||||
}
|
||||
public String getMaxFileSize() {
|
||||
int bytes = _context.logManager().getFileSize();
|
||||
if (bytes <= 0) return "1.00 MB";
|
||||
if (bytes <= 0) return "1.00 MiB";
|
||||
return DataHelper.formatSize2(bytes, false) + 'B';
|
||||
}
|
||||
public String getLogLevelTable() {
|
||||
|
@ -502,12 +502,12 @@ public class ConfigNetHandler extends FormHandler {
|
||||
!_inboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH,
|
||||
Integer.toString(FIFOBandwidthRefiller.DEFAULT_INBOUND_BURST_BANDWIDTH)))) {
|
||||
try {
|
||||
int rate = Integer.parseInt(_inboundRate);
|
||||
int kb = DEF_BURST_TIME * rate;
|
||||
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, Integer.toString(rate));
|
||||
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, Integer.toString(kb));
|
||||
float rate = Integer.parseInt(_inboundRate) / 1.024f;
|
||||
float kb = DEF_BURST_TIME * rate;
|
||||
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, Integer.toString(Math.round(rate)));
|
||||
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, Integer.toString(Math.round(kb)));
|
||||
rate -= Math.min(rate * DEF_BURST_PCT / 100, 50);
|
||||
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, Integer.toString(rate));
|
||||
changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, Integer.toString(Math.round(rate)));
|
||||
bwUpdated = true;
|
||||
} catch (NumberFormatException nfe) {
|
||||
addFormError(_t("Invalid bandwidth"));
|
||||
@ -517,12 +517,12 @@ public class ConfigNetHandler extends FormHandler {
|
||||
!_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH,
|
||||
Integer.toString(FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BURST_BANDWIDTH)))) {
|
||||
try {
|
||||
int rate = Integer.parseInt(_outboundRate);
|
||||
int kb = DEF_BURST_TIME * rate;
|
||||
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, Integer.toString(rate));
|
||||
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, Integer.toString(kb));
|
||||
float rate = Integer.parseInt(_outboundRate) / 1.024f;
|
||||
float kb = DEF_BURST_TIME * rate;
|
||||
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, Integer.toString(Math.round(rate)));
|
||||
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, Integer.toString(Math.round(kb)));
|
||||
rate -= Math.min(rate * DEF_BURST_PCT / 100, 50);
|
||||
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, Integer.toString(rate));
|
||||
changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, Integer.toString(Math.round(rate)));
|
||||
bwUpdated = true;
|
||||
} catch (NumberFormatException nfe) {
|
||||
addFormError(_t("Invalid bandwidth"));
|
||||
|
@ -243,36 +243,46 @@ public class ConfigNetHelper extends HelperBase {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/** @return decimal */
|
||||
public String getInboundRate() {
|
||||
return Integer.toString(_context.bandwidthLimiter().getInboundKBytesPerSecond());
|
||||
return Integer.toString(Math.round(_context.bandwidthLimiter().getInboundKBytesPerSecond() * 1.024f));
|
||||
}
|
||||
|
||||
/** @return decimal */
|
||||
public String getOutboundRate() {
|
||||
return Integer.toString(_context.bandwidthLimiter().getOutboundKBytesPerSecond());
|
||||
return Integer.toString(Math.round(_context.bandwidthLimiter().getOutboundKBytesPerSecond() * 1.024f));
|
||||
}
|
||||
|
||||
/** @return decimal */
|
||||
public String getInboundBurstRateBits() {
|
||||
return kbytesToBits(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond());
|
||||
}
|
||||
|
||||
/** @return decimal */
|
||||
public String getOutboundBurstRateBits() {
|
||||
return kbytesToBits(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond());
|
||||
}
|
||||
|
||||
/** @return decimal */
|
||||
public String getShareRateBits() {
|
||||
return kbytesToBits(getShareBandwidth());
|
||||
}
|
||||
private String kbytesToBits(int kbytes) {
|
||||
return DataHelper.formatSize(kbytes * (8 * 1024L)) + ' ' + _t("bits per second") +
|
||||
' ' + _t("or {0} bytes per month maximum", DataHelper.formatSize(kbytes * (1024L * 60 * 60 * 24 * 31)));
|
||||
|
||||
/** @param kbytes binary K */
|
||||
private String kbytesToBits(float kbytes) {
|
||||
return DataHelper.formatSize2Decimal((long) (kbytes * (8 * 1024))) + _t("bits per second") +
|
||||
"; " +
|
||||
_t("{0}Bytes per month maximum", DataHelper.formatSize2Decimal((long) (kbytes * (1024L * 60 * 60 * 24 * 31))));
|
||||
}
|
||||
|
||||
/** @return decimal */
|
||||
public String getInboundBurstRate() {
|
||||
return Integer.toString(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond());
|
||||
return Integer.toString(Math.round(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond() * 1.024f));
|
||||
}
|
||||
|
||||
/** @return decimal */
|
||||
public String getOutboundBurstRate() {
|
||||
return Integer.toString(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond());
|
||||
return Integer.toString(Math.round(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond() * 1.024f));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -350,7 +360,7 @@ public class ConfigNetHelper extends HelperBase {
|
||||
public static final int DEFAULT_SHARE_KBPS = 12;
|
||||
|
||||
/**
|
||||
* @return in KBytes per second
|
||||
* @return in binary KBytes per second
|
||||
*/
|
||||
public int getShareBandwidth() {
|
||||
int irateKBps = _context.bandwidthLimiter().getInboundKBytesPerSecond();
|
||||
|
@ -224,7 +224,7 @@ public class PeerHelper extends HelperBase {
|
||||
buf.append("</span></td><td class=\"cells\" align=\"center\"><span class=\"right\">");
|
||||
if (con.getTimeSinceReceive() < 2*60*1000) {
|
||||
float r = con.getRecvRate();
|
||||
buf.append(formatRate(r / 1024));
|
||||
buf.append(formatRate(r / 1000));
|
||||
bpsRecv += r;
|
||||
} else {
|
||||
buf.append(formatRate(0));
|
||||
@ -232,7 +232,7 @@ public class PeerHelper extends HelperBase {
|
||||
buf.append("</span>").append(THINSP).append("<span class=\"left\">");
|
||||
if (con.getTimeSinceSend() < 2*60*1000) {
|
||||
float r = con.getSendRate();
|
||||
buf.append(formatRate(r / 1024));
|
||||
buf.append(formatRate(r / 1000));
|
||||
bpsSend += r;
|
||||
} else {
|
||||
buf.append(formatRate(0));
|
||||
@ -268,8 +268,8 @@ public class PeerHelper extends HelperBase {
|
||||
// buf.append("<tr> <td colspan=\"11\"><hr></td></tr>\n");
|
||||
buf.append("<tr class=\"tablefooter\"><td colspan=\"4\" align=\"left\"><b>")
|
||||
.append(ngettext("{0} peer", "{0} peers", peers.size()));
|
||||
buf.append("</b></td><td align=\"center\" nowrap><span class=\"right\"><b>").append(formatRate(bpsRecv/1024)).append("</b></span>");
|
||||
buf.append(THINSP).append("<span class=\"left\"><b>").append(formatRate(bpsSend/1024)).append("</b></span>");
|
||||
buf.append("</b></td><td align=\"center\" nowrap><span class=\"right\"><b>").append(formatRate(bpsRecv/1000)).append("</b></span>");
|
||||
buf.append(THINSP).append("<span class=\"left\"><b>").append(formatRate(bpsSend/1000)).append("</b></span>");
|
||||
buf.append("</td><td align=\"right\"><b>").append(DataHelper.formatDuration2(totalUptime/peers.size()));
|
||||
buf.append("</b></td><td align=\"right\"><b>").append(DataHelper.formatDuration2(offsetTotal*1000/peers.size()));
|
||||
buf.append("</b></td><td align=\"right\"><b>").append(totalSend).append("</b></td><td align=\"right\"><b>").append(totalRecv);
|
||||
@ -634,7 +634,7 @@ public class PeerHelper extends HelperBase {
|
||||
|
||||
private static final String formatKBps(int bps) {
|
||||
synchronized (_fmt) {
|
||||
return _fmt.format((float)bps/1024);
|
||||
return _fmt.format((float)bps/1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ class ProfileOrganizerRenderer {
|
||||
.append("<td><b>U</b></td><td>").append(_t("Unreachable")).append("</td>")
|
||||
.append("<td> </td></tr>");
|
||||
buf.append("<tr><td> </td>")
|
||||
.append("<td><b>X</b></td><td>").append(_t("Over {0} shared bandwidth", Router.MIN_BW_X + " KBps")).append("</td>")
|
||||
.append("<td><b>X</b></td><td>").append(_t("Over {0} shared bandwidth", Math.round(Router.MIN_BW_X * 1.024f) + " KBps")).append("</td>")
|
||||
.append("<td> </td><td> </td><td> </td></tr>");
|
||||
buf.append("<tr><td> </td><td colspan=\"5\">").append(_t("Note: For P and X bandwidth tiers, O is included for the purpose of backward compatibility in the NetDB."))
|
||||
.append("</tr>");
|
||||
|
@ -320,7 +320,7 @@ public class SummaryHelper extends HelperBase {
|
||||
// long free = Runtime.getRuntime().freeMemory()/1024/1024;
|
||||
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
||||
// return integerFormatter.format(used) + "MB / " + free + " MB";
|
||||
return integerFormatter.format(used) + " / " + total + " MB";
|
||||
return integerFormatter.format(used) + " / " + total + " MiB";
|
||||
}
|
||||
|
||||
/** @since 0.9.32 */
|
||||
@ -349,7 +349,7 @@ public class SummaryHelper extends HelperBase {
|
||||
// return integerFormatter.format(used) + "MB (" + usedPc + "%)";
|
||||
// return integerFormatter.format(used) + "MB / " + free + " MB";
|
||||
return "<div class=\"percentBarOuter\" id=\"sb_memoryBar\"><div class=\"percentBarText\">RAM: " +
|
||||
integerFormatter.format(used) + " / " + total + " MB" +
|
||||
integerFormatter.format(used) + " / " + total + " MiB" +
|
||||
"</div><div class=\"percentBarInner\" style=\"width: " + integerFormatter.format(usedPc) +
|
||||
"%;\"></div></div>";
|
||||
}
|
||||
@ -498,17 +498,18 @@ public class SummaryHelper extends HelperBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return "x.xx / y.yy {K|M}"
|
||||
* Output is decimal, not binary
|
||||
* @return "x.xx / y.yy {K|M}"
|
||||
*/
|
||||
private static String formatPair(double in, double out) {
|
||||
boolean mega = in >= 1024*1024 || out >= 1024*1024;
|
||||
boolean mega = in >= 1000*1000 || out >= 1000*1000;
|
||||
// scale both the same
|
||||
if (mega) {
|
||||
in /= 1024*1024;
|
||||
out /= 1024*1024;
|
||||
in /= 1000*1000;
|
||||
out /= 1000*1000;
|
||||
} else {
|
||||
in /= 1024;
|
||||
out /= 1024;
|
||||
in /= 1000;
|
||||
out /= 1000;
|
||||
}
|
||||
// control total width
|
||||
DecimalFormat fmt;
|
||||
@ -530,9 +531,7 @@ public class SummaryHelper extends HelperBase {
|
||||
public String getInboundTransferred() {
|
||||
if (_context == null)
|
||||
return "0";
|
||||
|
||||
long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
|
||||
|
||||
return DataHelper.formatSize2(received) + 'B';
|
||||
}
|
||||
|
||||
@ -544,7 +543,6 @@ public class SummaryHelper extends HelperBase {
|
||||
public String getOutboundTransferred() {
|
||||
if (_context == null)
|
||||
return "0";
|
||||
|
||||
long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
|
||||
return DataHelper.formatSize2(sent) + 'B';
|
||||
}
|
||||
@ -957,7 +955,7 @@ public class SummaryHelper extends HelperBase {
|
||||
String status = checker.getStatus();
|
||||
if (status.length() > 0) {
|
||||
// Show status message even if not running, timer in ReseedChecker should remove after 20 minutes
|
||||
buf.append("<div class=\"sb_notice\"><i>").append(checker.getStatus()).append("</i></div>");
|
||||
buf.append("<div class=\"sb_notice\"><i>").append(status).append("</i></div>");
|
||||
}
|
||||
if (!checker.inProgress()) {
|
||||
// If a new reseed isn't running, and the last reseed had errors, show error message
|
||||
|
@ -185,7 +185,7 @@ class TunnelRenderer {
|
||||
+ "<td> </td></tr>");
|
||||
out.write("<tr><td> </td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>P</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_P, Router.MIN_BW_X)) + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>X</b></span></td><td>" + _t("Over {0} shared bandwidth", Router.MIN_BW_X + " KBps") + "</td>"
|
||||
+ "<td><span class=\"tunnel_cap\"><b>X</b></span></td><td>" + _t("Over {0} shared bandwidth", Math.round(Router.MIN_BW_X * 1.024f) + " KBps") + "</td>"
|
||||
+ "<td> </td></tr>");
|
||||
out.write("</tbody></table>");
|
||||
|
||||
@ -193,7 +193,7 @@ class TunnelRenderer {
|
||||
|
||||
/** @since 0.9.33 */
|
||||
static String range(int f, int t) {
|
||||
return f + " - " + t + " KBps";
|
||||
return Math.round(f * 1.024f) + " - " + (Math.round(t * 1.024f) - 1) + " KBps";
|
||||
}
|
||||
|
||||
private static class TunnelComparator implements Comparator<HopConfig>, Serializable {
|
||||
@ -248,7 +248,7 @@ class TunnelRenderer {
|
||||
_t("Outbound") + "\"></td>");
|
||||
out.write("<td class=\"cells\" align=\"center\">" + DataHelper.formatDuration2(timeLeft) + "</td>\n");
|
||||
int count = info.getProcessedMessagesCount();
|
||||
out.write("<td class=\"cells\" align=\"center\">" + count + " KB</td>\n");
|
||||
out.write("<td class=\"cells\" align=\"center\">" + count + " KiB</td>\n");
|
||||
for (int j = 0; j < info.getLength(); j++) {
|
||||
Hash peer = info.getPeer(j);
|
||||
TunnelId id = (info.isInbound() ? info.getReceiveTunnelId(j) : info.getSendTunnelId(j));
|
||||
|
Reference in New Issue
Block a user