|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.router.transport.FIFOBandwidthLimiter
public class 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 | |
---|---|
static interface |
FIFOBandwidthLimiter.CompleteListener
|
static interface |
FIFOBandwidthLimiter.Request
A bandwidth request, either inbound or outbound. |
Constructor Summary | |
---|---|
FIFOBandwidthLimiter(I2PAppContext context)
|
Method Summary | |
---|---|
int |
getCurrentParticipatingBandwidth()
Out bandwidth. |
int |
getInboundBurstBytes()
|
int |
getInboundBurstKBytesPerSecond()
The configured maximum, not the current rate |
int |
getInboundKBytesPerSecond()
The configured maximum, not the current rate |
int |
getOutboundBurstBytes()
|
int |
getOutboundBurstKBytesPerSecond()
The configured maximum, not the current rate |
int |
getOutboundKBytesPerSecond()
The configured maximum, not the current rate |
float |
getReceiveBps()
|
float |
getReceiveBps15s()
|
float |
getSendBps()
|
float |
getSendBps15s()
|
(package private) StringBuilder |
getStatus()
|
long |
getTotalAllocatedInboundBytes()
|
long |
getTotalAllocatedOutboundBytes()
|
long |
now()
|
(package private) 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 |
void |
reinitialize()
|
void |
renderStatusHTML(Writer out)
Deprecated. not worth translating |
FIFOBandwidthLimiter.Request |
requestInbound(int bytesIn,
String purpose)
Request some bytes. |
FIFOBandwidthLimiter.Request |
requestOutbound(int bytesOut,
int priority,
String purpose)
Request some bytes. |
void |
sentParticipatingMessage(int size)
We sent a message. |
(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 limited |
void |
shutdown()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FIFOBandwidthLimiter(I2PAppContext context)
Method Detail |
---|
public long now()
public long getTotalAllocatedInboundBytes()
public long getTotalAllocatedOutboundBytes()
void setInboundUnlimited(boolean isUnlimited)
void setOutboundUnlimited(boolean isUnlimited)
public float getSendBps()
public float getReceiveBps()
public float getSendBps15s()
public float getReceiveBps15s()
public int getOutboundKBytesPerSecond()
public int getInboundKBytesPerSecond()
public int getOutboundBurstKBytesPerSecond()
public int getInboundBurstKBytesPerSecond()
public void reinitialize()
public void shutdown()
public void sentParticipatingMessage(int size)
size
- bytespublic int getCurrentParticipatingBandwidth()
public FIFOBandwidthLimiter.Request requestInbound(int bytesIn, String purpose)
public FIFOBandwidthLimiter.Request requestOutbound(int bytesOut, int priority, String purpose)
void setInboundBurstKBps(int kbytesPerSecond)
void setOutboundBurstKBps(int kbytesPerSecond)
public int getInboundBurstBytes()
public int getOutboundBurstBytes()
void setInboundBurstBytes(int bytes)
void setOutboundBurstBytes(int bytes)
StringBuilder getStatus()
final void refillBandwidthQueues(List<FIFOBandwidthLimiter.Request> buf, long bytesInbound, long bytesOutbound, long maxBurstIn, long maxBurstOut)
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)public void renderStatusHTML(Writer out) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |