org::xmlBlaster::util::queue::CacheQueuePlugin Class Reference

This class implements a very simple cache around the RAM and SQLite queue. More...

Inheritance diagram for org::xmlBlaster::util::queue::CacheQueuePlugin:

Inheritance graph
[legend]
Collaboration diagram for org::xmlBlaster::util::queue::CacheQueuePlugin:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CacheQueuePlugin (org::xmlBlaster::util::Global &global, org::xmlBlaster::util::qos::storage::ClientQueueProperty &property)
virtual ~CacheQueuePlugin ()
void put (MsgQueueEntry &entry)
 puts a new entry into the queue.
std::vector< EntryTypepeekWithSamePriority (long maxNumOfEntries=-1, long maxNumOfBytes=-1)
 Returns the entries with the highest priority in the queue.
long randomRemove (std::vector< EntryType >::const_iterator &start, std::vector< EntryType >::const_iterator &end)
 Deletes the entries specified in the std::vector in the argument list.
long getNumOfEntries ()
 Access the current number of entries.
long getMaxNumOfEntries ()
 Access the configured maximum number of elements for this queue.
int64_t getNumOfBytes ()
 Returns the amount of bytes currently in the queue.
int64_t getMaxNumOfBytes ()
 Access the configured capacity (maximum bytes) for this queue.
void clear ()
 Clears (removes all entries) this queue.
bool empty ()
 returns true if the queue is empty, false otherwise
std::string getType ()
 Get the name of the plugin.
std::string getVersion ()
 Get the version of the plugin.
void destroy ()
 Removes all entries and cleans up the storage, for example with a database it would remove all tables and relating database files.

Static Public Member Functions

static std::string usage ()

Protected Attributes

std::string ME
org::xmlBlaster::util::Globalglobal_
org::xmlBlaster::util::I_Loglog_

Properties

org::xmlBlaster::util::qos::storage::ClientQueueProperty _
I_QueuetransientQueueP_
I_QueuepersistentQueueP_
org::xmlBlaster::util::thread::Mutex accessMutex_

Detailed Description

This class implements a very simple cache around the RAM and SQLite queue.

Note there is no swapping support for transient or persistent messages all transient messages are hold in RAM, and all persistent messages are duplicated to harddisk. When time permits we will add swapping support similar to the Java CACHE implementation.
If you have mainly persistent messages and need to take care on your RAM consumption with many messages in queue consider to use the "SQLite" persistent queue directly (without any RAM or CACHE) with the option -connection/queue/type SQLite instead of the default -connection/queue/type CACHE.
On the other hand if you use only transient message consider using the RAM queue directly with the option -connection/queue/type RAM instead of the default -connection/queue/type CACHE.

Author:
Marcel Ruff
See also:
The client.cpp.queue requirement

Definition at line 41 of file CacheQueuePlugin.h.


Constructor & Destructor Documentation

org::xmlBlaster::util::queue::CacheQueuePlugin::CacheQueuePlugin ( org::xmlBlaster::util::Global global,
org::xmlBlaster::util::qos::storage::ClientQueueProperty property 
)

Definition at line 21 of file CacheQueuePlugin.cpp.

References org::xmlBlaster::util::queue::QueueFactory::getFactory(), org::xmlBlaster::util::XmlBlasterException::getMessage(), org::xmlBlaster::util::queue::QueueFactory::getPlugin(), getType(), getVersion(), global_, org::xmlBlaster::util::I_Log::info(), log_, ME, persistentQueueP_, transientQueueP_, and org::xmlBlaster::util::I_Log::warn().

org::xmlBlaster::util::queue::CacheQueuePlugin::~CacheQueuePlugin (  )  [virtual]

Definition at line 69 of file CacheQueuePlugin.cpp.

References org::xmlBlaster::util::I_Log::call(), org::xmlBlaster::util::queue::QueueFactory::getFactory(), log_, ME, persistentQueueP_, org::xmlBlaster::util::queue::QueueFactory::releasePlugin(), and transientQueueP_.


Member Function Documentation

void org::xmlBlaster::util::queue::CacheQueuePlugin::put ( MsgQueueEntry entry  )  [virtual]

puts a new entry into the queue.

