Package com.tangosol.io.nio
Class AbstractBufferManager
java.lang.Object
com.tangosol.util.Base
com.tangosol.io.nio.AbstractBufferManager
- All Implemented Interfaces:
ByteBufferManager
- Direct Known Subclasses:
MappedBufferManager
Provides a basic implementation of ByteBufferManager.
- Since:
- Coherence 2.2
- Author:
- cp 2002.09.19
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractBufferManager
(int cbInitial, int cbMaximum) Construct a AbstractBufferManager that supports a buffer of a certain initial and maximum size. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
Allocate a new buffer, copying old data if there is any.protected void
Determine the grow and shrink thresholds based on the current capacity.Get the current ByteBuffer reference.int
Get the capacity of the current ByteBuffer.int
Determine the level (what number of bytes used) above which the current ByteBuffer will need to be "resized" upwards.int
Determine the maximum size that the managed buffer can reach.protected int
int
Determine the minimum size that the managed buffer can reach.int
Determine the level (what number of bytes used) below which the current ByteBuffer will need to be "resized" downwards.void
grow
(int cbRequired) Request that the buffer be grown based on the number of bytes currently required.protected void
setBuffer
(ByteBuffer buffer) Set the current ByteBuffer reference.protected void
setCapacity
(int cb) Set the capacity of the current ByteBuffer.protected void
setGrowthThreshold
(int cb) Specify the level (what number of bytes used) above which the current ByteBuffer will need to be "resized" upwards.protected void
setMaxCapacity
(int cb) Specify the maximum size that the managed buffer can reach.protected void
setMinCapacity
(int cb) Specify the minimum size that the managed buffer can reach.protected void
setShrinkageThreshold
(int cb) Specify the level (what number of bytes used) below which the current ByteBuffer will need to be "resized" downwards.void
shrink
(int cbRequired) Request that the buffer be shrunk based on the number of bytes currently required.Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
Constructor Details
-
AbstractBufferManager
protected AbstractBufferManager(int cbInitial, int cbMaximum) Construct a AbstractBufferManager that supports a buffer of a certain initial and maximum size.- Parameters:
cbInitial
- the initial sizecbMaximum
- the maximum size
-
-
Method Details
-
getBuffer
Get the current ByteBuffer reference.- Specified by:
getBuffer
in interfaceByteBufferManager
- Returns:
- the current ByteBuffer
-
setBuffer
Set the current ByteBuffer reference.- Parameters:
buffer
- the current ByteBuffer
-
getCapacity
public int getCapacity()Get the capacity of the current ByteBuffer. This is the same asgetBuffer().capacity()
.- Specified by:
getCapacity
in interfaceByteBufferManager
- Returns:
- the capacity of the current ByteBuffer
-
setCapacity
protected void setCapacity(int cb) Set the capacity of the current ByteBuffer. This does not actually allocate a new buffer.- Parameters:
cb
- the capacity of the managed ByteBuffer
-
getGrowthThreshold
public int getGrowthThreshold()Determine the level (what number of bytes used) above which the current ByteBuffer will need to be "resized" upwards. Returns Integer.MAX_VALUE if the buffer cannot be resized upwards.- Specified by:
getGrowthThreshold
in interfaceByteBufferManager
- Returns:
- the number of bytes that, when the number of used bytes exceeds it, the ByteBuffer will need to grow
-
setGrowthThreshold
protected void setGrowthThreshold(int cb) Specify the level (what number of bytes used) above which the current ByteBuffer will need to be "resized" upwards.- Parameters:
cb
- the number of bytes that, when the number of used bytes exceeds it, the ByteBuffer will need to grow
-
getShrinkageThreshold
public int getShrinkageThreshold()Determine the level (what number of bytes used) below which the current ByteBuffer will need to be "resized" downwards. Returns 0 if the buffer cannot be resized downwards.- Specified by:
getShrinkageThreshold
in interfaceByteBufferManager
- Returns:
- the number of bytes that, when the number of used bytes drops below it, the ByteBuffer will need to shrink
-
setShrinkageThreshold
protected void setShrinkageThreshold(int cb) Specify the level (what number of bytes used) below which the current ByteBuffer will need to be "resized" downwards. Specify 0 if the buffer cannot be resized downwards.- Parameters:
cb
- the number of bytes that, when the number of used bytes drops below it, the ByteBuffer will need to shrink
-
getMinCapacity
public int getMinCapacity()Determine the minimum size that the managed buffer can reach. If the buffer is already at its minimum, then this method will return the same value asgetCapacity
.- Specified by:
getMinCapacity
in interfaceByteBufferManager
- Returns:
- minimum size for the managed buffer
-
setMinCapacity
protected void setMinCapacity(int cb) Specify the minimum size that the managed buffer can reach.- Parameters:
cb
- minimum size for the managed buffer
-
getMaxCapacity
public int getMaxCapacity()Determine the maximum size that the managed buffer can reach. If the buffer is already at its maximum, then this method will return the same value asgetCapacity
.- Specified by:
getMaxCapacity
in interfaceByteBufferManager
- Returns:
- maximum size for the managed buffer
-
setMaxCapacity
protected void setMaxCapacity(int cb) Specify the maximum size that the managed buffer can reach.- Parameters:
cb
- maximum size for the managed buffer
-
getMaxIncrement
protected int getMaxIncrement()- Returns:
- maximum size to grow in one step
-
grow
public void grow(int cbRequired) Request that the buffer be grown based on the number of bytes currently required.- Specified by:
grow
in interfaceByteBufferManager
- Parameters:
cbRequired
- the number of bytes that are needed by the requesting operation
-
shrink
public void shrink(int cbRequired) Request that the buffer be shrunk based on the number of bytes currently required.- Specified by:
shrink
in interfaceByteBufferManager
- Parameters:
cbRequired
- the number of contiguous bytes in the buffer, starting from offset 0, that are actually in use
-
calibrate
protected void calibrate()Determine the grow and shrink thresholds based on the current capacity. -
allocateBuffer
protected abstract void allocateBuffer()Allocate a new buffer, copying old data if there is any.
-