Package net.i2p.router.transport
Class FIFOBandwidthLimiter
java.lang.Object
net.i2p.router.transport.FIFOBandwidthLimiter
public class FIFOBandwidthLimiter extends Object
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
Nested Classes Modifier and Type Class Description static interfaceFIFOBandwidthLimiter.CompleteListenerstatic interfaceFIFOBandwidthLimiter.RequestA bandwidth request, either inbound or outbound. -
Constructor Summary
Constructors Constructor Description FIFOBandwidthLimiter(RouterContext context) -
Method Summary
Modifier and Type Method Description intgetCurrentParticipatingBandwidth()Out bandwidth.intgetInboundBurstBytes()intgetInboundBurstKBytesPerSecond()The configured maximum, not the current rate.intgetInboundKBytesPerSecond()The configured maximum, not the current rate.intgetOutboundBurstBytes()intgetOutboundBurstKBytesPerSecond()The configured maximum, not the current rate.intgetOutboundKBytesPerSecond()The configured maximum, not the current rate.floatgetReceiveBps()floatgetReceiveBps15s()floatgetSendBps()floatgetSendBps15s()(package private) StringBuildergetStatus()longgetTotalAllocatedInboundBytes()longgetTotalAllocatedOutboundBytes()longnow()(package private) voidrefillBandwidthQueues(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 canvoidreinitialize()voidrenderStatusHTML(Writer out)Deprecated.not worth translatingFIFOBandwidthLimiter.RequestrequestInbound(int bytesIn, String purpose)Request some bytes.FIFOBandwidthLimiter.RequestrequestOutbound(int bytesOut, int priority, String purpose)Request some bytes.booleansentParticipatingMessage(int size, float factor)We intend to send traffic for a participating tunnel with the given size and adjustment factor.(package private) voidsetInboundBurstBytes(int bytes)(package private) voidsetInboundBurstKBps(int kbytesPerSecond)(package private) voidsetInboundUnlimited(boolean isUnlimited)Deprecated.unused for now, we are always limited(package private) voidsetOutboundBurstBytes(int bytes)(package private) voidsetOutboundBurstKBps(int kbytesPerSecond)(package private) voidsetOutboundUnlimited(boolean isUnlimited)Deprecated.unused for now, we are always limitedvoidshutdown()
-
Constructor Details
-
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
-