00001
00002 #ifndef _MANAGEMENT_EXCHANGE_
00003 #define _MANAGEMENT_EXCHANGE_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "qpid/management/ManagementObject.h"
00028 #include "qpid/framing/FieldTable.h"
00029 #include "qpid/framing/Uuid.h"
00030
00031 namespace qpid {
00032 namespace management {
00033
00034 class Exchange : public ManagementObject
00035 {
00036 private:
00037
00038 static std::string packageName;
00039 static std::string className;
00040 static uint8_t md5Sum[16];
00041
00042
00043 uint64_t vhostRef;
00044 std::string name;
00045 std::string type;
00046 uint8_t durable;
00047
00048
00049 uint32_t producerCount;
00050 uint32_t producerCountHigh;
00051 uint32_t producerCountLow;
00052 uint32_t bindingCount;
00053 uint32_t bindingCountHigh;
00054 uint32_t bindingCountLow;
00055
00056
00057
00058 struct PerThreadStats {
00059 uint64_t msgReceives;
00060 uint64_t msgDrops;
00061 uint64_t msgRoutes;
00062 uint64_t byteReceives;
00063 uint64_t byteDrops;
00064 uint64_t byteRoutes;
00065
00066 };
00067
00068 struct PerThreadStats** perThreadStatsArray;
00069
00070 inline struct PerThreadStats* getThreadStats() {
00071 int index = getThreadIndex();
00072 struct PerThreadStats* threadStats = perThreadStatsArray[index];
00073 if (threadStats == 0) {
00074 threadStats = new(PerThreadStats);
00075 perThreadStatsArray[index] = threadStats;
00076 threadStats->msgReceives = 0;
00077 threadStats->msgDrops = 0;
00078 threadStats->msgRoutes = 0;
00079 threadStats->byteReceives = 0;
00080 threadStats->byteDrops = 0;
00081 threadStats->byteRoutes = 0;
00082
00083 }
00084 return threadStats;
00085 }
00086
00087 void aggregatePerThreadStats(struct PerThreadStats*);
00088
00089
00090 static void writeSchema (qpid::framing::Buffer& buf);
00091 void writeProperties (qpid::framing::Buffer& buf);
00092 void writeStatistics (qpid::framing::Buffer& buf,
00093 bool skipHeaders = false);
00094 void doMethod (std::string methodName,
00095 qpid::framing::Buffer& inBuf,
00096 qpid::framing::Buffer& outBuf);
00097 writeSchemaCall_t getWriteSchemaCall(void) { return writeSchema; }
00098
00099 public:
00100
00101 friend class PackageQpid;
00102
00103 Exchange (ManagementAgent* agent,
00104 Manageable* coreObject, Manageable* _parent, std::string _name, uint8_t _durable);
00105 ~Exchange (void);
00106
00107
00108
00109 std::string& getPackageName (void) { return packageName; }
00110 std::string& getClassName (void) { return className; }
00111 uint8_t* getMd5Sum (void) { return md5Sum; }
00112
00113
00114
00115
00116 inline void set_type (std::string val){
00117 sys::Mutex::ScopedLock mutex(accessLock);
00118 type = val;
00119 configChanged = true;
00120 }
00121 inline void inc_producerCount (uint32_t by = 1){
00122 sys::Mutex::ScopedLock mutex(accessLock);
00123 producerCount += by;
00124 if (producerCountHigh < producerCount)
00125 producerCountHigh = producerCount;
00126 instChanged = true;
00127 }
00128 inline void dec_producerCount (uint32_t by = 1){
00129 sys::Mutex::ScopedLock mutex(accessLock);
00130 producerCount -= by;
00131 if (producerCountLow > producerCount)
00132 producerCountLow = producerCount;
00133 instChanged = true;
00134 }
00135 inline void inc_bindingCount (uint32_t by = 1){
00136 sys::Mutex::ScopedLock mutex(accessLock);
00137 bindingCount += by;
00138 if (bindingCountHigh < bindingCount)
00139 bindingCountHigh = bindingCount;
00140 instChanged = true;
00141 }
00142 inline void dec_bindingCount (uint32_t by = 1){
00143 sys::Mutex::ScopedLock mutex(accessLock);
00144 bindingCount -= by;
00145 if (bindingCountLow > bindingCount)
00146 bindingCountLow = bindingCount;
00147 instChanged = true;
00148 }
00149 inline void inc_msgReceives (uint64_t by = 1){
00150 getThreadStats()->msgReceives += by;
00151 instChanged = true;
00152 }
00153 inline void dec_msgReceives (uint64_t by = 1){
00154 getThreadStats()->msgReceives -= by;
00155 instChanged = true;
00156 }
00157 inline void inc_msgDrops (uint64_t by = 1){
00158 getThreadStats()->msgDrops += by;
00159 instChanged = true;
00160 }
00161 inline void dec_msgDrops (uint64_t by = 1){
00162 getThreadStats()->msgDrops -= by;
00163 instChanged = true;
00164 }
00165 inline void inc_msgRoutes (uint64_t by = 1){
00166 getThreadStats()->msgRoutes += by;
00167 instChanged = true;
00168 }
00169 inline void dec_msgRoutes (uint64_t by = 1){
00170 getThreadStats()->msgRoutes -= by;
00171 instChanged = true;
00172 }
00173 inline void inc_byteReceives (uint64_t by = 1){
00174 getThreadStats()->byteReceives += by;
00175 instChanged = true;
00176 }
00177 inline void dec_byteReceives (uint64_t by = 1){
00178 getThreadStats()->byteReceives -= by;
00179 instChanged = true;
00180 }
00181 inline void inc_byteDrops (uint64_t by = 1){
00182 getThreadStats()->byteDrops += by;
00183 instChanged = true;
00184 }
00185 inline void dec_byteDrops (uint64_t by = 1){
00186 getThreadStats()->byteDrops -= by;
00187 instChanged = true;
00188 }
00189 inline void inc_byteRoutes (uint64_t by = 1){
00190 getThreadStats()->byteRoutes += by;
00191 instChanged = true;
00192 }
00193 inline void dec_byteRoutes (uint64_t by = 1){
00194 getThreadStats()->byteRoutes -= by;
00195 instChanged = true;
00196 }
00197
00198 };
00199
00200 }}
00201
00202 #endif