diff --git a/router/java/src/net/i2p/router/LoadTestManager.java b/router/java/src/net/i2p/router/LoadTestManager.java index 55adb61382bdba62ad7aea82f3720fc7a566b00a..d3e5c46f5791a0e9361a7349aad89da0e0e4d265 100644 --- a/router/java/src/net/i2p/router/LoadTestManager.java +++ b/router/java/src/net/i2p/router/LoadTestManager.java @@ -117,12 +117,7 @@ public class LoadTestManager { private int getConcurrency() { if (!isEnabled(_context)) return 0; - int rv = CONCURRENT_PEERS; - try { - rv = Integer.parseInt(_context.getProperty("router.loadTestConcurrency", CONCURRENT_PEERS+"")); - } catch (NumberFormatException nfe) { - rv = CONCURRENT_PEERS; - } + int rv = _context.getProperty("router.loadTestConcurrency", CONCURRENT_PEERS); if (rv < 0) rv = 0; if (rv > 50) @@ -131,15 +126,7 @@ public class LoadTestManager { } private int getPeerMessages() { - String msgsPerPeer = _context.getProperty("router.loadTestMessagesPerPeer"); - int rv = CONCURRENT_MESSAGES; - if (msgsPerPeer != null) { - try { - rv = Integer.parseInt(msgsPerPeer); - } catch (NumberFormatException nfe) { - rv = CONCURRENT_MESSAGES; - } - } + int rv = _context.getProperty("router.loadTestMessagesPerPeer", CONCURRENT_MESSAGES); if (rv < 1) rv = 1; if (rv > 50) diff --git a/router/java/src/net/i2p/router/RouterThrottleImpl.java b/router/java/src/net/i2p/router/RouterThrottleImpl.java index 2c3f2114e58836880aff3f843c9c35162ea6875b..fc38b16958aaba4ae35e04c3bbb55175b18ac0db 100644 --- a/router/java/src/net/i2p/router/RouterThrottleImpl.java +++ b/router/java/src/net/i2p/router/RouterThrottleImpl.java @@ -190,14 +190,7 @@ class RouterThrottleImpl implements RouterThrottle { } } - int max = DEFAULT_MAX_TUNNELS; - String maxTunnels = _context.getProperty(PROP_MAX_TUNNELS); - if (maxTunnels != null) { - try { - max = Integer.parseInt(maxTunnels); - } catch (NumberFormatException nfe) { - } - } + int max = _context.getProperty(PROP_MAX_TUNNELS, DEFAULT_MAX_TUNNELS); if (numTunnels >= max) { if (_log.shouldLog(Log.WARN)) _log.warn("Refusing tunnel request since we are already participating in " @@ -387,11 +380,7 @@ class RouterThrottleImpl implements RouterThrottle { /** dont ever probabalistically throttle tunnels if we have less than this many */ private int getMinThrottleTunnels() { - try { - return Integer.parseInt(_context.getProperty("router.minThrottleTunnels", "1000")); - } catch (NumberFormatException nfe) { - return 1000; - } + return _context.getProperty("router.minThrottleTunnels", 1000); } private double getTunnelGrowthFactor() { diff --git a/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java b/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java index e759441d943ce96f45f80f58e86028cf6e4dcf93..b090d6cc781bf21bd3637f2b809754d0aa3f6ced 100644 --- a/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java +++ b/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java @@ -1101,22 +1101,7 @@ public class ProfileOrganizer { * @return minimum number of peers to be placed in the 'fast' group */ protected int getMinimumFastPeers() { - String val = _context.getProperty(PROP_MINIMUM_FAST_PEERS, ""+DEFAULT_MINIMUM_FAST_PEERS); - if (val != null) { - try { - int rv = Integer.parseInt(val); - if (_log.shouldLog(Log.DEBUG)) - _log.debug("router context said " + PROP_MINIMUM_FAST_PEERS + '=' + val); - return rv; - } catch (NumberFormatException nfe) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Minimum fast peers improperly set in the router environment [" + val + "]", nfe); - } - } - - if (_log.shouldLog(Log.DEBUG)) - _log.debug("no config for " + PROP_MINIMUM_FAST_PEERS + ", using " + DEFAULT_MINIMUM_FAST_PEERS); - return DEFAULT_MINIMUM_FAST_PEERS; + return _context.getProperty(PROP_MINIMUM_FAST_PEERS, DEFAULT_MINIMUM_FAST_PEERS); } @@ -1130,22 +1115,7 @@ public class ProfileOrganizer { * @return minimum number of peers to be placed in the 'fast' group */ protected int getMinimumHighCapacityPeers() { - String val = _context.getProperty(PROP_MINIMUM_HIGH_CAPACITY_PEERS, ""+DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS); - if (val != null) { - try { - int rv = Integer.parseInt(val); - if (_log.shouldLog(Log.DEBUG)) - _log.debug("router context said " + PROP_MINIMUM_HIGH_CAPACITY_PEERS + '=' + val); - return rv; - } catch (NumberFormatException nfe) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Minimum high capacity peers improperly set in the router environment [" + val + "]", nfe); - } - } - - if (_log.shouldLog(Log.DEBUG)) - _log.debug("no config for " + PROP_MINIMUM_HIGH_CAPACITY_PEERS + ", using " + DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS); - return DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS; + return _context.getProperty(PROP_MINIMUM_HIGH_CAPACITY_PEERS, DEFAULT_MINIMUM_HIGH_CAPACITY_PEERS); } private final static DecimalFormat _fmt = new DecimalFormat("###,##0.00", new DecimalFormatSymbols(Locale.UK)); diff --git a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java index 0210f8da5266113cae7a0bbb483fb37069d7b2ac..d4bdfea85f31835b90abbc934b697284d483b9cc 100644 --- a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java +++ b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java @@ -154,55 +154,30 @@ public class FIFOBandwidthRefiller implements Runnable { } private void updateInboundRate() { - String inBwStr = _context.getProperty(PROP_INBOUND_BANDWIDTH); - if ( (inBwStr != null) && - (inBwStr.trim().length() > 0) && - (!(inBwStr.equals(String.valueOf(_inboundKBytesPerSecond)))) ) { + int in = _context.getProperty(PROP_INBOUND_BANDWIDTH, DEFAULT_INBOUND_BANDWIDTH); + if (in != _inboundKBytesPerSecond) { // bandwidth was specified *and* changed - try { - int in = Integer.parseInt(inBwStr); if ( (in <= 0) || (in > MIN_INBOUND_BANDWIDTH) ) _inboundKBytesPerSecond = in; else _inboundKBytesPerSecond = MIN_INBOUND_BANDWIDTH; if (_log.shouldLog(Log.DEBUG)) _log.debug("Updating inbound rate to " + _inboundKBytesPerSecond); - } catch (NumberFormatException nfe) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Invalid inbound bandwidth limit [" + inBwStr - + "], keeping as " + _inboundKBytesPerSecond); - } - } else { - if ( (inBwStr == null) && (_log.shouldLog(Log.DEBUG)) ) - _log.debug("Inbound bandwidth limits not specified in the config via " + PROP_INBOUND_BANDWIDTH); } if (_inboundKBytesPerSecond <= 0) _inboundKBytesPerSecond = DEFAULT_INBOUND_BANDWIDTH; } private void updateOutboundRate() { - String outBwStr = _context.getProperty(PROP_OUTBOUND_BANDWIDTH); - - if ( (outBwStr != null) && - (outBwStr.trim().length() > 0) && - (!(outBwStr.equals(String.valueOf(_outboundKBytesPerSecond)))) ) { + int out = _context.getProperty(PROP_OUTBOUND_BANDWIDTH, DEFAULT_OUTBOUND_BANDWIDTH); + if (out != _outboundKBytesPerSecond) { // bandwidth was specified *and* changed - try { - int out = Integer.parseInt(outBwStr); if ( (out <= 0) || (out >= MIN_OUTBOUND_BANDWIDTH) ) _outboundKBytesPerSecond = out; else _outboundKBytesPerSecond = MIN_OUTBOUND_BANDWIDTH; if (_log.shouldLog(Log.DEBUG)) _log.debug("Updating outbound rate to " + _outboundKBytesPerSecond); - } catch (NumberFormatException nfe) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Invalid outbound bandwidth limit [" + outBwStr - + "], keeping as " + _outboundKBytesPerSecond); - } - } else { - if ( (outBwStr == null) && (_log.shouldLog(Log.DEBUG)) ) - _log.debug("Outbound bandwidth limits not specified in the config via " + PROP_OUTBOUND_BANDWIDTH); } if (_outboundKBytesPerSecond <= 0) @@ -210,27 +185,15 @@ public class FIFOBandwidthRefiller implements Runnable { } private void updateInboundBurstRate() { - String inBwStr = _context.getProperty(PROP_INBOUND_BURST_BANDWIDTH); - if ( (inBwStr != null) && - (inBwStr.trim().length() > 0) && - (!(inBwStr.equals(String.valueOf(_inboundBurstKBytesPerSecond)))) ) { + int in = _context.getProperty(PROP_INBOUND_BURST_BANDWIDTH, DEFAULT_INBOUND_BURST_BANDWIDTH); + if (in != _inboundBurstKBytesPerSecond) { // bandwidth was specified *and* changed - try { - int in = Integer.parseInt(inBwStr); if ( (in <= 0) || (in >= _inboundKBytesPerSecond) ) _inboundBurstKBytesPerSecond = in; else _inboundBurstKBytesPerSecond = _inboundKBytesPerSecond; if (_log.shouldLog(Log.DEBUG)) _log.debug("Updating inbound burst rate to " + _inboundBurstKBytesPerSecond); - } catch (NumberFormatException nfe) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Invalid inbound bandwidth burst limit [" + inBwStr - + "], keeping as " + _inboundBurstKBytesPerSecond); - } - } else { - if ( (inBwStr == null) && (_log.shouldLog(Log.DEBUG)) ) - _log.debug("Inbound bandwidth burst limits not specified in the config via " + PROP_INBOUND_BURST_BANDWIDTH); } if (_inboundBurstKBytesPerSecond <= 0) @@ -239,28 +202,15 @@ public class FIFOBandwidthRefiller implements Runnable { } private void updateOutboundBurstRate() { - String outBwStr = _context.getProperty(PROP_OUTBOUND_BURST_BANDWIDTH); - - if ( (outBwStr != null) && - (outBwStr.trim().length() > 0) && - (!(outBwStr.equals(String.valueOf(_outboundBurstKBytesPerSecond)))) ) { + int out = _context.getProperty(PROP_OUTBOUND_BURST_BANDWIDTH, DEFAULT_OUTBOUND_BURST_BANDWIDTH); + if (out != _outboundBurstKBytesPerSecond) { // bandwidth was specified *and* changed - try { - int out = Integer.parseInt(outBwStr); if ( (out <= 0) || (out >= _outboundKBytesPerSecond) ) _outboundBurstKBytesPerSecond = out; else _outboundBurstKBytesPerSecond = _outboundKBytesPerSecond; if (_log.shouldLog(Log.DEBUG)) _log.debug("Updating outbound burst rate to " + _outboundBurstKBytesPerSecond); - } catch (NumberFormatException nfe) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Invalid outbound bandwidth burst limit [" + outBwStr - + "], keeping as " + _outboundBurstKBytesPerSecond); - } - } else { - if ( (outBwStr == null) && (_log.shouldLog(Log.DEBUG)) ) - _log.debug("Outbound bandwidth burst limits not specified in the config via " + PROP_OUTBOUND_BURST_BANDWIDTH); } if (_outboundBurstKBytesPerSecond <= 0) @@ -269,13 +219,10 @@ public class FIFOBandwidthRefiller implements Runnable { } private void updateInboundPeak() { - String inBwStr = _context.getProperty(PROP_INBOUND_BANDWIDTH_PEAK); - if ( (inBwStr != null) && - (inBwStr.trim().length() > 0) && - (!(inBwStr.equals(String.valueOf(_limiter.getInboundBurstBytes())))) ) { + int in = _context.getProperty(PROP_INBOUND_BANDWIDTH_PEAK, + DEFAULT_BURST_SECONDS * _inboundBurstKBytesPerSecond); + if (in != _limiter.getInboundBurstBytes()) { // peak bw was specified *and* changed - try { - int in = Integer.parseInt(inBwStr); if (in >= MIN_INBOUND_BANDWIDTH_PEAK) { if (in < _inboundBurstKBytesPerSecond) _limiter.setInboundBurstBytes(_inboundBurstKBytesPerSecond * 1024); @@ -287,27 +234,13 @@ public class FIFOBandwidthRefiller implements Runnable { else _limiter.setInboundBurstBytes(MIN_INBOUND_BANDWIDTH_PEAK * 1024); } - } catch (NumberFormatException nfe) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Invalid inbound bandwidth burst limit [" + inBwStr - + "]"); - _limiter.setInboundBurstBytes(DEFAULT_BURST_SECONDS * _inboundBurstKBytesPerSecond * 1024); - } - } else { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Inbound bandwidth burst limits not specified in the config via " - + PROP_INBOUND_BANDWIDTH_PEAK); - _limiter.setInboundBurstBytes(DEFAULT_BURST_SECONDS * _inboundBurstKBytesPerSecond * 1024); } } private void updateOutboundPeak() { - String inBwStr = _context.getProperty(PROP_OUTBOUND_BANDWIDTH_PEAK); - if ( (inBwStr != null) && - (inBwStr.trim().length() > 0) && - (!(inBwStr.equals(String.valueOf(_limiter.getOutboundBurstBytes())))) ) { + int in = _context.getProperty(PROP_OUTBOUND_BANDWIDTH_PEAK, + DEFAULT_BURST_SECONDS * _outboundBurstKBytesPerSecond); + if (in != _limiter.getOutboundBurstBytes()) { // peak bw was specified *and* changed - try { - int in = Integer.parseInt(inBwStr); if (in >= MIN_OUTBOUND_BANDWIDTH_PEAK) { if (in < _outboundBurstKBytesPerSecond) _limiter.setOutboundBurstBytes(_outboundBurstKBytesPerSecond * 1024); @@ -319,17 +252,6 @@ public class FIFOBandwidthRefiller implements Runnable { else _limiter.setOutboundBurstBytes(MIN_OUTBOUND_BANDWIDTH_PEAK * 1024); } - } catch (NumberFormatException nfe) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Invalid outbound bandwidth burst limit [" + inBwStr - + "]"); - _limiter.setOutboundBurstBytes(DEFAULT_BURST_SECONDS * _outboundBurstKBytesPerSecond * 1024); - } - } else { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Outbound bandwidth burst limits not specified in the config via " - + PROP_OUTBOUND_BANDWIDTH_PEAK); - _limiter.setOutboundBurstBytes(DEFAULT_BURST_SECONDS * _outboundBurstKBytesPerSecond * 1024); } } diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java b/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java index e1f040b8b34da1fa22efc83ebcd4bd86adf5441a..390fe888dcc2ca829b974db6543edb9d1db55bdc 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java @@ -39,10 +39,10 @@ class BuildExecutor implements Runnable { _context.statManager().createRateStat("tunnel.concurrentBuildsLagged", "How many builds are going at once when we reject further builds, due to job lag (period is lag)", "Tunnels", new long[] { 60*1000, 5*60*1000, 60*60*1000 }); _context.statManager().createRateStat("tunnel.buildExploratoryExpire", "How often an exploratory tunnel times out during creation", "Tunnels", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("tunnel.buildClientExpire", "How often a client tunnel times out during creation", "Tunnels", new long[] { 60*1000, 10*60*1000 }); - _context.statManager().createRateStat("tunnel.buildExploratorySuccess", "How often an exploratory tunnel is fully built", "Tunnels", new long[] { 60*1000, 10*60*1000 }); - _context.statManager().createRateStat("tunnel.buildClientSuccess", "How often a client tunnel is fully built", "Tunnels", new long[] { 60*1000, 10*60*1000 }); - _context.statManager().createRateStat("tunnel.buildExploratoryReject", "How often an exploratory tunnel is rejected", "Tunnels", new long[] { 60*1000, 10*60*1000 }); - _context.statManager().createRateStat("tunnel.buildClientReject", "How often a client tunnel is rejected", "Tunnels", new long[] { 60*1000, 10*60*1000 }); + _context.statManager().createRateStat("tunnel.buildExploratorySuccess", "Response time for success", "Tunnels", new long[] { 60*1000, 10*60*1000 }); + _context.statManager().createRateStat("tunnel.buildClientSuccess", "Response time for success", "Tunnels", new long[] { 60*1000, 10*60*1000 }); + _context.statManager().createRateStat("tunnel.buildExploratoryReject", "Response time for rejection", "Tunnels", new long[] { 60*1000, 10*60*1000 }); + _context.statManager().createRateStat("tunnel.buildClientReject", "Response time for rejection", "Tunnels", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("tunnel.buildRequestTime", "How long it takes to build a tunnel request", "Tunnels", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("tunnel.buildRequestZeroHopTime", "How long it takes to build a zero hop tunnel", "Tunnels", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("tunnel.pendingRemaining", "How many inbound requests are pending after a pass (period is how long the pass takes)?", "Tunnels", new long[] { 60*1000, 10*60*1000 }); @@ -71,10 +71,7 @@ class BuildExecutor implements Runnable { int allowed = maxKBps / 6; // Max. 1 concurrent build per 6 KB/s outbound if (allowed < 2) allowed = 2; // Never choke below 2 builds (but congestion may) if (allowed > 10) allowed = 10; // Never go beyond 10, that is uncharted territory (old limit was 5) - - String prop = _context.getProperty("router.tunnelConcurrentBuilds"); - if (prop != null) - try { allowed = Integer.valueOf(prop).intValue(); } catch (NumberFormatException nfe) {} + allowed = _context.getProperty("router.tunnelConcurrentBuilds", allowed); List expired = null; int concurrent = 0;