List of usage examples for io.netty.buffer ByteBufAllocator isDirectBufferPooled
boolean isDirectBufferPooled();
From source file:org.apache.bookkeeper.common.allocator.impl.ByteBufAllocatorBuilderTest.java
License:Apache License
@Test public void testPooled() { PooledByteBufAllocator pooledAlloc = new PooledByteBufAllocator(true); ByteBufAllocator alloc = ByteBufAllocatorBuilder.create().poolingPolicy(PoolingPolicy.PooledDirect) .pooledAllocator(pooledAlloc).build(); assertTrue(alloc.isDirectBufferPooled()); ByteBuf buf1 = alloc.buffer();/* ww w.j a v a 2s . c om*/ assertEquals(pooledAlloc, buf1.alloc()); assertFalse(buf1.hasArray()); buf1.release(); ByteBuf buf2 = alloc.directBuffer(); assertEquals(pooledAlloc, buf2.alloc()); assertFalse(buf2.hasArray()); buf2.release(); ByteBuf buf3 = alloc.heapBuffer(); assertEquals(pooledAlloc, buf3.alloc()); assertTrue(buf3.hasArray()); buf3.release(); }
From source file:org.apache.bookkeeper.common.allocator.impl.ByteBufAllocatorBuilderTest.java
License:Apache License
@Test public void testPooledWithDefaultAllocator() { ByteBufAllocator alloc = ByteBufAllocatorBuilder.create().poolingPolicy(PoolingPolicy.PooledDirect) .poolingConcurrency(3).build(); assertTrue(alloc.isDirectBufferPooled()); ByteBuf buf1 = alloc.buffer();//from w w w .j av a2 s . c o m assertEquals(PooledByteBufAllocator.class, buf1.alloc().getClass()); assertEquals(3, ((PooledByteBufAllocator) buf1.alloc()).metric().numDirectArenas()); assertFalse(buf1.hasArray()); buf1.release(); ByteBuf buf2 = alloc.directBuffer(); assertFalse(buf2.hasArray()); buf2.release(); ByteBuf buf3 = alloc.heapBuffer(); assertTrue(buf3.hasArray()); buf3.release(); }