Package net.i2p.router.transport
Class FIFOBandwidthLimiter
java.lang.Object
net.i2p.router.transport.FIFOBandwidthLimiter
Concurrent plan:
It's difficult to get rid of the locks on _pendingInboundRequests
since locked_satisyInboundAvailable() leaves Requests on the head
of the queue.
When we go to Java 6, we can convert from a locked ArrayList to
a LinkedBlockingDeque, where locked_sIA will poll() from the
head of the queue, and if the request is not fully satisfied,
offerFirst() (i.e. push) it back on the head.
Ditto outbound of course.
In the meantime, for Java 5, we have lockless 'shortcut'
methods for the common case where we are under the bandwidth limits.
And the volatile counters are now AtomicIntegers / AtomicLongs.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
A bandwidth request, either inbound or outbound. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Out bandwidth.int
int
The configured maximum, not the current rate.int
The configured maximum, not the current rate.int
int
The configured maximum, not the current rate.int
The configured maximum, not the current rate.float
float
float
float
(package private) StringBuilder
long
long
long
now()
(package private) final void
refillBandwidthQueues
(List<FIFOBandwidthLimiter.Request> buf, long bytesInbound, long bytesOutbound, long maxBurstIn, long maxBurstOut) More bytes are available - add them to the queue and satisfy any requests we canvoid
void
renderStatusHTML
(Writer out) Deprecated.not worth translatingrequestInbound
(int bytesIn, String purpose) Request some bytes.requestOutbound
(int bytesOut, int priority, String purpose) Request some bytes.boolean
sentParticipatingMessage
(int size, float factor) We intend to send traffic for a participating tunnel with the given size and adjustment factor.(package private) void
setInboundBurstBytes
(int bytes) (package private) void
setInboundBurstKBps
(int kbytesPerSecond) (package private) void
setInboundUnlimited
(boolean isUnlimited) Deprecated.unused for now, we are always limited(package private) void
setOutboundBurstBytes
(int bytes) (package private) void
setOutboundBurstKBps
(int kbytesPerSecond) (package private) void
setOutboundUnlimited
(boolean isUnlimited) Deprecated.unused for now, we are always limitedvoid
shutdown()
-
Constructor Details
-
FIFOBandwidthLimiter
-
-
Method Details
-
now
public long now() -
getTotalAllocatedInboundBytes
public long getTotalAllocatedInboundBytes() -
getTotalAllocatedOutboundBytes
public long getTotalAllocatedOutboundBytes() -
setInboundUnlimited
Deprecated.unused for now, we are always limited -
setOutboundUnlimited
Deprecated.unused for now, we are always limited -
getSendBps
public float getSendBps()- Returns:
- smoothed one second rate
-
getReceiveBps
public float getReceiveBps()- Returns:
- smoothed one second rate
-
getSendBps15s
public float getSendBps15s()- Returns:
- smoothed 15 second rate
-
getReceiveBps15s
public float getReceiveBps15s()- Returns:
- smoothed 15 second rate
-
getOutboundKBytesPerSecond
public int getOutboundKBytesPerSecond()The configured maximum, not the current rate. In binary K, i.e. rate / 1024. -
getInboundKBytesPerSecond
public int getInboundKBytesPerSecond()The configured maximum, not the current rate. In binary K, i.e. rate / 1024. -
getOutboundBurstKBytesPerSecond
public int getOutboundBurstKBytesPerSecond()The configured maximum, not the current rate. In binary K, i.e. rate / 1024. -
getInboundBurstKBytesPerSecond
public int getInboundBurstKBytesPerSecond()The configured maximum, not the current rate. In binary K, i.e. rate / 1024. -
reinitialize
public void reinitialize() -
shutdown
public void shutdown()- Since:
- 0.8.8
-
sentParticipatingMessage
public boolean sentParticipatingMessage(int size, float factor) We intend to send traffic for a participating tunnel with the given size and adjustment factor. Returns true if the message can be sent within the current share bandwidth limits, or false if it should be dropped.- Parameters:
size
- bytesfactor
- multiplier of size for the drop calculation, 1 for no adjustment- Returns:
- true for accepted, false for drop
- Since:
- 0.8.12
-
getCurrentParticipatingBandwidth
public int getCurrentParticipatingBandwidth()Out bandwidth. Actual bandwidth, not smoothed, not bucketed.- Returns:
- Bps in recent period (a few seconds)
- Since:
- 0.8.12
-
requestInbound
Request some bytes. Does not block. -
requestOutbound
Request some bytes. Does not block. -
setInboundBurstKBps
void setInboundBurstKBps(int kbytesPerSecond) -
setOutboundBurstKBps
void setOutboundBurstKBps(int kbytesPerSecond) -
getInboundBurstBytes
public int getInboundBurstBytes() -
getOutboundBurstBytes
public int getOutboundBurstBytes() -
setInboundBurstBytes
void setInboundBurstBytes(int bytes) -
setOutboundBurstBytes
void setOutboundBurstBytes(int bytes) -
getStatus
StringBuilder getStatus() -
refillBandwidthQueues
final void refillBandwidthQueues(List<FIFOBandwidthLimiter.Request> buf, long bytesInbound, long bytesOutbound, long maxBurstIn, long maxBurstOut) More bytes are available - add them to the queue and satisfy any requests we can- Parameters:
buf
- contains satisfied outbound requests, really just to avoid object thrash, not really usedmaxBurstIn
- allow up to this many bytes in from the burst section for this time period (may be negative)maxBurstOut
- allow up to this many bytes in from the burst section for this time period (may be negative)
-
renderStatusHTML
Deprecated.not worth translating- Throws:
IOException
-