Class BufferPool
java.lang.Object
org.apache.catalina.tribes.io.BufferPool
Pool for reusing byte buffers in Tribes messaging.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum pool size in bytes (100 MiB).protected static BufferPoolSingleton instance of the buffer pool.protected intMaximum pool size in bytes.protected final ConcurrentLinkedQueue<XByteBuffer> Queue of available buffers.protected final AtomicIntegerCurrent total size of pooled buffers in bytes.protected static final StringManagerString manager for internationalized messages. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all buffers from the pool.getBuffer(int minSize, boolean discard) Retrieves a buffer from the pool.static BufferPoolReturns the singleton buffer pool instance.intReturns the maximum pool size.voidreturnBuffer(XByteBuffer buffer) Returns a buffer to the pool for reuse.voidsetMaxSize(int bytes) Sets the maximum pool size.
-
Field Details
-
DEFAULT_POOL_SIZE
public static final int DEFAULT_POOL_SIZEDefault maximum pool size in bytes (100 MiB). -
sm
String manager for internationalized messages. -
instance
Singleton instance of the buffer pool. -
maxSize
protected int maxSizeMaximum pool size in bytes. -
size
Current total size of pooled buffers in bytes. -
queue
Queue of available buffers.
-
-
Method Details
-
getBufferPool
Returns the singleton buffer pool instance.- Returns:
- the buffer pool
-
getBuffer
Retrieves a buffer from the pool.- Parameters:
minSize- minimum buffer sizediscard- discard flag- Returns:
- the buffer
-
returnBuffer
Returns a buffer to the pool for reuse.- Parameters:
buffer- the buffer to return
-
clear
public void clear()Clears all buffers from the pool. -
setMaxSize
public void setMaxSize(int bytes) Sets the maximum pool size.- Parameters:
bytes- maximum size in bytes
-
getMaxSize
public int getMaxSize()Returns the maximum pool size.- Returns:
- maximum size in bytes
-