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) boolean
exitOnOutOfMemory
(package private) LeakDetectionPolicy
leakDetectionPolicy
(package private) java.util.function.Consumer<java.lang.OutOfMemoryError>
outOfMemoryListener
(package private) OutOfMemoryPolicy
outOfMemoryPolicy
(package private) io.netty.buffer.ByteBufAllocator
pooledAllocator
(package private) int
poolingConcurrency
(package private) PoolingPolicy
poolingPolicy
(package private) io.netty.buffer.ByteBufAllocator
unpooledAllocator
-
Constructor Summary
Constructors Constructor Description ByteBufAllocatorBuilderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufAllocatorWithOomHandler
build()
Finalize the configuredByteBufAllocator
.ByteBufAllocatorBuilder
exitOnOutOfMemory(boolean exitOnOutOfMemory)
ByteBufAllocatorBuilder
leakDetectionPolicy(LeakDetectionPolicy leakDetectionPolicy)
Enable the leak detection for the allocator.ByteBufAllocatorBuilder
outOfMemoryListener(java.util.function.Consumer<java.lang.OutOfMemoryError> listener)
Add a listener that is triggered whenever there is an allocation failure.ByteBufAllocatorBuilder
outOfMemoryPolicy(OutOfMemoryPolicy policy)
Define the OutOfMemory handling policy.ByteBufAllocatorBuilder
pooledAllocator(io.netty.buffer.ByteBufAllocator pooledAllocator)
Specify a custom allocator where the allocation requests should be forwarded to.ByteBufAllocatorBuilder
poolingConcurrency(int poolingConcurrency)
Controls the amount of concurrency for the memory pool.ByteBufAllocatorBuilder
poolingPolicy(PoolingPolicy policy)
Define the memory pooling policy.ByteBufAllocatorBuilder
unpooledAllocator(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:ByteBufAllocatorBuilder
Finalize the configuredByteBufAllocator
.- Specified by:
build
in interfaceByteBufAllocatorBuilder
-
pooledAllocator
public ByteBufAllocatorBuilder pooledAllocator(io.netty.buffer.ByteBufAllocator pooledAllocator)
Description copied from interface:ByteBufAllocatorBuilder
Specify a custom allocator where the allocation requests should be forwarded to.Default is to use a new instance of
PooledByteBufAllocator
.- Specified by:
pooledAllocator
in interfaceByteBufAllocatorBuilder
-
unpooledAllocator
public ByteBufAllocatorBuilder unpooledAllocator(io.netty.buffer.ByteBufAllocator unpooledAllocator)
Description copied from interface:ByteBufAllocatorBuilder
Specify a custom allocator where the allocation requests should be forwarded to.Default is to use
UnpooledByteBufAllocator.DEFAULT
.- Specified by:
unpooledAllocator
in interfaceByteBufAllocatorBuilder
-
poolingPolicy
public ByteBufAllocatorBuilder poolingPolicy(PoolingPolicy policy)
Description copied from interface:ByteBufAllocatorBuilder
Define the memory pooling policy.Default is
PoolingPolicy.PooledDirect
- Specified by:
poolingPolicy
in interfaceByteBufAllocatorBuilder
-
poolingConcurrency
public ByteBufAllocatorBuilder poolingConcurrency(int poolingConcurrency)
Description copied from interface:ByteBufAllocatorBuilder
Controls 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:
poolingConcurrency
in interfaceByteBufAllocatorBuilder
-
outOfMemoryPolicy
public ByteBufAllocatorBuilder outOfMemoryPolicy(OutOfMemoryPolicy policy)
Description copied from interface:ByteBufAllocatorBuilder
Define the OutOfMemory handling policy.Default is
OutOfMemoryPolicy.FallbackToHeap
- Specified by:
outOfMemoryPolicy
in interfaceByteBufAllocatorBuilder
-
outOfMemoryListener
public ByteBufAllocatorBuilder outOfMemoryListener(java.util.function.Consumer<java.lang.OutOfMemoryError> listener)
Description copied from interface:ByteBufAllocatorBuilder
Add a listener that is triggered whenever there is an allocation failure.Application can use this to trigger alerting or process restarting.
- Specified by:
outOfMemoryListener
in interfaceByteBufAllocatorBuilder
-
leakDetectionPolicy
public ByteBufAllocatorBuilder leakDetectionPolicy(LeakDetectionPolicy leakDetectionPolicy)
Description copied from interface:ByteBufAllocatorBuilder
Enable the leak detection for the allocator.Default is
LeakDetectionPolicy.Disabled
- Specified by:
leakDetectionPolicy
in interfaceByteBufAllocatorBuilder
-
exitOnOutOfMemory
public ByteBufAllocatorBuilder exitOnOutOfMemory(boolean exitOnOutOfMemory)
- Specified by:
exitOnOutOfMemory
in interfaceByteBufAllocatorBuilder
-
-