safer operation (for use in the sim where some things aren't always availble)
This commit is contained in:
@ -2,6 +2,7 @@ package net.i2p.router;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.i2np.TunnelCreateMessage;
|
||||
import net.i2p.stat.RateStat;
|
||||
import net.i2p.stat.Rate;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
@ -62,8 +63,11 @@ class RouterThrottleImpl implements RouterThrottle {
|
||||
}
|
||||
public boolean acceptTunnelRequest(TunnelCreateMessage msg) {
|
||||
long lag = _context.jobQueue().getMaxLag();
|
||||
Rate throttleRate = _context.statManager().getRate("router.throttleNetworkCause").getRate(10*60*1000);
|
||||
long throttleEvents = throttleRate.getCurrentEventCount() + throttleRate.getLastEventCount();
|
||||
RateStat rs = _context.statManager().getRate("router.throttleNetworkCause");
|
||||
Rate r = null;
|
||||
if (rs != null)
|
||||
r = rs.getRate(10*60*1000);
|
||||
long throttleEvents = (r != null ? r.getCurrentEventCount() + r.getLastEventCount() : 0);
|
||||
if (throttleEvents > THROTTLE_EVENT_LIMIT) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Refusing tunnel request with the job lag of " + lag
|
||||
@ -73,10 +77,20 @@ class RouterThrottleImpl implements RouterThrottle {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ok, we're not hosed, but can we handle the bandwidth requirements
|
||||
// of another tunnel?
|
||||
double msgsPerTunnel = _context.statManager().getRate("tunnel.participatingMessagesProcessed").getRate(10*60*1000).getAverageValue();
|
||||
double bytesPerMsg = _context.statManager().getRate("tunnel.relayMessageSize").getRate(10*60*1000).getAverageValue();
|
||||
rs = _context.statManager().getRate("tunnel.participatingMessagesProcessed");
|
||||
r = null;
|
||||
if (rs != null)
|
||||
r = rs.getRate(10*60*1000);
|
||||
double msgsPerTunnel = (r != null ? r.getAverageValue() : 0);
|
||||
r = null;
|
||||
rs = _context.statManager().getRate("tunnel.relayMessageSize");
|
||||
if (rs != null)
|
||||
r = rs.getRate(10*60*1000);
|
||||
double bytesPerMsg = (r != null ? r.getAverageValue() : 0);
|
||||
double bytesPerTunnel = msgsPerTunnel * bytesPerMsg;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user