conf.getInt(HConstants.REGION_SERVER_HANDLER_COUNT, HConstants.DEFAULT_REGION_SERVER_HANDLER_COUNT) * bufsForTwoMB * 2); this.reservoir = new ByteBufferPool(poolBufSize, maxPoolSize); this.minSizeForReservoirUse = getMinSizeForReservoirUse(this.reservoir); } else {
private void testBBPool(int maxPoolSize, int bufferSize, boolean directByteBuffer) { ByteBufferPool pool = new ByteBufferPool(bufferSize, maxPoolSize, directByteBuffer); for (int i = 0; i < maxPoolSize; i++) { ByteBuffer buffer = pool.getBuffer(); assertEquals(0, buffer.position()); assertEquals(bufferSize, buffer.limit()); assertEquals(directByteBuffer, buffer.isDirect()); } assertEquals(0, pool.getQueueSize()); ByteBuffer bb = directByteBuffer ? ByteBuffer.allocate(bufferSize) : ByteBuffer.allocateDirect(bufferSize); pool.putbackBuffer(bb); assertEquals(0, pool.getQueueSize()); bb = directByteBuffer ? ByteBuffer.allocateDirect(bufferSize + 1) : ByteBuffer.allocate(bufferSize + 1); pool.putbackBuffer(bb); assertEquals(0, pool.getQueueSize()); } }
@Test public void testWrites() throws Exception { ByteBufferPool pool = new ByteBufferPool(10, 3); ByteBufferListOutputStream bbos = new ByteBufferListOutputStream(pool); bbos.write(2);// Write a byte
@Test public void testAllocateByteBuffToReadInto() throws Exception { int maxBuffersInPool = 10; ByteBufferPool pool = new ByteBufferPool(6 * 1024, maxBuffersInPool); initPoolWithAllBuffers(pool, maxBuffersInPool); ByteBuff buff = null;
private void testBBPool(int maxPoolSize, int bufferSize, boolean directByteBuffer) { ByteBufferPool pool = new ByteBufferPool(bufferSize, maxPoolSize, directByteBuffer); for (int i = 0; i < maxPoolSize; i++) { ByteBuffer buffer = pool.getBuffer(); assertEquals(0, buffer.position()); assertEquals(bufferSize, buffer.limit()); assertEquals(directByteBuffer, buffer.isDirect()); } assertEquals(0, pool.getQueueSize()); ByteBuffer bb = directByteBuffer ? ByteBuffer.allocate(bufferSize) : ByteBuffer.allocateDirect(bufferSize); pool.putbackBuffer(bb); assertEquals(0, pool.getQueueSize()); bb = directByteBuffer ? ByteBuffer.allocateDirect(bufferSize + 1) : ByteBuffer.allocate(bufferSize + 1); pool.putbackBuffer(bb); assertEquals(0, pool.getQueueSize()); } }
private void testBBPool(int maxPoolSize, int bufferSize, boolean directByteBuffer) { ByteBufferPool pool = new ByteBufferPool(bufferSize, maxPoolSize, directByteBuffer); for (int i = 0; i < maxPoolSize; i++) { ByteBuffer buffer = pool.getBuffer(); assertEquals(0, buffer.position()); assertEquals(bufferSize, buffer.limit()); assertEquals(directByteBuffer, buffer.isDirect()); } assertEquals(0, pool.getQueueSize()); ByteBuffer bb = directByteBuffer ? ByteBuffer.allocate(bufferSize) : ByteBuffer.allocateDirect(bufferSize); pool.putbackBuffer(bb); assertEquals(0, pool.getQueueSize()); bb = directByteBuffer ? ByteBuffer.allocateDirect(bufferSize + 1) : ByteBuffer.allocate(bufferSize + 1); pool.putbackBuffer(bb); assertEquals(0, pool.getQueueSize()); } }
@Test public void testWrites() throws Exception { ByteBufferPool pool = new ByteBufferPool(10, 3); ByteBufferListOutputStream bbos = new ByteBufferListOutputStream(pool); bbos.write(2);// Write a byte
@Test public void testWrites() throws Exception { ByteBufferPool pool = new ByteBufferPool(10, 3); ByteBufferListOutputStream bbos = new ByteBufferListOutputStream(pool); bbos.write(2);// Write a byte
@Test public void testAllocateByteBuffToReadInto() throws Exception { int maxBuffersInPool = 10; ByteBufferPool pool = new ByteBufferPool(6 * 1024, maxBuffersInPool); initPoolWithAllBuffers(pool, maxBuffersInPool); ByteBuff buff = null;