Router: Parameterize bandwidth classes, fix display on /tunnels

This commit is contained in:
zzz
2017-12-05 15:53:05 +00:00
parent 7f5f764aba
commit 692790c4ed
2 changed files with 32 additions and 12 deletions

View File

@ -150,21 +150,26 @@ class TunnelRenderer {
out.write("<h3 class=\"tabletitle\">" + _t("Bandwidth Tiers") + "</h3>\n");
out.write("<table id=\"tunnel_defs\"><tbody>");
out.write("<tr><td>&nbsp;</td>"
+ "<td><span class=\"tunnel_cap\"><b>L</b></span></td><td>" + _t("{0} shared bandwidth", "12 - 32KBps") + "</td>"
+ "<td><span class=\"tunnel_cap\"><b>M</b></span></td><td>" + _t("{0} shared bandwidth", "32 - 64KBps") + "</td>"
+ "<td><span class=\"tunnel_cap\"><b>L</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_L, Router.MIN_BW_M)) + "</td>"
+ "<td><span class=\"tunnel_cap\"><b>M</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_M, Router.MIN_BW_N)) + "</td>"
+ "<td>&nbsp;</td></tr>");
out.write("<tr><td>&nbsp;</td>"
+ "<td><span class=\"tunnel_cap\"><b>N</b></span></td><td>" + _t("{0} shared bandwidth", "64 - 128KBps") + "</td>"
+ "<td><span class=\"tunnel_cap\"><b>O</b></span></td><td>" + _t("{0} shared bandwidth", "128 - 256KBps") + "</td>"
+ "<td><span class=\"tunnel_cap\"><b>N</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_N, Router.MIN_BW_O)) + "</td>"
+ "<td><span class=\"tunnel_cap\"><b>O</b></span></td><td>" + _t("{0} shared bandwidth", range(Router.MIN_BW_O, Router.MIN_BW_P)) + "</td>"
+ "<td>&nbsp;</td></tr>");
out.write("<tr><td>&nbsp;</td>"
+ "<td><span class=\"tunnel_cap\"><b>P</b></span></td><td>" + _t("{0} shared bandwidth", "256 - 2000KBps") + "</td>"
+ "<td><span class=\"tunnel_cap\"><b>X</b></span></td><td>" + _t("Over {0} shared bandwidth", "2000KBps") + "</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>&nbsp;</td></tr>");
out.write("</tbody></table>");
}
/** @since 0.9.33 */
private static String range(int f, int t) {
return f + " - " + t + " KBps";
}
private static class TunnelComparator implements Comparator<HopConfig>, Serializable {
public int compare(HopConfig l, HopConfig r) {
return (r.getProcessedMessagesCount() - l.getProcessedMessagesCount());

View File

@ -952,6 +952,21 @@ public class Router implements RouterClock.ClockShiftListener {
@Deprecated
public static final char CAPABILITY_NEW_TUNNEL = 'T';
/** @since 0.9.33 */
public static final int MIN_BW_K = 0;
/** @since 0.9.33 */
public static final int MIN_BW_L = 12;
/** @since 0.9.33 */
public static final int MIN_BW_M = 48;
/** @since 0.9.33 */
public static final int MIN_BW_N = 64;
/** @since 0.9.33 */
public static final int MIN_BW_O = 128;
/** @since 0.9.33 */
public static final int MIN_BW_P = 256;
/** @since 0.9.33 */
public static final int MIN_BW_X = 2000;
/**
* The current bandwidth class.
* For building our RI. Not for external use.
@ -967,17 +982,17 @@ public class Router implements RouterClock.ClockShiftListener {
String force = _context.getProperty(PROP_FORCE_BWCLASS);
if (force != null && force.length() > 0) {
return force.charAt(0);
} else if (bwLim < 12) {
} else if (bwLim < MIN_BW_L) {
return CAPABILITY_BW12;
} else if (bwLim <= 48) {
} else if (bwLim <= MIN_BW_M) {
return CAPABILITY_BW32;
} else if (bwLim <= 64) {
} else if (bwLim <= MIN_BW_N) {
return CAPABILITY_BW64;
} else if (bwLim <= 128) {
} else if (bwLim <= MIN_BW_O) {
return CAPABILITY_BW128;
} else if (bwLim <= 256) {
} else if (bwLim <= MIN_BW_P) {
return CAPABILITY_BW256;
} else if (bwLim <= 2000) { // TODO adjust threshold
} else if (bwLim <= MIN_BW_X) { // TODO adjust threshold
// 512 supported as of 0.9.18;
return CAPABILITY_BW512;
} else {