Class ByteBufAllocatorBuilderImpl
- java.lang.Object
-
- org.apache.bookkeeper.common.allocator.impl.ByteBufAllocatorBuilderImpl
-
- All Implemented Interfaces:
ByteBufAllocatorBuilder
public class ByteBufAllocatorBuilderImpl extends java.lang.Object implements ByteBufAllocatorBuilder
Implementation ofByteBufAllocatorBuilder.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleanexitOnOutOfMemory(package private) LeakDetectionPolicyleakDetectionPolicy(package private) java.util.function.Consumer<java.lang.OutOfMemoryError>outOfMemoryListener(package private) OutOfMemoryPolicyoutOfMemoryPolicy(package private) io.netty.buffer.ByteBufAllocatorpooledAllocator(package private) intpoolingConcurrency(package private) PoolingPolicypoolingPolicy(package private) io.netty.buffer.ByteBufAllocatorunpooledAllocator
-
Constructor Summary
Constructors Constructor Description ByteBufAllocatorBuilderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufAllocatorWithOomHandlerbuild()Finalize the configuredByteBufAllocator.ByteBufAllocatorBuilderexitOnOutOfMemory(boolean exitOnOutOfMemory)ByteBufAllocatorBuilderleakDetectionPolicy(LeakDetectionPolicy leakDetectionPolicy)Enable the leak detection for the allocator.ByteBufAllocatorBuilderoutOfMemoryListener(java.util.function.Consumer<java.lang.OutOfMemoryError> listener)Add a listener that is triggered whenever there is an allocation failure.ByteBufAllocatorBuilderoutOfMemoryPolicy(OutOfMemoryPolicy policy)Define the OutOfMemory handling policy.ByteBufAllocatorBuilderpooledAllocator(io.netty.buffer.ByteBufAllocator pooledAllocator)Specify a custom allocator where the allocation requests should be forwarded to.ByteBufAllocatorBuilderpoolingConcurrency(int poolingConcurrency)Controls the amount of concurrency for the memory pool.ByteBufAllocatorBuilderpoolingPolicy(PoolingPolicy policy)Define the memory pooling policy.ByteBufAllocatorBuilderunpooledAllocator(io.netty.buffer.ByteBufAllocator unpooledAllocator)Specify a custom allocator where the allocation requests should be forwarded to.
-
-
-
Field Detail
-
pooledAllocator
io.netty.buffer.ByteBufAllocator pooledAllocator
-
unpooledAllocator
io.netty.buffer.ByteBufAllocator unpooledAllocator
-
poolingPolicy
PoolingPolicy poolingPolicy
-
poolingConcurrency
int poolingConcurrency
-
outOfMemoryPolicy
OutOfMemoryPolicy outOfMemoryPolicy
-
outOfMemoryListener
java.util.function.Consumer<java.lang.OutOfMemoryError> outOfMemoryListener
-
leakDetectionPolicy
LeakDetectionPolicy leakDetectionPolicy
-
exitOnOutOfMemory
boolean exitOnOutOfMemory
-
-
Method Detail
-
build
public ByteBufAllocatorWithOomHandler build()
Description copied from interface:ByteBufAllocatorBuilderFinalize the configuredByteBufAllocator.- Specified by:
buildin interfaceByteBufAllocatorBuilder
-
pooledAllocator
public ByteBufAllocatorBuilder pooledAllocator(io.netty.buffer.ByteBufAllocator pooledAllocator)
Description copied from interface:ByteBufAllocatorBuilderSpecify a custom allocator where the allocation requests should be forwarded to.Default is to use a new instance of
PooledByteBufAllocator.- Specified by:
pooledAllocatorin interfaceByteBufAllocatorBuilder
-
unpooledAllocator
public ByteBufAllocatorBuilder unpooledAllocator(io.netty.buffer.ByteBufAllocator unpooledAllocator)
Description copied from interface:ByteBufAllocatorBuilderSpecify a custom allocator where the allocation requests should be forwarded to.Default is to use
UnpooledByteBufAllocator.DEFAULT.- Specified by:
unpooledAllocatorin interfaceByteBufAllocatorBuilder
-
poolingPolicy
public ByteBufAllocatorBuilder poolingPolicy(PoolingPolicy policy)
Description copied from interface:ByteBufAllocatorBuilderDefine the memory pooling policy.Default is
PoolingPolicy.PooledDirect- Specified by:
poolingPolicyin interfaceByteBufAllocatorBuilder
-
poolingConcurrency
public ByteBufAllocatorBuilder poolingConcurrency(int poolingConcurrency)
Description copied from interface:ByteBufAllocatorBuilderControls the amount of concurrency for the memory pool.Default is to have a number of allocator arenas equals to 2 * CPUS.
Decreasing this number will reduce the amount of memory overhead, at the expense of increased allocation contention.
- Specified by:
poolingConcurrencyin interfaceByteBufAllocatorBuilder
-
outOfMemoryPolicy
public ByteBufAllocatorBuilder outOfMemoryPolicy(OutOfMemoryPolicy policy)
Description copied from interface:ByteBufAllocatorBuilderDefine the OutOfMemory handling policy.Default is
OutOfMemoryPolicy.FallbackToHeap- Specified by:
outOfMemoryPolicyin interfaceByteBufAllocatorBuilder
-
outOfMemoryListener
public ByteBufAllocatorBuilder outOfMemoryListener(java.util.function.Consumer<java.lang.OutOfMemoryError> listener)
Description copied from interface:ByteBufAllocatorBuilderAdd a listener that is triggered whenever there is an allocation failure.Application can use this to trigger alerting or process restarting.
- Specified by:
outOfMemoryListenerin interfaceByteBufAllocatorBuilder
-
leakDetectionPolicy
public ByteBufAllocatorBuilder leakDetectionPolicy(LeakDetectionPolicy leakDetectionPolicy)
Description copied from interface:ByteBufAllocatorBuilderEnable the leak detection for the allocator.Default is
LeakDetectionPolicy.Disabled- Specified by:
leakDetectionPolicyin interfaceByteBufAllocatorBuilder
-
exitOnOutOfMemory
public ByteBufAllocatorBuilder exitOnOutOfMemory(boolean exitOnOutOfMemory)
- Specified by:
exitOnOutOfMemoryin interfaceByteBufAllocatorBuilder
-
-