util/queue/CacheQueuePlugin.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 Name:      CacheQueuePlugin.h
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 ------------------------------------------------------------------------------*/
00006 #ifndef _UTIL_QUEUE_CACHEQUEUE_H
00007 #define _UTIL_QUEUE_CACHEQUEUE_H
00008 
00009 #include <util/xmlBlasterDef.h>
00010 #include <util/ReferenceHolder.h>
00011 #include <util/queue/I_Queue.h>
00012 #include <util/queue/MsgQueueEntry.h>
00013 #include <util/thread/ThreadImpl.h>
00014 #include <util/I_Log.h>
00015 #include <set>
00016 
00017 namespace org { namespace xmlBlaster { namespace util { namespace queue {
00018 
00019 typedef std::set<EntryType, std::greater<EntryType> > StorageType;
00020 
00041 class Dll_Export CacheQueuePlugin : public I_Queue
00042 {
00043 private:
00044    CacheQueuePlugin(const CacheQueuePlugin& queue);
00045    CacheQueuePlugin& operator =(const CacheQueuePlugin& queue);
00046 
00053    long reloadFromPersistentStore() const;
00054 
00055 protected:
00056    std::string ME;
00057    org::xmlBlaster::util::Global& global_;
00058    org::xmlBlaster::util::I_Log& log_;
00059    org::xmlBlaster::util::qos::storage::ClientQueueProperty property_;
00060    mutable I_Queue *transientQueueP_;
00061    I_Queue *persistentQueueP_;
00062    org::xmlBlaster::util::thread::Mutex accessMutex_;
00063 
00064 public:
00065    CacheQueuePlugin(org::xmlBlaster::util::Global& global, const org::xmlBlaster::util::qos::storage::ClientQueueProperty& property);
00066 
00067    virtual ~CacheQueuePlugin();
00068     
00076    void put(const MsgQueueEntry &entry);
00077 
00084    const std::vector<EntryType> peekWithSamePriority(long maxNumOfEntries=-1, long maxNumOfBytes=-1) const;
00085 
00090    long randomRemove(const std::vector<EntryType>::const_iterator &start, const std::vector<EntryType>::const_iterator &end);
00091 
00096    long getNumOfEntries() const;
00097 
00102    long getMaxNumOfEntries() const;
00103 
00111    int64_t getNumOfBytes() const;
00112 
00117    int64_t getMaxNumOfBytes() const;
00118 
00122    void clear();
00123 
00127     bool empty() const;
00128 
00129     static std::string usage();
00130 
00136    std::string getType() { static std::string type = "CACHE"; return type; }
00137 
00143    std::string getVersion() { static std::string version = "1.0"; return version; }
00144 
00145    void destroy();
00146 };
00147 
00148 }}}} // namespace
00149 
00150 #endif
00151