From 6019cf81481cad89962d1aa83f4c1e612b6522ad Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Mon, 9 Nov 2009 17:15:19 +0000 Subject: [PATCH] * Console: - Tag tunnel status --- apps/routerconsole/java/bmsg.sh | 6 ++- apps/routerconsole/java/bundle-messages.sh | 6 ++- .../i2p/router/web/SummaryBarRenderer.java | 2 +- apps/routerconsole/java/strings/Strings.java | 5 ++ installer/resources/countries.txt | 2 +- .../net/i2p/router/RouterThrottleImpl.java | 48 ++++++++++++------- .../i2p/router/tunnel/pool/BuildHandler.java | 22 ++++++--- 7 files changed, 65 insertions(+), 26 deletions(-) diff --git a/apps/routerconsole/java/bmsg.sh b/apps/routerconsole/java/bmsg.sh index 989bc1a30b..c63835709b 100644 --- a/apps/routerconsole/java/bmsg.sh +++ b/apps/routerconsole/java/bmsg.sh @@ -32,7 +32,11 @@ then sed 's/..,\(..*\)/_("\1");/' $CFILE >> $JFILE fi -JPATHS="src ../jsp/WEB-INF strings $JFILE" +# list specific files in router/ here, so we don't scan the whole tree +ROUTERFILES="\ + ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \ + ../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java" +JPATHS="src ../jsp/WEB-INF strings $JFILE $ROUTERFILES" for i in ../locale/messages_*.po do # get language diff --git a/apps/routerconsole/java/bundle-messages.sh b/apps/routerconsole/java/bundle-messages.sh index cb08afe2de..fd2a58713b 100755 --- a/apps/routerconsole/java/bundle-messages.sh +++ b/apps/routerconsole/java/bundle-messages.sh @@ -21,7 +21,11 @@ then sed 's/..,\(..*\)/_("\1");/' $CFILE >> $JFILE fi -JPATHS="src ../jsp/WEB-INF strings $JFILE" +# list specific files in router/ here, so we don't scan the whole tree +ROUTERFILES="\ + ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \ + ../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java" +JPATHS="src ../jsp/WEB-INF strings $JFILE $ROUTERFILES" for i in ../locale/messages_*.po do # get language diff --git a/apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java index 72856fedcd..bbffa6c9d0 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java @@ -401,7 +401,7 @@ public class SummaryBarRenderer { .append("</td></tr>\n" + "</table><hr><h4>") - .append(_helper.getTunnelStatus()) + .append(_(_helper.getTunnelStatus())) .append("</h4><hr>\n") .append(_helper.getDestinations()); diff --git a/apps/routerconsole/java/strings/Strings.java b/apps/routerconsole/java/strings/Strings.java index c9a94d6d2b..ce0b00649a 100644 --- a/apps/routerconsole/java/strings/Strings.java +++ b/apps/routerconsole/java/strings/Strings.java @@ -33,8 +33,13 @@ class Dummy { _("shared clients"); _("IRC proxy"); _("eepsite"); + // older names for pre-0.7.4 installs + _("eepProxy"); + _("ircProxy"); // hardcoded in i2psnark _("I2PSnark"); + // hardcoded in iMule? + _("iMule"); // standard themes for ConfigUIHelper _("classic"); diff --git a/installer/resources/countries.txt b/installer/resources/countries.txt index c2d0e841c4..5e1c0dcf46 100644 --- a/installer/resources/countries.txt +++ b/installer/resources/countries.txt @@ -116,7 +116,7 @@ KR,Republic of Korea KW,Kuwait KY,Cayman Islands KZ,Kazakhstan -LA,Lao People'S Democratic Republic +LA,Lao People's Democratic Republic LB,Lebanon LC,Saint Lucia LI,Liechtenstein diff --git a/router/java/src/net/i2p/router/RouterThrottleImpl.java b/router/java/src/net/i2p/router/RouterThrottleImpl.java index 00adcda785..750acb0730 100644 --- a/router/java/src/net/i2p/router/RouterThrottleImpl.java +++ b/router/java/src/net/i2p/router/RouterThrottleImpl.java @@ -88,7 +88,7 @@ class RouterThrottleImpl implements RouterThrottle { if (_context.getProperty(Router.PROP_SHUTDOWN_IN_PROGRESS) != null) { if (_log.shouldLog(Log.WARN)) _log.warn("Refusing tunnel request since we are shutting down ASAP"); - setTunnelStatus("Rejecting tunnels: Shutting down"); + setTunnelStatus(_x("Rejecting tunnels: Shutting down")); // Don't use CRIT because this tells everybody we are shutting down return TunnelHistory.TUNNEL_REJECT_BANDWIDTH; } @@ -137,7 +137,7 @@ class RouterThrottleImpl implements RouterThrottle { _log.warn("Refusing tunnel request due to sendProcessingTime of " + avgSendProcessingTime + " ms over the last two minutes, which is too much."); } - setTunnelStatus("Rejecting tunnels: High message delay"); + setTunnelStatus(_x("Rejecting tunnels: High message delay")); return TunnelHistory.TUNNEL_REJECT_BANDWIDTH; } } @@ -171,7 +171,9 @@ class RouterThrottleImpl implements RouterThrottle { _log.warn("Probabalistically refusing tunnel request (avg=" + avg + " current=" + numTunnels + ")"); _context.statManager().addRateData("router.throttleTunnelProbTooFast", (long)(numTunnels-avg), 0); - setTunnelStatus("Rejecting " + (100 - (int) probAccept*100) + "% of tunnels: High number of requests"); + // hard to do {0} from here + //setTunnelStatus("Rejecting " + (100 - (int) probAccept*100) + "% of tunnels: High number of requests"); + setTunnelStatus(_x("Rejecting most tunnels: High number of requests")); return TunnelHistory.TUNNEL_REJECT_PROBABALISTIC_REJECT; } } else { @@ -205,13 +207,13 @@ class RouterThrottleImpl implements RouterThrottle { if (_log.shouldLog(Log.INFO)) _log.info("Probabalistically accept tunnel request (p=" + probAccept + " v=" + v + " test time avg 1m=" + avg1m + " 10m=" + avg10m + ")"); - } else if (false) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Probabalistically refusing tunnel request (test time avg 1m=" + avg1m - + " 10m=" + avg10m + ")"); - _context.statManager().addRateData("router.throttleTunnelProbTestSlow", (long)(avg1m-avg10m), 0); - setTunnelStatus("Rejecting " + ((int) probAccept*100) + "% of tunnels: High test time"); - return TunnelHistory.TUNNEL_REJECT_PROBABALISTIC_REJECT; + //} else if (false) { + // if (_log.shouldLog(Log.WARN)) + // _log.warn("Probabalistically refusing tunnel request (test time avg 1m=" + avg1m + // + " 10m=" + avg10m + ")"); + // _context.statManager().addRateData("router.throttleTunnelProbTestSlow", (long)(avg1m-avg10m), 0); + // setTunnelStatus("Rejecting " + ((int) probAccept*100) + "% of tunnels: High test time"); + // return TunnelHistory.TUNNEL_REJECT_PROBABALISTIC_REJECT; } } else { // not yet... @@ -227,7 +229,7 @@ class RouterThrottleImpl implements RouterThrottle { _log.warn("Refusing tunnel request since we are already participating in " + numTunnels + " (our max is " + max + ")"); _context.statManager().addRateData("router.throttleTunnelMaxExceeded", numTunnels, 0); - setTunnelStatus("Rejecting tunnels: Limit reached"); + setTunnelStatus(_x("Rejecting tunnels: Limit reached")); return TunnelHistory.TUNNEL_REJECT_BANDWIDTH; } @@ -295,7 +297,7 @@ class RouterThrottleImpl implements RouterThrottle { private static final int DEFAULT_MESSAGES_PER_TUNNEL_ESTIMATE = 40; // .067KBps /** also limited to 90% - see below */ private static final int MIN_AVAILABLE_BPS = 4*1024; // always leave at least 4KBps free when allowing - private static final String LIMIT_STR = "Rejecting tunnels: Bandwidth limit"; + private static final String LIMIT_STR = _x("Rejecting tunnels: Bandwidth limit"); /** * with bytesAllocated already accounted for across the numTunnels existing @@ -363,11 +365,15 @@ class RouterThrottleImpl implements RouterThrottle { if (probReject >= 0.9) setTunnelStatus(LIMIT_STR); else if (probReject >= 0.5) - setTunnelStatus("Rejecting " + ((int)(100.0*probReject)) + "% of tunnels: Bandwidth limit"); + // hard to do {0} from here + //setTunnelStatus("Rejecting " + ((int)(100.0*probReject)) + "% of tunnels: Bandwidth limit"); + setTunnelStatus(_x("Rejecting most tunnels: Bandwidth limit")); else if(probReject >= 0.1) - setTunnelStatus("Accepting " + (100-(int)(100.0*probReject)) + "% of tunnels"); + // hard to do {0} from here + //setTunnelStatus("Accepting " + (100-(int)(100.0*probReject)) + "% of tunnels"); + setTunnelStatus(_x("Accepting most tunnels")); else - setTunnelStatus("Accepting tunnels"); + setTunnelStatus(_x("Accepting tunnels")); return !reject; @@ -477,7 +483,7 @@ class RouterThrottleImpl implements RouterThrottle { // if (_context.router().getRouterInfo().getBandwidthTier().equals("K")) // setTunnelStatus("Not expecting tunnel requests: Advertised bandwidth too low"); // else - setTunnelStatus("Rejecting tunnels"); + setTunnelStatus(_x("Rejecting tunnels")); } public void setTunnelStatus(String msg) { @@ -485,4 +491,14 @@ class RouterThrottleImpl implements RouterThrottle { } protected RouterContext getContext() { return _context; } + + /** + * Mark a string for extraction by xgettext and translation. + * Use this only in static initializers. + * It does not translate! + * @return s + */ + private static final String _x(String s) { + return s; + } } diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java index debe7cff26..465f21e33b 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java @@ -125,7 +125,7 @@ class BuildHandler { } while (_inboundBuildMessages.size() > 0); if (dropExpired > 0) - _context.throttle().setTunnelStatus("Dropping tunnel requests: Too slow"); + _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: Too slow")); // now pull off the oldest requests first (we're doing a tail-drop // when adding) @@ -337,7 +337,7 @@ class BuildHandler { if (timeSinceReceived > (BuildRequestor.REQUEST_TIMEOUT*3)) { // don't even bother, since we are so overloaded locally - _context.throttle().setTunnelStatus("Dropping tunnel requests: Overloaded"); + _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: Overloaded")); if (_log.shouldLog(Log.WARN)) _log.warn("Not even trying to handle/decrypt the request " + state.msg.getUniqueId() + ", since we received it a long time ago: " + timeSinceReceived); @@ -496,7 +496,7 @@ class BuildHandler { pDrop = (float)Math.pow(pDrop, 16); if (_context.random().nextFloat() < pDrop) { // || (proactiveDrops > MAX_PROACTIVE_DROPS) ) ) { _context.statManager().addRateData("tunnel.rejectOverloaded", recvDelay, proactiveDrops); - _context.throttle().setTunnelStatus("Rejecting tunnels: Request overload"); + _context.throttle().setTunnelStatus(_x("Rejecting tunnels: Request overload")); if (true || (proactiveDrops < MAX_PROACTIVE_DROPS*2)) response = TunnelHistory.TUNNEL_REJECT_TRANSIENT_OVERLOAD; else @@ -521,7 +521,7 @@ class BuildHandler { (ri == null || ri.getBandwidthTier().charAt(0) != 'O') && ((isInGW && ! _context.commSystem().haveInboundCapacity(87)) || (isOutEnd && ! _context.commSystem().haveOutboundCapacity(87)))) { - _context.throttle().setTunnelStatus("Rejecting tunnels: Connection limit"); + _context.throttle().setTunnelStatus(_x("Rejecting tunnels: Connection limit")); response = TunnelHistory.TUNNEL_REJECT_BANDWIDTH; } @@ -722,7 +722,7 @@ class BuildHandler { } } if (dropped > 0) { - _context.throttle().setTunnelStatus("Dropping tunnel requests: High load"); + _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: High load")); // if the queue is backlogged, stop adding new messages _context.statManager().addRateData("tunnel.dropLoadBacklog", _inboundBuildMessages.size(), _inboundBuildMessages.size()); } else { @@ -731,7 +731,7 @@ class BuildHandler { pDrop = (float)Math.pow(pDrop, 16); // steeeep float f = _context.random().nextFloat(); if ( (pDrop > f) && (allowProactiveDrop()) ) { - _context.throttle().setTunnelStatus("Dropping tunnel requests: Queue time"); + _context.throttle().setTunnelStatus(_x("Dropping tunnel requests: Queue time")); _context.statManager().addRateData("tunnel.dropLoadProactive", queueTime, _inboundBuildMessages.size()); } else { _inboundBuildMessages.add(new BuildMessageState(receivedMessage, from, fromHash)); @@ -860,4 +860,14 @@ class BuildHandler { //_log.error("Cant contact next hop for " + _cfg); } } + + /** + * Mark a string for extraction by xgettext and translation. + * Use this only in static initializers. + * It does not translate! + * @return s + */ + private static final String _x(String s) { + return s; + } } -- GitLab