java.lang.Object
org.eclipse.jetty.io.ArrayRetainableByteBufferPool
- All Implemented Interfaces:
RetainableByteBufferPool,org.eclipse.jetty.util.component.Dumpable
- Direct Known Subclasses:
ArrayByteBufferPool.Retained,LogarithmicArrayByteBufferPool.LogarithmicRetainablePool,MappedByteBufferPool.Retained
@ManagedObject
public class ArrayRetainableByteBufferPool
extends Object
implements RetainableByteBufferPool, org.eclipse.jetty.util.component.Dumpable
A RetainableByteBuffer pool where RetainableByteBuffers are held in Pools that are
held in array elements.
Given a capacity factor of 1024, the first array element holds a Pool of RetainableByteBuffers
each of capacity 1024, the second array element holds a Pool of RetainableByteBuffers each of capacity
2048, and so on.
The maxHeapMemory and maxDirectMemory default heuristic is to use Runtime.maxMemory()
divided by 4.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.io.RetainableByteBufferPool
RetainableByteBufferPool.NotRetainedByteBufferPool -
Field Summary
Fields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a new ArrayRetainableByteBufferPool with a default configuration.ArrayRetainableByteBufferPool(int minCapacity, int factor, int maxCapacity, int maxBucketSize) Creates a new ArrayRetainableByteBufferPool with the given configuration.ArrayRetainableByteBufferPool(int minCapacity, int factor, int maxCapacity, int maxBucketSize, long maxHeapMemory, long maxDirectMemory) Creates a new ArrayRetainableByteBufferPool with the given configuration.protectedArrayRetainableByteBufferPool(int minCapacity, int factor, int maxCapacity, int maxBucketSize, long maxHeapMemory, long maxDirectMemory, Function<Integer, Integer> bucketIndexFor, Function<Integer, Integer> bucketCapacity) Deprecated.protectedArrayRetainableByteBufferPool(int minCapacity, int factor, int maxCapacity, int maxBucketSize, IntUnaryOperator bucketIndexFor, IntUnaryOperator bucketCapacity, long maxHeapMemory, long maxDirectMemory) Creates a new ArrayRetainableByteBufferPool with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionacquire(int size, boolean direct) Acquires a memory buffer from the pool.protected ByteBufferallocate(int capacity) protected ByteBufferallocateDirect(int capacity) voidclear()voiddump(Appendable out, String indent) longlonglonglonglonglonglonglongintintprotected org.eclipse.jetty.util.Pool<RetainableByteBuffer> poolFor(int capacity, boolean direct) protected voidremoved(RetainableByteBuffer retainedBuffer) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable
dump, dumpSelf
-
Constructor Details
-
ArrayRetainableByteBufferPool
public ArrayRetainableByteBufferPool()Creates a new ArrayRetainableByteBufferPool with a default configuration. BothmaxHeapMemoryandmaxDirectMemorydefault to 0 to use default heuristic. -
ArrayRetainableByteBufferPool
public ArrayRetainableByteBufferPool(int minCapacity, int factor, int maxCapacity, int maxBucketSize) Creates a new ArrayRetainableByteBufferPool with the given configuration. BothmaxHeapMemoryandmaxDirectMemorydefault to 0 to use default heuristic.- Parameters:
minCapacity- the minimum ByteBuffer capacityfactor- the capacity factormaxCapacity- the maximum ByteBuffer capacitymaxBucketSize- the maximum number of ByteBuffers for each bucket
-
ArrayRetainableByteBufferPool
public ArrayRetainableByteBufferPool(int minCapacity, int factor, int maxCapacity, int maxBucketSize, long maxHeapMemory, long maxDirectMemory) Creates a new ArrayRetainableByteBufferPool with the given configuration.- Parameters:
minCapacity- the minimum ByteBuffer capacityfactor- the capacity factormaxCapacity- the maximum ByteBuffer capacitymaxBucketSize- the maximum number of ByteBuffers for each bucketmaxHeapMemory- the max heap memory in bytes, -1 for unlimited memory or 0 to use default heuristicmaxDirectMemory- the max direct memory in bytes, -1 for unlimited memory or 0 to use default heuristic
-
ArrayRetainableByteBufferPool
@Deprecated protected ArrayRetainableByteBufferPool(int minCapacity, int factor, int maxCapacity, int maxBucketSize, long maxHeapMemory, long maxDirectMemory, Function<Integer, Integer> bucketIndexFor, Function<Integer, Integer> bucketCapacity) Deprecated.Creates a new ArrayRetainableByteBufferPool with the given configuration.- Parameters:
minCapacity- the minimum ByteBuffer capacityfactor- the capacity factormaxCapacity- the maximum ByteBuffer capacitymaxBucketSize- the maximum number of ByteBuffers for each bucketmaxHeapMemory- the max heap memory in bytes, -1 for unlimited memory or 0 to use default heuristicmaxDirectMemory- the max direct memory in bytes, -1 for unlimited memory or 0 to use default heuristicbucketIndexFor- aFunctionthat takes a capacity and returns a bucket indexbucketCapacity- aFunctionthat takes a bucket index and returns a capacity
-
ArrayRetainableByteBufferPool
protected ArrayRetainableByteBufferPool(int minCapacity, int factor, int maxCapacity, int maxBucketSize, IntUnaryOperator bucketIndexFor, IntUnaryOperator bucketCapacity, long maxHeapMemory, long maxDirectMemory) Creates a new ArrayRetainableByteBufferPool with the given configuration.- Parameters:
minCapacity- the minimum ByteBuffer capacityfactor- the capacity factormaxCapacity- the maximum ByteBuffer capacitymaxBucketSize- the maximum number of ByteBuffers for each bucketbucketIndexFor- aIntUnaryOperatorthat takes a capacity and returns a bucket indexbucketCapacity- aIntUnaryOperatorthat takes a bucket index and returns a capacitymaxHeapMemory- the max heap memory in bytes, -1 for unlimited memory or 0 to use default heuristicmaxDirectMemory- the max direct memory in bytes, -1 for unlimited memory or 0 to use default heuristic
-
-
Method Details
-
getMinCapacity
@ManagedAttribute("The minimum pooled buffer capacity") public int getMinCapacity() -
getMaxCapacity
@ManagedAttribute("The maximum pooled buffer capacity") public int getMaxCapacity() -
acquire
Description copied from interface:RetainableByteBufferPoolAcquires a memory buffer from the pool.- Specified by:
acquirein interfaceRetainableByteBufferPool- Parameters:
size- The size of the buffer. The returned buffer will have at least this capacity.direct- true if a direct memory buffer is needed, false otherwise.- Returns:
- a memory buffer with position and size set to 0.
-
allocate
-
allocateDirect
-
removed
-
poolFor
-
getDirectByteBufferCount
@ManagedAttribute("The number of pooled direct ByteBuffers") public long getDirectByteBufferCount() -
getHeapByteBufferCount
@ManagedAttribute("The number of pooled heap ByteBuffers") public long getHeapByteBufferCount() -
getAvailableDirectByteBufferCount
@ManagedAttribute("The number of pooled direct ByteBuffers that are available") public long getAvailableDirectByteBufferCount() -
getAvailableHeapByteBufferCount
@ManagedAttribute("The number of pooled heap ByteBuffers that are available") public long getAvailableHeapByteBufferCount() -
getDirectMemory
@ManagedAttribute("The bytes retained by direct ByteBuffers") public long getDirectMemory() -
getHeapMemory
@ManagedAttribute("The bytes retained by heap ByteBuffers") public long getHeapMemory() -
getAvailableDirectMemory
@ManagedAttribute("The available bytes retained by direct ByteBuffers") public long getAvailableDirectMemory() -
getAvailableHeapMemory
@ManagedAttribute("The available bytes retained by heap ByteBuffers") public long getAvailableHeapMemory() -
clear
@ManagedOperation(value="Clears this RetainableByteBufferPool", impact="ACTION") public void clear()- Specified by:
clearin interfaceRetainableByteBufferPool
-
toString
-
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
IOException
-
ArrayRetainableByteBufferPool(int, int, int, int, IntUnaryOperator, IntUnaryOperator, long, long)instead