Class AbstractBundler
- Direct Known Subclasses:
AbstractBinaryEntryBundler
,AbstractEntryBundler
,AbstractKeyBundler
Assume that we receive a continuous and concurrent stream of individual operations on multiple threads in parallel. Let's also assume those individual operations have relatively high latency (network or database-related) and there are functionally analogous [bulk] operations that take a collection of arguments instead of a single one without causing the latency to grow linearly, as a function of the collection size. Examples of operations and topologies that satisfy these assumptions are:
- get() and getAll() methods for the
NamedCache
API for the partitioned cache service topology; - put() and putAll() methods for the
NamedCache
API for the partitioned cache service topology; - load() and loadAll() methods for the
CacheLoader
API for the read-through backing map topology; - store() and storeAll() methods for the
CacheStore
API for the write-through backing map topology.
Under these assumptions, it's quite clear that the bundler could achieve a better utilization of system resources and better throughput if slightly delays the individual execution requests with a purpose of "bundling" them together and passing into a corresponding bulk operation. Additionally, the "bundled" request should be triggered if a bundle reaches a "preferred bundle size" threshold, eliminating a need to wait till a bundle timeout is reached.
Note: we assume that all bundle-able operations are idempotent and could be repeated if un-bundling is necessary due to a bundled operation failure.
- Since:
- Coherence 3.3
- Author:
- gg 2007.01.28
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Bundle represents a unit of optimized execution.protected static class
Statistics class contains the latest bundler statistics.Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Frequency of the adjustment attempts.protected AtomicInteger
A counter for the total number of threads that have started any bundle related execution.protected double
The previous bundle size threshold value.protected List
A pool of Bundle objects. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
adjust()
Adjust this Bundler's parameters according to the available statistical information.long
Obtain the timeout delay value.protected AbstractBundler.Bundle
Retrieve any Bundle that is currently in the open state.int
Obtain the bundle size threshold value.int
Obtains the minimum number of threads that will trigger the bundler to switch from a pass through to a bundled mode.protected abstract AbstractBundler.Bundle
Instantiate a new Bundle object.boolean
Check whether or not the auto-adjustment is allowed.void
Reset this Bundler statistics.void
setAllowAutoAdjust
(boolean fAutoAdjust) Specify whether or not the auto-adjustment is allowed..void
setDelayMillis
(long lDelay) Specify the timeout delay value.void
setSizeThreshold
(int cSize) Specify the bundle size threshold value.void
setThreadThreshold
(int cThreads) Specify the minimum number of threads that will trigger the bundler to switch from a pass through to a bundled mode.toString()
Provide a human readable description for the Bundler object (for debugging).protected void
Update the statistics for this Bundle.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
-
Field Details
-
ADJUSTMENT_FREQUENCY
public static int ADJUSTMENT_FREQUENCYFrequency of the adjustment attempts. This number represents a number of iterations of the master bundle usage after which an adjustment attempt will be performed. -
m_dPreviousSizeThreshold
protected double m_dPreviousSizeThresholdThe previous bundle size threshold value. -
m_listBundle
A pool of Bundle objects. Note that this list never shrinks. -
m_countThreads
A counter for the total number of threads that have started any bundle related execution. This counter is used by subclasses to reduce an impact of bundled execution for lightly loaded environments.
-
-
Constructor Details
-
AbstractBundler
public AbstractBundler()Construct the bundler. By default, the timeout delay value is set to one millisecond and the auto-adjustment feature is turned on.
-
-
Method Details
-
getSizeThreshold
public int getSizeThreshold()Obtain the bundle size threshold value.- Returns:
- the bundle size threshold value expressed in the same units as the
value returned by the
AbstractBundler.Bundle.getBundleSize()
method
-
setSizeThreshold
public void setSizeThreshold(int cSize) Specify the bundle size threshold value.- Parameters:
cSize
- the bundle size threshold value; must be positive value expressed in the same units as the value returned by theAbstractBundler.Bundle.getBundleSize()
method
-
getThreadThreshold
public int getThreadThreshold()Obtains the minimum number of threads that will trigger the bundler to switch from a pass through to a bundled mode.- Returns:
- a the number of threads threshold
-
setThreadThreshold
public void setThreadThreshold(int cThreads) Specify the minimum number of threads that will trigger the bundler to switch from a pass through to a bundled mode.- Parameters:
cThreads
- the number of threads threshold
-
getDelayMillis
public long getDelayMillis()Obtain the timeout delay value.- Returns:
- the timeout delay value in milliseconds
-
setDelayMillis
public void setDelayMillis(long lDelay) Specify the timeout delay value.- Parameters:
lDelay
- the timeout delay value in milliseconds
-
isAllowAutoAdjust
public boolean isAllowAutoAdjust()Check whether or not the auto-adjustment is allowed.- Returns:
- true iff the auto-adjustment is allowed
-
setAllowAutoAdjust
public void setAllowAutoAdjust(boolean fAutoAdjust) Specify whether or not the auto-adjustment is allowed..- Parameters:
fAutoAdjust
- true if the auto-adjustment should be allowed; false otherwise
-
updateStatistics
protected void updateStatistics()Update the statistics for this Bundle. -
resetStatistics
public void resetStatistics()Reset this Bundler statistics. -
adjust
public void adjust()Adjust this Bundler's parameters according to the available statistical information. -
toString
Provide a human readable description for the Bundler object (for debugging). -
getOpenBundle
Retrieve any Bundle that is currently in the open state. This method does not assume any external synchronization and as a result, a caller must double check the returned bundle open state (after synchronizing on it).- Returns:
- an open Bundle
-
instantiateBundle
Instantiate a new Bundle object.- Returns:
- a new Bundle object
-