BufferPool { public ByteBuffer acquireDirectReceiveBuffer(int size) { return acquireDirectBuffer(size, false); } BufferPool(DMStats stats); ByteBuffer acquireDirectSenderBuffer(int size); ByteBuffer acquireDirectReceiveBuffer(int size); ByteBuffer acquireNonDirectSenderBuffer(int size); ByteBuffer acquireNonDirectReceiveBuffer(int size); void releaseSenderBuffer(ByteBuffer bb); void releaseReceiveBuffer(ByteBuffer bb); @VisibleForTesting ByteBuffer getPoolableBuffer(ByteBuffer buffer); static final boolean useDirectBuffers; }
@Test public void checkBufferSizeAfterAllocation() throws Exception { ByteBuffer buffer = bufferPool.acquireDirectReceiveBuffer(100); ByteBuffer newBuffer = bufferPool.acquireDirectReceiveBuffer(10000); assertThat(buffer.isDirect()).isTrue(); assertThat(newBuffer.isDirect()).isTrue(); assertThat(buffer.capacity()).isEqualTo(100); assertThat(newBuffer.capacity()).isEqualTo(10000); assertThat(buffer.position()).isEqualTo(0); assertThat(buffer.limit()).isEqualTo(100); assertThat(newBuffer.position()).isEqualTo(0); assertThat(newBuffer.limit()).isEqualTo(10000); }