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

Skip to content
Snippets Groups Projects
Commit cd37c301 authored by jrandom's avatar jrandom Committed by zzz
Browse files

if (log.shouldLog())

yeah, aspect oriented programming sure would be nice.
parent f5fa2663
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,9 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter { ...@@ -62,7 +62,9 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter {
_context.jobQueue().addJob(new UpdateBWJob()); _context.jobQueue().addJob(new UpdateBWJob());
updateLimits(); updateLimits();
_log.info("Initializing the limiter with maximum inbound [" + MAX_IN_POOL + "] outbound [" + MAX_OUT_POOL + "]"); if (_log.shouldLog(Log.INFO))
_log.info("Initializing the limiter with maximum inbound [" + MAX_IN_POOL
+ "] outbound [" + MAX_OUT_POOL + "]");
} }
public long getTotalSendBytes() { return _totalSendBytes; } public long getTotalSendBytes() { return _totalSendBytes; }
...@@ -80,7 +82,9 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter { ...@@ -80,7 +82,9 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter {
// we don't have sufficient bytes. // we don't have sufficient bytes.
// the delay = (needed/numPerMinute) // the delay = (needed/numPerMinute)
long val = MINUTE*(numBytes-_availableReceive)/_maxReceiveBytesPerMinute; long val = MINUTE*(numBytes-_availableReceive)/_maxReceiveBytesPerMinute;
_log.debug("DelayInbound: " + val + " for " + numBytes + " (avail=" + _availableReceive + ", max=" + _maxReceiveBytesPerMinute + ")"); if (_log.shouldLog(Log.DEBUG))
_log.debug("DelayInbound: " + val + " for " + numBytes + " (avail="
+ _availableReceive + ", max=" + _maxReceiveBytesPerMinute + ")");
return val; return val;
} }
} }
...@@ -97,7 +101,9 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter { ...@@ -97,7 +101,9 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter {
// we don't have sufficient bytes. // we don't have sufficient bytes.
// the delay = (needed/numPerMinute) // the delay = (needed/numPerMinute)
long val = MINUTE*(numBytes-_availableSend)/_maxSendBytesPerMinute; long val = MINUTE*(numBytes-_availableSend)/_maxSendBytesPerMinute;
_log.debug("DelayOutbound: " + val + " for " + numBytes + " (avail=" + _availableSend + ", max=" + _maxSendBytesPerMinute + ")"); if (_log.shouldLog(Log.DEBUG))
_log.debug("DelayOutbound: " + val + " for " + numBytes + " (avail="
+ _availableSend + ", max=" + _maxSendBytesPerMinute + ")");
return val; return val;
} }
} }
...@@ -129,7 +135,8 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter { ...@@ -129,7 +135,8 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter {
long oldReceive = _maxReceiveBytesPerMinute; long oldReceive = _maxReceiveBytesPerMinute;
long oldSend = _maxSendBytesPerMinute; long oldSend = _maxSendBytesPerMinute;
_log.debug("Read limits ["+inBwStr+" in, " + outBwStr + " out] vs current [" + oldReceive + " in, " + oldSend + " out]"); if (_log.shouldLog(Log.DEBUG))
_log.debug("Read limits ["+inBwStr+" in, " + outBwStr + " out] vs current [" + oldReceive + " in, " + oldSend + " out]");
if ( (inBwStr != null) && (inBwStr.trim().length() > 0) ) { if ( (inBwStr != null) && (inBwStr.trim().length() > 0) ) {
try { try {
...@@ -179,16 +186,20 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter { ...@@ -179,16 +186,20 @@ public class TrivialBandwidthLimiter extends BandwidthLimiter {
_availableSend += numMinutes * _maxSendBytesPerMinute; _availableSend += numMinutes * _maxSendBytesPerMinute;
_lastResync = now; _lastResync = now;
_log.debug("Adding " + (numMinutes*_maxReceiveBytesPerMinute) + " bytes to availableReceive"); if (_log.shouldLog(Log.DEBUG)) {
_log.debug("Adding " + (numMinutes*_maxSendBytesPerMinute) + " bytes to availableSend"); _log.debug("Adding " + (numMinutes*_maxReceiveBytesPerMinute) + " bytes to availableReceive");
_log.debug("Adding " + (numMinutes*_maxSendBytesPerMinute) + " bytes to availableSend");
}
// if we're huge, trim // if we're huge, trim
if (_availableReceive > MAX_IN_POOL) { if (_availableReceive > MAX_IN_POOL) {
_log.debug("Trimming available receive to " + MAX_IN_POOL); if (_log.shouldLog(Log.DEBUG))
_log.debug("Trimming available receive to " + MAX_IN_POOL);
_availableReceive = MAX_IN_POOL; _availableReceive = MAX_IN_POOL;
} }
if (_availableSend > MAX_OUT_POOL) { if (_availableSend > MAX_OUT_POOL) {
_log.debug("Trimming available send to " + MAX_OUT_POOL); if (_log.shouldLog(Log.DEBUG))
_log.debug("Trimming available send to " + MAX_OUT_POOL);
_availableSend = MAX_OUT_POOL; _availableSend = MAX_OUT_POOL;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment