#include <coherence/net/cache/AbstractBundler.hpp>
Inherits Object.
Inherited by AbstractEntryBundler, and 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:
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 int32_to 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.
Public Types | |
typedef spec::Handle | Handle |
AbstractBundler Handle definition. | |
typedef spec::View | View |
AbstractBundler View definition. | |
typedef spec::Holder | Holder |
AbstractBundler Holder definition. | |
typedef this_spec::Handle | Handle |
Object Handle definition. | |
typedef this_spec::View | View |
Object View definition. | |
typedef this_spec::Holder | Holder |
Object Holder definition. | |
Public Member Functions | |
virtual int32_t | getSizeThreshold () const |
Obtain the bundle size threshold value. | |
virtual void | setSizeThreshold (int32_t cSize) |
Specify the bundle size threshold value. | |
virtual int32_t | getThreadThreshold () const |
Obtains the minimum number of threads that will trigger the bundler to switch from a pass through to a bundled mode. | |
virtual void | setThreadThreshold (int32_t cThreads) |
Specify the minimum number of threads that will trigger the bundler to switch from a pass through to a bundled mode. | |
virtual int64_t | getDelayMillis () const |
Obtain the timeout delay value. | |
virtual void | setDelayMillis (int64_t lDelay) |
Specify the timeout delay value. | |
virtual bool | isAllowAutoAdjust () const |
Check whether or not auto-adjustment is allowed. | |
virtual void | setAllowAutoAdjust (bool fAutoAdjust) |
Specify whether or not auto-adjustment is allowed. | |
virtual void | resetStatistics () |
Reset this Bundler statistics. | |
virtual void | adjust () |
Adjust this Bundler's parameters according to the available statistical information. | |
virtual TypedHandle < const String > | toString () const |
Output a human-readable description of this Object to the given stream. Note that when overriding this method the return type must be TypedHandle<const String> rather then String::View. These two types are assignment compatible but not equivalent and declaring the override with String::View will not be a compatible override. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toString method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents and is generally how toString() will be implemented.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::View vs = COH_TO_STRING(vKey << " = " << vValue); The COH_TO_STRING macro is also the most common way to implement the toString method. For example:
virtual TypedHandle<const String> Person::toString() const { return COH_TO_STRING("Name: " << f_sName << " SSN: " << f_nSSN); }
| |
Static Public Attributes | |
static const int32_t | adjustment_frequency |
Frequency of the adjustment attempts. | |
Protected Member Functions | |
AbstractBundler () | |
Construct the bundler. | |
virtual void | updateStatistics () |
Update the statistics for this Bundle. | |
virtual void | init (Bundle::Handle hBundle) |
Initialize the bundler. | |
virtual Bundle::Handle | getOpenBundle () |
Retrieve any Bundle that is currently in the open state. | |
virtual Bundle::Handle | instantiateBundle ()=0 |
Instantiate a new Bundle object. | |
Protected Attributes | |
bool | m_fFirstAdjustment |
Indicate whether this is a first time adjustment. | |
double | m_dPreviousSizeThreshold |
The previous bundle size threshold value. | |
FinalHandle< List > | f_hListBundle |
A pool of Bundle objects. | |
FinalHandle < AtomicCounter > | f_hCountThreads |
A counter for the total number of threads that have started any bundle related execution. | |
Classes | |
class | Bundle |
Bundle represents a unit of optimized execution. More... | |
class | Statistics |
Statistics class contains the latest bundler statistics. More... |
AbstractBundler | ( | ) | [protected] |
Construct the bundler.
By default, the timeout delay value is set to one millisecond and the auto-adjustment feature is turned on.
virtual int32_t getSizeThreshold | ( | ) | const [virtual] |
Obtain the bundle size threshold value.
virtual void setSizeThreshold | ( | int32_t | cSize | ) | [virtual] |
Specify the bundle size threshold value.
cSize | the bundle size threshold value; must be positive value expressed in the same units as the value returned by the Bundle::getBundleSize() method |
virtual int32_t getThreadThreshold | ( | ) | const [virtual] |
Obtains the minimum number of threads that will trigger the bundler to switch from a pass through to a bundled mode.
virtual void setThreadThreshold | ( | int32_t | cThreads | ) | [virtual] |
Specify the minimum number of threads that will trigger the bundler to switch from a pass through to a bundled mode.
cThreads | the number of threads threshold |
virtual int64_t getDelayMillis | ( | ) | const [virtual] |
Obtain the timeout delay value.
virtual void setDelayMillis | ( | int64_t | lDelay | ) | [virtual] |
Specify the timeout delay value.
lDelay | the timeout delay value in milliseconds |
virtual bool isAllowAutoAdjust | ( | ) | const [virtual] |
Check whether or not auto-adjustment is allowed.
virtual void setAllowAutoAdjust | ( | bool | fAutoAdjust | ) | [virtual] |
Specify whether or not auto-adjustment is allowed.
fAutoAdjust | true if auto-adjustment should be allowed; false otherwise |
virtual void init | ( | Bundle::Handle | hBundle | ) | [protected, virtual] |
Initialize the bundler.
hBundle | specifies the bundle for this bundler |
virtual Bundle::Handle getOpenBundle | ( | ) | [protected, virtual] |
virtual Bundle::Handle instantiateBundle | ( | ) | [protected, pure virtual] |
Instantiate a new Bundle object.
Implemented in AbstractEntryBundler, and AbstractKeyBundler.
const int32_t adjustment_frequency [static] |
Frequency of the adjustment attempts.
This number represents a number of iterations of the master bundle usage after which an adjustment attempt will be performed.
FinalHandle<List> f_hListBundle [protected] |
A pool of Bundle objects.
Note that this list never shrinks.
FinalHandle<AtomicCounter> f_hCountThreads [protected] |
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.