util/qos/storage/QueuePropertyBase.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 Name:      QueuePropertyBase.h
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 Comment:   Holding callback queue properties
00006 Version:   $Id: QueuePropertyBase.h 13445 2005-07-15 01:54:35Z ruff $
00007 ------------------------------------------------------------------------------*/
00008 
00016 #ifndef _UTIL_QUEUE_QUEUEPROPERTYBASE_H
00017 #define _UTIL_QUEUE_QUEUEPROPERTYBASE_H
00018 
00019 #include <util/xmlBlasterDef.h>
00020 #include <util/Constants.h>
00021 #include <util/qos/address/AddressBase.h>
00022 
00023 #include <string>
00024 #include <vector>
00025 
00026 namespace org { namespace xmlBlaster { namespace util { namespace qos { namespace storage {
00027 
00028 extern Dll_Export  const long DEFAULT_maxEntriesDefault;
00029 extern Dll_Export  const long DEFAULT_maxEntriesCacheDefault;
00030 extern Dll_Export  const long DEFAULT_bytesDefault;
00031 extern Dll_Export  const long DEFAULT_bytesCacheDefault;
00033 extern Dll_Export  const double DEFAULT_storeSwapLevelRatio;
00035 extern Dll_Export  const double DEFAULT_storeSwapBytesRatio;
00037 extern Dll_Export  const double DEFAULT_reloadSwapLevelRatio;
00039 extern Dll_Export  const double DEFAULT_reloadSwapBytesRatio;
00040 extern Dll_Export  const Timestamp DEFAULT_minExpires;
00041 extern Dll_Export  const Timestamp DEFAULT_maxExpires;
00042 extern Dll_Export  const std::string DEFAULT_onOverflow;
00043 extern Dll_Export  const std::string DEFAULT_onFailure;
00044 
00045 // static variables
00046 extern Dll_Export  std::string DEFAULT_type;
00047 extern Dll_Export  std::string DEFAULT_version;
00049 extern Dll_Export  long DEFAULT_expires;
00050 
00051 typedef std::vector<org::xmlBlaster::util::qos::address::AddressBaseRef> AddressVector;
00052 
00053 class Dll_Export QueuePropertyBase
00054 {
00055    friend class QueuePropertyFactory;
00056 protected:
00057    std::string  ME; //  = "QueuePropertyBase";
00058    org::xmlBlaster::util::Global& global_;
00059    org::xmlBlaster::util::I_Log&    log_;
00060 
00062    std::string type_;
00063 
00065    std::string version_;
00066 
00068    long maxEntriesDefault_;
00069 
00071    long maxEntriesCacheDefault_;
00072 
00074    long maxBytesDefault_;
00075 
00077    long maxBytesCacheDefault_;
00078 
00080    Timestamp minExpires_;
00081 
00083    Timestamp maxExpires_;
00084 
00085 
00087    std::string relating_; //  = Constants.RELATING_CALLBACK;
00089    Timestamp expires_; // = DEFAULT_expires;
00091    long maxEntries_;
00093    long maxBytes_;
00095    long maxEntriesCache_;
00096 
00098    long storeSwapLevel_;
00099 
00101    long storeSwapBytes_;
00102 
00104    long reloadSwapLevel_;
00105 
00107    long reloadSwapBytes_;
00108 
00110    long maxBytesCache_;
00111 
00113    std::string onOverflow_;
00114 
00116    std::string onFailure_;
00117 
00119    AddressVector addressArr_; // = new org::xmlBlaster::util::qos::address::AddressBase[0];
00120 
00122    std::string nodeId_; // = null;
00123 
00125    std::string propertyPrefix_;
00126 
00127    std::string rootTagName_;
00128 
00129    void copy(const QueuePropertyBase& prop)
00130    {
00131       type_                 = prop.type_;
00132       version_              = prop.version_;
00133       maxEntriesDefault_    = prop.maxEntriesDefault_;
00134       maxEntriesCacheDefault_= prop.maxEntriesCacheDefault_;
00135       maxBytesDefault_      = prop.maxBytesDefault_;
00136       maxBytesCacheDefault_ = prop.maxBytesCacheDefault_;
00137       minExpires_           = prop.maxExpires_;
00138       relating_             = prop.relating_;
00139       expires_              = prop.expires_;
00140       maxEntries_           = prop.maxEntries_;
00141       maxBytes_             = prop.maxBytes_;
00142       maxEntriesCache_      = prop.maxEntriesCache_;
00143       storeSwapLevel_       = prop.storeSwapLevel_;
00144       storeSwapBytes_       = prop.storeSwapBytes_;
00145       reloadSwapLevel_      = prop.reloadSwapLevel_;
00146       reloadSwapBytes_      = prop.reloadSwapBytes_;
00147       maxBytesCache_        = prop.maxBytesCache_;
00148       onOverflow_           = prop.onOverflow_;
00149       onFailure_            = prop.onFailure_;
00150       addressArr_           = prop.addressArr_;
00151       nodeId_               = prop.nodeId_;
00152       propertyPrefix_       = prop.propertyPrefix_;
00153       rootTagName_          = prop.rootTagName_;
00154    }
00155 
00159    /*inline*/ void initialize(const std::string& propertyPrefix);
00160 
00161    void setMaxExpires(Timestamp maxExpires)
00162    {
00163       maxExpires_ = maxExpires;
00164    }
00165 
00166    Timestamp getMaxExpires() const
00167    {
00168       return maxExpires_;
00169    }
00170 
00171    void setMinExpires(Timestamp minExpires)
00172    {
00173       minExpires_ = minExpires;
00174    }
00175 
00176    Timestamp getMinExpires()
00177    {
00178       return minExpires_;
00179    }
00180 
00181 public:
00182 
00187    QueuePropertyBase(org::xmlBlaster::util::Global& global, const std::string& nodeId);
00188 
00189    QueuePropertyBase(const QueuePropertyBase& prop);
00190 
00191    QueuePropertyBase& operator =(const QueuePropertyBase& prop);
00192 
00193    virtual ~QueuePropertyBase();
00194 
00198    void setRelating(const std::string& relating);
00199 
00204    std::string getRelating() const;
00205 
00210    Timestamp getExpires() const;
00211 
00216    void setExpires(Timestamp expires);
00217 
00223    long getMaxEntries() const;
00224 
00230    void setMaxEntries(long maxEntries);
00231 
00237    std::string getType() const;
00238 
00244    void setType(const std::string& type);
00245 
00251    std::string getVersion() const;
00252 
00258    void setVersion(const std::string& version);
00259 
00265    long getMaxEntriesCache() const;
00266 
00272    void setMaxEntriesCache(long maxEntriesCache);
00273 
00279    long getMaxBytes() const;
00280 
00286    void setMaxBytes(long maxBytes);
00287 
00293    long getMaxBytesCache() const;
00294 
00300    long getStoreSwapLevel() const;
00301 
00307    void setStoreSwapLevel(long storeSwapLevel);
00308 
00314    long getStoreSwapBytes() const;
00315 
00321    void setStoreSwapBytes(long storeSwapBytes);
00322 
00328    long getReloadSwapLevel() const;
00329 
00335    void setReloadSwapLevel(long reloadSwapLevel);
00336 
00342    long getReloadSwapBytes() const;
00343 
00349    void setReloadSwapBytes(long reloadSwapBytes);
00350 
00356    void setMaxBytesCache(long maxBytesCache);
00357 
00363    void setOnOverflow(const std::string& onOverflow);
00364 
00369    std::string getOnOverflow() const;
00370 
00371    /*
00372     * The default mode, when queue is full the publisher blocks until
00373     * there is space again.
00374    public final boolean onOverflowBlock() {
00375       if (Constants.ONOVERFLOW_BLOCK.equalsIgnoreCase(getOnOverflow()))
00376          return true;
00377       return false;
00378    }
00379     */
00380 
00386    void setOnFailure(const std::string& onFailure);
00387 
00392    std::string getOnFailure() const;
00393 
00397    bool onFailureDeadMessage();
00398 
00403    AddressVector getAddresses() const;
00404 
00411    std::string toXml(const std::string& extraOffset="") const;
00412 
00416    org::xmlBlaster::util::Global& getGlobal();
00417 
00418 //   void cleanupAddresses();
00419 
00421    std::string getPropertyPrefix() const;
00422    void setpropertyPrefix(const std::string& prefix);
00423 
00428    std::string getPrefix();
00429 
00435    std::string getPropName(const std::string& token);
00436 
00437    std::string getRootTagName() const;
00438 
00439 };
00440 
00441 }}}}} // namespaces
00442 
00443 #endif