HBASE-13819 Make RPC layer CellBlock buffer a DirectByteBuffer.
This commit is contained in:
parent
411683c22b
commit
5dba2c71f7
|
@ -67,16 +67,20 @@ public class BoundedByteBufferPool {
|
|||
|
||||
private ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
private boolean createDirectByteBuffer;
|
||||
|
||||
/**
|
||||
* @param maxByteBufferSizeToCache
|
||||
* @param initialByteBufferSize
|
||||
* @param maxToCache
|
||||
* @param createDirectByteBuffer whether the buffers created by this pool to be off heap
|
||||
*/
|
||||
public BoundedByteBufferPool(final int maxByteBufferSizeToCache, final int initialByteBufferSize,
|
||||
final int maxToCache) {
|
||||
final int maxToCache, final boolean createDirectByteBuffer) {
|
||||
this.maxByteBufferSizeToCache = maxByteBufferSizeToCache;
|
||||
this.runningAverage = initialByteBufferSize;
|
||||
this.buffers = new BoundedArrayQueue<ByteBuffer>(maxToCache);
|
||||
this.createDirectByteBuffer = createDirectByteBuffer;
|
||||
}
|
||||
|
||||
public ByteBuffer getBuffer() {
|
||||
|
@ -94,7 +98,8 @@ public class BoundedByteBufferPool {
|
|||
// Clear sets limit == capacity. Postion == 0.
|
||||
bb.clear();
|
||||
} else {
|
||||
bb = ByteBuffer.allocate(this.runningAverage);
|
||||
bb = this.createDirectByteBuffer ? ByteBuffer.allocateDirect(this.runningAverage)
|
||||
: ByteBuffer.allocate(this.runningAverage);
|
||||
this.allocations.incrementAndGet();
|
||||
}
|
||||
if (LOG.isTraceEnabled()) {
|
||||
|
|
|
@ -37,8 +37,8 @@ public class TestBoundedByteBufferPool {
|
|||
|
||||
@Before
|
||||
public void before() {
|
||||
this.reservoir =
|
||||
new BoundedByteBufferPool(maxByteBufferSizeToCache, initialByteBufferSize, maxToCache);
|
||||
this.reservoir = new BoundedByteBufferPool(maxByteBufferSizeToCache, initialByteBufferSize,
|
||||
maxToCache, false);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -1967,7 +1967,9 @@ public class RpcServer implements RpcServerInterface {
|
|||
// Make the max twice the number of handlers to be safe.
|
||||
conf.getInt("hbase.ipc.server.reservoir.initial.max",
|
||||
conf.getInt(HConstants.REGION_SERVER_HANDLER_COUNT,
|
||||
HConstants.DEFAULT_REGION_SERVER_HANDLER_COUNT) * 2));
|
||||
HConstants.DEFAULT_REGION_SERVER_HANDLER_COUNT) * 2),
|
||||
// By default make direct byte buffers from the buffer pool.
|
||||
conf.getBoolean("hbase.ipc.server.reservoir.direct.buffer", true));
|
||||
this.server = server;
|
||||
this.services = services;
|
||||
this.bindAddress = bindAddress;
|
||||
|
|
Loading…
Reference in New Issue