00001
00002 #ifndef _MANAGEMENT_QUEUE_
00003 #define _MANAGEMENT_QUEUE_
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 Queue : 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 uint8_t durable;
00046 uint8_t autoDelete;
00047 uint8_t exclusive;
00048 framing::FieldTable arguments;
00049
00050
00051 uint32_t consumerCount;
00052 uint32_t consumerCountHigh;
00053 uint32_t consumerCountLow;
00054 uint32_t bindingCount;
00055 uint32_t bindingCountHigh;
00056 uint32_t bindingCountLow;
00057 uint32_t unackedMessages;
00058 uint32_t unackedMessagesHigh;
00059 uint32_t unackedMessagesLow;
00060
00061
00062
00063 struct PerThreadStats {
00064 uint64_t msgTotalEnqueues;
00065 uint64_t msgTotalDequeues;
00066 uint64_t msgTxnEnqueues;
00067 uint64_t msgTxnDequeues;
00068 uint64_t msgPersistEnqueues;
00069 uint64_t msgPersistDequeues;
00070 uint32_t msgDepth;
00071 uint32_t byteDepth;
00072 uint64_t byteTotalEnqueues;
00073 uint64_t byteTotalDequeues;
00074 uint64_t byteTxnEnqueues;
00075 uint64_t byteTxnDequeues;
00076 uint64_t bytePersistEnqueues;
00077 uint64_t bytePersistDequeues;
00078 uint64_t enqueueTxnStarts;
00079 uint64_t enqueueTxnCommits;
00080 uint64_t enqueueTxnRejects;
00081 uint32_t enqueueTxnCount;
00082 uint64_t dequeueTxnStarts;
00083 uint64_t dequeueTxnCommits;
00084 uint64_t dequeueTxnRejects;
00085 uint32_t dequeueTxnCount;
00086 uint64_t messageLatencyCount;
00087 uint64_t messageLatencyTotal;
00088 uint64_t messageLatencyMin;
00089 uint64_t messageLatencyMax;
00090
00091 };
00092
00093 struct PerThreadStats** perThreadStatsArray;
00094
00095 inline struct PerThreadStats* getThreadStats() {
00096 int index = getThreadIndex();
00097 struct PerThreadStats* threadStats = perThreadStatsArray[index];
00098 if (threadStats == 0) {
00099 threadStats = new(PerThreadStats);
00100 perThreadStatsArray[index] = threadStats;
00101 threadStats->msgTotalEnqueues = 0;
00102 threadStats->msgTotalDequeues = 0;
00103 threadStats->msgTxnEnqueues = 0;
00104 threadStats->msgTxnDequeues = 0;
00105 threadStats->msgPersistEnqueues = 0;
00106 threadStats->msgPersistDequeues = 0;
00107 threadStats->msgDepth = 0;
00108 threadStats->byteDepth = 0;
00109 threadStats->byteTotalEnqueues = 0;
00110 threadStats->byteTotalDequeues = 0;
00111 threadStats->byteTxnEnqueues = 0;
00112 threadStats->byteTxnDequeues = 0;
00113 threadStats->bytePersistEnqueues = 0;
00114 threadStats->bytePersistDequeues = 0;
00115 threadStats->enqueueTxnStarts = 0;
00116 threadStats->enqueueTxnCommits = 0;
00117 threadStats->enqueueTxnRejects = 0;
00118 threadStats->enqueueTxnCount = 0;
00119 threadStats->dequeueTxnStarts = 0;
00120 threadStats->dequeueTxnCommits = 0;
00121 threadStats->dequeueTxnRejects = 0;
00122 threadStats->dequeueTxnCount = 0;
00123 threadStats->messageLatencyCount = 0;
00124 threadStats->messageLatencyMin = std::numeric_limits<uint64_t>::max();
00125 threadStats->messageLatencyMax = std::numeric_limits<uint64_t>::min();
00126 threadStats->messageLatencyTotal = 0;
00127
00128 }
00129 return threadStats;
00130 }
00131
00132 void aggregatePerThreadStats(struct PerThreadStats*);
00133
00134
00135 static void writeSchema (qpid::framing::Buffer& buf);
00136 void writeProperties (qpid::framing::Buffer& buf);
00137 void writeStatistics (qpid::framing::Buffer& buf,
00138 bool skipHeaders = false);
00139 void doMethod (std::string methodName,
00140 qpid::framing::Buffer& inBuf,
00141 qpid::framing::Buffer& outBuf);
00142 writeSchemaCall_t getWriteSchemaCall(void) { return writeSchema; }
00143
00144 public:
00145
00146 friend class PackageQpid;
00147
00148 Queue (ManagementAgent* agent,
00149 Manageable* coreObject, Manageable* _parent, std::string _name, uint8_t _durable, uint8_t _autoDelete, uint8_t _exclusive);
00150 ~Queue (void);
00151
00152
00153
00154 std::string& getPackageName (void) { return packageName; }
00155 std::string& getClassName (void) { return className; }
00156 uint8_t* getMd5Sum (void) { return md5Sum; }
00157
00158
00159 static const uint32_t METHOD_PURGE = 1;
00160
00161
00162 inline void set_arguments (framing::FieldTable val){
00163 sys::Mutex::ScopedLock mutex(accessLock);
00164 arguments = val;
00165 configChanged = true;
00166 }
00167 inline void inc_msgTotalEnqueues (uint64_t by = 1){
00168 getThreadStats()->msgTotalEnqueues += by;
00169 instChanged = true;
00170 }
00171 inline void dec_msgTotalEnqueues (uint64_t by = 1){
00172 getThreadStats()->msgTotalEnqueues -= by;
00173 instChanged = true;
00174 }
00175 inline void inc_msgTotalDequeues (uint64_t by = 1){
00176 getThreadStats()->msgTotalDequeues += by;
00177 instChanged = true;
00178 }
00179 inline void dec_msgTotalDequeues (uint64_t by = 1){
00180 getThreadStats()->msgTotalDequeues -= by;
00181 instChanged = true;
00182 }
00183 inline void inc_msgTxnEnqueues (uint64_t by = 1){
00184 getThreadStats()->msgTxnEnqueues += by;
00185 instChanged = true;
00186 }
00187 inline void dec_msgTxnEnqueues (uint64_t by = 1){
00188 getThreadStats()->msgTxnEnqueues -= by;
00189 instChanged = true;
00190 }
00191 inline void inc_msgTxnDequeues (uint64_t by = 1){
00192 getThreadStats()->msgTxnDequeues += by;
00193 instChanged = true;
00194 }
00195 inline void dec_msgTxnDequeues (uint64_t by = 1){
00196 getThreadStats()->msgTxnDequeues -= by;
00197 instChanged = true;
00198 }
00199 inline void inc_msgPersistEnqueues (uint64_t by = 1){
00200 getThreadStats()->msgPersistEnqueues += by;
00201 instChanged = true;
00202 }
00203 inline void dec_msgPersistEnqueues (uint64_t by = 1){
00204 getThreadStats()->msgPersistEnqueues -= by;
00205 instChanged = true;
00206 }
00207 inline void inc_msgPersistDequeues (uint64_t by = 1){
00208 getThreadStats()->msgPersistDequeues += by;
00209 instChanged = true;
00210 }
00211 inline void dec_msgPersistDequeues (uint64_t by = 1){
00212 getThreadStats()->msgPersistDequeues -= by;
00213 instChanged = true;
00214 }
00215 inline void inc_byteTotalEnqueues (uint64_t by = 1){
00216 getThreadStats()->byteTotalEnqueues += by;
00217 instChanged = true;
00218 }
00219 inline void dec_byteTotalEnqueues (uint64_t by = 1){
00220 getThreadStats()->byteTotalEnqueues -= by;
00221 instChanged = true;
00222 }
00223 inline void inc_byteTotalDequeues (uint64_t by = 1){
00224 getThreadStats()->byteTotalDequeues += by;
00225 instChanged = true;
00226 }
00227 inline void dec_byteTotalDequeues (uint64_t by = 1){
00228 getThreadStats()->byteTotalDequeues -= by;
00229 instChanged = true;
00230 }
00231 inline void inc_byteTxnEnqueues (uint64_t by = 1){
00232 getThreadStats()->byteTxnEnqueues += by;
00233 instChanged = true;
00234 }
00235 inline void dec_byteTxnEnqueues (uint64_t by = 1){
00236 getThreadStats()->byteTxnEnqueues -= by;
00237 instChanged = true;
00238 }
00239 inline void inc_byteTxnDequeues (uint64_t by = 1){
00240 getThreadStats()->byteTxnDequeues += by;
00241 instChanged = true;
00242 }
00243 inline void dec_byteTxnDequeues (uint64_t by = 1){
00244 getThreadStats()->byteTxnDequeues -= by;
00245 instChanged = true;
00246 }
00247 inline void inc_bytePersistEnqueues (uint64_t by = 1){
00248 getThreadStats()->bytePersistEnqueues += by;
00249 instChanged = true;
00250 }
00251 inline void dec_bytePersistEnqueues (uint64_t by = 1){
00252 getThreadStats()->bytePersistEnqueues -= by;
00253 instChanged = true;
00254 }
00255 inline void inc_bytePersistDequeues (uint64_t by = 1){
00256 getThreadStats()->bytePersistDequeues += by;
00257 instChanged = true;
00258 }
00259 inline void dec_bytePersistDequeues (uint64_t by = 1){
00260 getThreadStats()->bytePersistDequeues -= by;
00261 instChanged = true;
00262 }
00263 inline void inc_enqueueTxnStarts (uint64_t by = 1){
00264 getThreadStats()->enqueueTxnStarts += by;
00265 instChanged = true;
00266 }
00267 inline void dec_enqueueTxnStarts (uint64_t by = 1){
00268 getThreadStats()->enqueueTxnStarts -= by;
00269 instChanged = true;
00270 }
00271 inline void inc_enqueueTxnCommits (uint64_t by = 1){
00272 getThreadStats()->enqueueTxnCommits += by;
00273 instChanged = true;
00274 }
00275 inline void dec_enqueueTxnCommits (uint64_t by = 1){
00276 getThreadStats()->enqueueTxnCommits -= by;
00277 instChanged = true;
00278 }
00279 inline void inc_enqueueTxnRejects (uint64_t by = 1){
00280 getThreadStats()->enqueueTxnRejects += by;
00281 instChanged = true;
00282 }
00283 inline void dec_enqueueTxnRejects (uint64_t by = 1){
00284 getThreadStats()->enqueueTxnRejects -= by;
00285 instChanged = true;
00286 }
00287 inline void inc_enqueueTxnCount (uint32_t by = 1){
00288 getThreadStats()->enqueueTxnCount += by;
00289 instChanged = true;
00290 }
00291 inline void dec_enqueueTxnCount (uint32_t by = 1){
00292 getThreadStats()->enqueueTxnCount -= by;
00293 instChanged = true;
00294 }
00295 inline void inc_dequeueTxnStarts (uint64_t by = 1){
00296 getThreadStats()->dequeueTxnStarts += by;
00297 instChanged = true;
00298 }
00299 inline void dec_dequeueTxnStarts (uint64_t by = 1){
00300 getThreadStats()->dequeueTxnStarts -= by;
00301 instChanged = true;
00302 }
00303 inline void inc_dequeueTxnCommits (uint64_t by = 1){
00304 getThreadStats()->dequeueTxnCommits += by;
00305 instChanged = true;
00306 }
00307 inline void dec_dequeueTxnCommits (uint64_t by = 1){
00308 getThreadStats()->dequeueTxnCommits -= by;
00309 instChanged = true;
00310 }
00311 inline void inc_dequeueTxnRejects (uint64_t by = 1){
00312 getThreadStats()->dequeueTxnRejects += by;
00313 instChanged = true;
00314 }
00315 inline void dec_dequeueTxnRejects (uint64_t by = 1){
00316 getThreadStats()->dequeueTxnRejects -= by;
00317 instChanged = true;
00318 }
00319 inline void inc_dequeueTxnCount (uint32_t by = 1){
00320 getThreadStats()->dequeueTxnCount += by;
00321 instChanged = true;
00322 }
00323 inline void dec_dequeueTxnCount (uint32_t by = 1){
00324 getThreadStats()->dequeueTxnCount -= by;
00325 instChanged = true;
00326 }
00327 inline void inc_consumerCount (uint32_t by = 1){
00328 sys::Mutex::ScopedLock mutex(accessLock);
00329 consumerCount += by;
00330 if (consumerCountHigh < consumerCount)
00331 consumerCountHigh = consumerCount;
00332 instChanged = true;
00333 }
00334 inline void dec_consumerCount (uint32_t by = 1){
00335 sys::Mutex::ScopedLock mutex(accessLock);
00336 consumerCount -= by;
00337 if (consumerCountLow > consumerCount)
00338 consumerCountLow = consumerCount;
00339 instChanged = true;
00340 }
00341 inline void inc_bindingCount (uint32_t by = 1){
00342 sys::Mutex::ScopedLock mutex(accessLock);
00343 bindingCount += by;
00344 if (bindingCountHigh < bindingCount)
00345 bindingCountHigh = bindingCount;
00346 instChanged = true;
00347 }
00348 inline void dec_bindingCount (uint32_t by = 1){
00349 sys::Mutex::ScopedLock mutex(accessLock);
00350 bindingCount -= by;
00351 if (bindingCountLow > bindingCount)
00352 bindingCountLow = bindingCount;
00353 instChanged = true;
00354 }
00355 inline void inc_unackedMessages (uint32_t by = 1){
00356 sys::Mutex::ScopedLock mutex(accessLock);
00357 unackedMessages += by;
00358 if (unackedMessagesHigh < unackedMessages)
00359 unackedMessagesHigh = unackedMessages;
00360 instChanged = true;
00361 }
00362 inline void dec_unackedMessages (uint32_t by = 1){
00363 sys::Mutex::ScopedLock mutex(accessLock);
00364 unackedMessages -= by;
00365 if (unackedMessagesLow > unackedMessages)
00366 unackedMessagesLow = unackedMessages;
00367 instChanged = true;
00368 }
00369 inline void set_messageLatency (uint64_t val){
00370 getThreadStats()->messageLatencyCount++;
00371 getThreadStats()->messageLatencyTotal += val;
00372 if (getThreadStats()->messageLatencyMin > val)
00373 getThreadStats()->messageLatencyMin = val;
00374 if (getThreadStats()->messageLatencyMax < val)
00375 getThreadStats()->messageLatencyMax = val;
00376 instChanged = true;
00377 }
00378
00379 };
00380
00381 }}
00382
00383 #endif