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:
- DirectBufferManager,- MappedBufferManager
Provides a basic implementation of ByteBufferManager.
- Since:
- Coherence 2.2
- Author:
- cp 2002.09.19
- 
Nested Class SummaryNested classes/interfaces inherited from class com.tangosol.util.BaseBase.LoggingWriter
- 
Field Summary
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractBufferManager(int cbInitial, int cbMaximum) Construct a AbstractBufferManager that supports a buffer of a certain initial and maximum size.
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract voidAllocate a new buffer, copying old data if there is any.protected voidDetermine the grow and shrink thresholds based on the current capacity.Get the current ByteBuffer reference.intGet the capacity of the current ByteBuffer.intDetermine the level (what number of bytes used) above which the current ByteBuffer will need to be "resized" upwards.intDetermine the maximum size that the managed buffer can reach.protected intintDetermine the minimum size that the managed buffer can reach.intDetermine the level (what number of bytes used) below which the current ByteBuffer will need to be "resized" downwards.voidgrow(int cbRequired) Request that the buffer be grown based on the number of bytes currently required.protected voidsetBuffer(ByteBuffer buffer) Set the current ByteBuffer reference.protected voidsetCapacity(int cb) Set the capacity of the current ByteBuffer.protected voidsetGrowthThreshold(int cb) Specify the level (what number of bytes used) above which the current ByteBuffer will need to be "resized" upwards.protected voidsetMaxCapacity(int cb) Specify the maximum size that the managed buffer can reach.protected voidsetMinCapacity(int cb) Specify the minimum size that the managed buffer can reach.protected voidsetShrinkageThreshold(int cb) Specify the level (what number of bytes used) below which the current ByteBuffer will need to be "resized" downwards.voidshrink(int cbRequired) Request that the buffer be shrunk based on the number of bytes currently required.Methods inherited from class com.tangosol.util.Baseazzert, 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, newHashMap, newHashMap, newHashSet, newHashSet, 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- 
AbstractBufferManagerprotected AbstractBufferManager(int cbInitial, int cbMaximum) Construct a AbstractBufferManager that supports a buffer of a certain initial and maximum size.- Parameters:
- cbInitial- the initial size
- cbMaximum- the maximum size
 
 
- 
- 
Method Details- 
getBufferGet the current ByteBuffer reference.- Specified by:
- getBufferin interface- ByteBufferManager
- Returns:
- the current ByteBuffer
 
- 
setBufferSet the current ByteBuffer reference.- Parameters:
- buffer- the current ByteBuffer
 
- 
getCapacitypublic int getCapacity()Get the capacity of the current ByteBuffer. This is the same asgetBuffer().capacity().- Specified by:
- getCapacityin interface- ByteBufferManager
- Returns:
- the capacity of the current ByteBuffer
 
- 
setCapacityprotected 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
 
- 
getGrowthThresholdpublic 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:
- getGrowthThresholdin interface- ByteBufferManager
- Returns:
- the number of bytes that, when the number of used bytes exceeds it, the ByteBuffer will need to grow
 
- 
setGrowthThresholdprotected 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
 
- 
getShrinkageThresholdpublic 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:
- getShrinkageThresholdin interface- ByteBufferManager
- Returns:
- the number of bytes that, when the number of used bytes drops below it, the ByteBuffer will need to shrink
 
- 
setShrinkageThresholdprotected 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
 
- 
getMinCapacitypublic 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:
- getMinCapacityin interface- ByteBufferManager
- Returns:
- minimum size for the managed buffer
 
- 
setMinCapacityprotected void setMinCapacity(int cb) Specify the minimum size that the managed buffer can reach.- Parameters:
- cb- minimum size for the managed buffer
 
- 
getMaxCapacitypublic 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:
- getMaxCapacityin interface- ByteBufferManager
- Returns:
- maximum size for the managed buffer
 
- 
setMaxCapacityprotected void setMaxCapacity(int cb) Specify the maximum size that the managed buffer can reach.- Parameters:
- cb- maximum size for the managed buffer
 
- 
getMaxIncrementprotected int getMaxIncrement()- Returns:
- maximum size to grow in one step
 
- 
growpublic void grow(int cbRequired) Request that the buffer be grown based on the number of bytes currently required.- Specified by:
- growin interface- ByteBufferManager
- Parameters:
- cbRequired- the number of bytes that are needed by the requesting operation
 
- 
shrinkpublic void shrink(int cbRequired) Request that the buffer be shrunk based on the number of bytes currently required.- Specified by:
- shrinkin interface- ByteBufferManager
- Parameters:
- cbRequired- the number of contiguous bytes in the buffer, starting from offset 0, that are actually in use
 
- 
calibrateprotected void calibrate()Determine the grow and shrink thresholds based on the current capacity.
- 
allocateBufferprotected abstract void allocateBuffer()Allocate a new buffer, copying old data if there is any.
 
-