@InterfaceAudience.Private public class BoundedByteBufferPool extends Object
The intended use case is a reservoir of bytebuffers that an RPC can reuse; buffers tend to achieve a particular 'run' size over time give or take a few extremes. Set TRACE level on this class for a couple of seconds to get reporting on how it is running when deployed.
This class is thread safe.
Modifier and Type | Field and Description |
---|---|
private AtomicLong |
allocations |
(package private) Queue<ByteBuffer> |
buffers |
private ReentrantLock |
lock |
private static org.apache.commons.logging.Log |
LOG |
private int |
maxByteBufferSizeToCache |
(package private) int |
runningAverage |
private int |
totalReservoirCapacity |
Constructor and Description |
---|
BoundedByteBufferPool(int maxByteBufferSizeToCache,
int initialByteBufferSize,
int maxToCache) |
private static final org.apache.commons.logging.Log LOG
final Queue<ByteBuffer> buffers
private final int maxByteBufferSizeToCache
volatile int runningAverage
private volatile int totalReservoirCapacity
private AtomicLong allocations
private ReentrantLock lock
public BoundedByteBufferPool(int maxByteBufferSizeToCache, int initialByteBufferSize, int maxToCache)
maxByteBufferSizeToCache
- initialByteBufferSize
- maxToCache
- public ByteBuffer getBuffer()
public void putBuffer(ByteBuffer bb)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.