Note that this method takes the entry pointed to by the argument and puts a reference to it into the queue. This means that you can not destroy the entry before the reference to it has been removed from the queue (which normally happens on a remove or when destroying the queue.

Implements org::xmlBlaster::util::queue::I_Queue.

Definition at line 76 of file CacheQueuePlugin.cpp.

References accessMutex_, org::xmlBlaster::util::I_Log::call(), org::xmlBlaster::util::XmlBlasterException::getMessage(), org::xmlBlaster::util::queue::MsgQueueEntry::isPersistent(), log_, ME, persistentQueueP_, org::xmlBlaster::util::queue::I_Queue::put(), transientQueueP_, and org::xmlBlaster::util::I_Log::warn().

vector< EntryType > org::xmlBlaster::util::queue::CacheQueuePlugin::peekWithSamePriority ( long  maxNumOfEntries = -1,
long  maxNumOfBytes = -1 
) [virtual]

Returns the entries with the highest priority in the queue.

If 'maxNumOfEntries' is positive, this is the maximum number of entries to return. If maxNumOfBytes is positive, only the entries which fit into the range specified are returned. If there are no such entries, an empty std::vector is returned.

Implements org::xmlBlaster::util::queue::I_Queue.

Definition at line 111 of file CacheQueuePlugin.cpp.

References accessMutex_, org::xmlBlaster::util::queue::I_Queue::peekWithSamePriority(), and transientQueueP_.

long org::xmlBlaster::util::queue::CacheQueuePlugin::randomRemove ( std::vector< EntryType >::const_iterator &  start,
std::vector< EntryType >::const_iterator &  end 
) [virtual]

Deletes the entries specified in the std::vector in the argument list.

If this std::vector is empty or if the queue is empty, zero (0) is returned, otherwise it returns the number of entries really deleted.

Implements org::xmlBlaster::util::queue::I_Queue.

long org::xmlBlaster::util::queue::CacheQueuePlugin::getNumOfEntries (  )  [virtual]

Access the current number of entries.

Returns:
The number of entries in the queue

Implements org::xmlBlaster::util::queue::I_Queue.

Definition at line 152 of file CacheQueuePlugin.cpp.

References org::xmlBlaster::util::queue::I_Queue::getNumOfEntries(), and transientQueueP_.

long org::xmlBlaster::util::queue::CacheQueuePlugin::getMaxNumOfEntries (  )  [virtual]

Access the configured maximum number of elements for this queue.

Returns:
The maximum number of elements in the queue

Implements org::xmlBlaster::util::queue::I_Queue.

Definition at line 157 of file CacheQueuePlugin.cpp.

References org::xmlBlaster::util::queue::I_Queue::getMaxNumOfEntries(), and transientQueueP_.

int64_t org::xmlBlaster::util::queue::CacheQueuePlugin::getNumOfBytes (  )  [virtual]

Returns the amount of bytes currently in the queue.

If the implementation of this interface is not able to return the correct number of entries (for example if the implementation must make a remote call to a DB which is temporarly not available) it will return -1.

Returns:
The amount of bytes currently in the queue, returns -1 on error

Implements org::xmlBlaster::util::queue::I_Queue.

Definition at line 162 of file CacheQueuePlugin.cpp.

References org::xmlBlaster::util::queue::I_Queue::getNumOfBytes(), and transientQueueP_.

int64_t org::xmlBlaster::util::queue::CacheQueuePlugin::getMaxNumOfBytes (  )  [virtual]

Access the configured capacity (maximum bytes) for this queue.

Returns:
The maximum capacity for the queue in bytes

Implements org::xmlBlaster::util::queue::I_Queue.

Definition at line 167 of file CacheQueuePlugin.cpp.

References org::xmlBlaster::util::queue::I_Queue::getMaxNumOfBytes(), and transientQueueP_.

void org::xmlBlaster::util::queue::CacheQueuePlugin::clear (  )  [virtual]

Clears (removes all entries) this queue.

Implements org::xmlBlaster::util::queue::I_Queue.

Definition at line 172 of file CacheQueuePlugin.cpp.

References accessMutex_, org::xmlBlaster::util::queue::I_Queue::clear(), org::xmlBlaster::util::XmlBlasterException::getMessage(), log_, ME, persistentQueueP_, transientQueueP_, and org::xmlBlaster::util::I_Log::warn().

bool org::xmlBlaster::util::queue::CacheQueuePlugin::empty (  )  [virtual]

returns true if the queue is empty, false otherwise

Implements org::xmlBlaster::util::queue::I_Queue.

Definition at line 186 of file CacheQueuePlugin.cpp.

References org::xmlBlaster::util::queue::I_Queue::empty(), and transientQueueP_.

string org::xmlBlaster::util::queue::CacheQueuePlugin::usage (  )  [static]

Definition at line 204 of file CacheQueuePlugin.cpp.

References org::xmlBlaster::util::qos::storage::ClientQueueProperty::usage(), and org::xmlBlaster::util::queue::SQLiteQueuePlugin::usage().

std::string org::xmlBlaster::util::queue::CacheQueuePlugin::getType (  )  [virtual]

Get the name of the plugin.

Returns:
"CACHE" I_Plugin

Implements org::xmlBlaster::util::plugin::I_Plugin.

Definition at line 136 of file CacheQueuePlugin.h.

Referenced by CacheQueuePlugin().

std::string org::xmlBlaster::util::queue::CacheQueuePlugin::getVersion (  )  [virtual]

Get the version of the plugin.

Returns:
"1.0" I_Plugin

Implements org::xmlBlaster::util::plugin::I_Plugin.

Definition at line 143 of file CacheQueuePlugin.h.

Referenced by CacheQueuePlugin().

void org::xmlBlaster::util::queue::CacheQueuePlugin::destroy (  )  [virtual]

Removes all entries and cleans up the storage, for example with a database it would remove all tables and relating database files.

This is an administrative task. The class instance calling destroy() is invalid after this call

Exceptions:
XmlBlasterException if failed

Implements org::xmlBlaster::util::queue::I_Queue.

Definition at line 191 of file CacheQueuePlugin.cpp.

References org::xmlBlaster::util::queue::I_Queue::destroy(), org::xmlBlaster::util::XmlBlasterException::getMessage(), log_, ME, persistentQueueP_, transientQueueP_, and org::xmlBlaster::util::I_Log::warn().


Member Data Documentation

std::string org::xmlBlaster::util::queue::CacheQueuePlugin::ME [protected]

Definition at line 56 of file CacheQueuePlugin.h.

Referenced by CacheQueuePlugin(), clear(), destroy(), put(), and ~CacheQueuePlugin().

org::xmlBlaster::util::Global& org::xmlBlaster::util::queue::CacheQueuePlugin::global_ [protected]

Definition at line 57 of file CacheQueuePlugin.h.

Referenced by CacheQueuePlugin().

org::xmlBlaster::util::I_Log& org::xmlBlaster::util::queue::CacheQueuePlugin::log_ [protected]

Definition at line 58 of file CacheQueuePlugin.h.

Referenced by CacheQueuePlugin(), clear(), destroy(), put(), and ~CacheQueuePlugin().


Property Documentation

org::xmlBlaster::util::qos::storage::ClientQueueProperty org::xmlBlaster::util::queue::CacheQueuePlugin::_ [protected]

Definition at line 59 of file CacheQueuePlugin.h.

I_Queue* org::xmlBlaster::util::queue::CacheQueuePlugin::transientQueueP_ [mutable, protected]

Definition at line 60 of file CacheQueuePlugin.h.

Referenced by CacheQueuePlugin(), clear(), destroy(), empty(), getMaxNumOfBytes(), getMaxNumOfEntries(), getNumOfBytes(), getNumOfEntries(), peekWithSamePriority(), put(), and ~CacheQueuePlugin().

I_Queue* org::xmlBlaster::util::queue::CacheQueuePlugin::persistentQueueP_ [protected]

Definition at line 61 of file CacheQueuePlugin.h.

Referenced by CacheQueuePlugin(), clear(), destroy(), put(), and ~CacheQueuePlugin().

org::xmlBlaster::util::thread::Mutex org::xmlBlaster::util::queue::CacheQueuePlugin::accessMutex_ [protected]

Definition at line 62 of file CacheQueuePlugin.h.

Referenced by clear(), peekWithSamePriority(), and put().


The documentation for this class was generated from the following files: