Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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
`static interface` | `FIFOBandwidthLimiter.CompleteListener`
`static interface` | `FIFOBandwidthLimiter.Request` This is somewhat complicated by having both inbound and outbound in a single request.

Constructor Summary
`FIFOBandwidthLimiter(I2PAppContext context)`

Method Summary
`FIFOBandwidthLimiter.Request` | `createRequest()`
`int` | `getInboundBurstBytes()`
`int` | `getInboundBurstKBytesPerSecond()`
`int` | `getInboundKBytesPerSecond()`
`boolean` | `getInboundUnlimited()`
`int` | `getOutboundBurstBytes()`
`int` | `getOutboundBurstKBytesPerSecond()`
`int` | `getOutboundKBytesPerSecond()` These are the configured maximums, not the current rate
`boolean` | `getOutboundUnlimited()`
`float` | `getReceiveBps()`
`float` | `getReceiveBps15s()`
`float` | `getSendBps()`
`float` | `getSendBps15s()`
`(package private) StringBuilder` | `getStatus()`
`long` | `getTotalAllocatedInboundBytes()`
`long` | `getTotalAllocatedOutboundBytes()`
`long` | `getTotalWastedInboundBytes()`
`long` | `getTotalWastedOutboundBytes()`
`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` | `requestInbound(int bytesIn, String purpose, FIFOBandwidthLimiter.CompleteListener lsnr, Object attachment)`
`FIFOBandwidthLimiter.Request` | `requestOutbound(int bytesOut, String purpose)` Request some bytes.
`FIFOBandwidthLimiter.Request` | `requestOutbound(int bytesOut, String purpose, FIFOBandwidthLimiter.CompleteListener lsnr, Object attachment)`
`(package private) void` | `setInboundBurstBytes(int bytes)`
`(package private) void` | `setInboundBurstKBps(int kbytesPerSecond)`
`void` | `setInboundUnlimited(boolean isUnlimited)`
`(package private) void` | `setOutboundBurstBytes(int bytes)`
`(package private) void` | `setOutboundBurstKBps(int kbytesPerSecond)`
`void` | `setOutboundUnlimited(boolean isUnlimited)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FIFOBandwidthLimiter

    public FIFOBandwidthLimiter(I2PAppContext context)

Method Detail

### now

    public long now()

### getTotalAllocatedInboundBytes

    public long getTotalAllocatedInboundBytes()

### getTotalAllocatedOutboundBytes

    public long getTotalAllocatedOutboundBytes()

### getTotalWastedInboundBytes

    public long getTotalWastedInboundBytes()

### getTotalWastedOutboundBytes

    public long getTotalWastedOutboundBytes()

### getInboundUnlimited

    public boolean getInboundUnlimited()

### setInboundUnlimited

    public void setInboundUnlimited(boolean isUnlimited)

### getOutboundUnlimited

    public boolean getOutboundUnlimited()

### setOutboundUnlimited

    public void setOutboundUnlimited(boolean isUnlimited)

### getSendBps

    public float getSendBps()

### getReceiveBps

    public float getReceiveBps()

### getSendBps15s

    public float getSendBps15s()

### getReceiveBps15s

    public float getReceiveBps15s()

### getOutboundKBytesPerSecond

    public int getOutboundKBytesPerSecond()

  These are the configured maximums, not the current rate

### getInboundKBytesPerSecond

    public int getInboundKBytesPerSecond()

### getOutboundBurstKBytesPerSecond

    public int getOutboundBurstKBytesPerSecond()

### getInboundBurstKBytesPerSecond

    public int getInboundBurstKBytesPerSecond()

### reinitialize

    public void reinitialize()

### createRequest

    public FIFOBandwidthLimiter.Request createRequest()

### requestInbound

    public FIFOBandwidthLimiter.Request requestInbound(int bytesIn,
                                                       String purpose)

  Request some bytes. Does not block.

### requestInbound

    public FIFOBandwidthLimiter.Request requestInbound(int bytesIn,
                                                       String purpose,
                                                       FIFOBandwidthLimiter.CompleteListener lsnr,
                                                       Object attachment)

### requestOutbound

    public FIFOBandwidthLimiter.Request requestOutbound(int bytesOut,
                                                        String purpose)

  Request some bytes. Does not block.

### requestOutbound

    public FIFOBandwidthLimiter.Request requestOutbound(int bytesOut,
                                                        String purpose,
                                                        FIFOBandwidthLimiter.CompleteListener lsnr,
                                                        Object attachment)

### 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:
    `maxBurstIn` - 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

    public void renderStatusHTML(Writer out)
                          throws IOException

  Deprecated. not worth translating

  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD