00001
00002 #ifndef _MANAGEMENT_CONNECTION_
00003 #define _MANAGEMENT_CONNECTION_
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 Connection : 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 address;
00045 uint8_t incoming;
00046
00047
00048 uint8_t closing;
00049 std::string authIdentity;
00050
00051
00052
00053 struct PerThreadStats {
00054 uint64_t framesFromClient;
00055 uint64_t framesToClient;
00056 uint64_t bytesFromClient;
00057 uint64_t bytesToClient;
00058
00059 };
00060
00061 struct PerThreadStats** perThreadStatsArray;
00062
00063 inline struct PerThreadStats* getThreadStats() {
00064 int index = getThreadIndex();
00065 struct PerThreadStats* threadStats = perThreadStatsArray[index];
00066 if (threadStats == 0) {
00067 threadStats = new(PerThreadStats);
00068 perThreadStatsArray[index] = threadStats;
00069 threadStats->framesFromClient = 0;
00070 threadStats->framesToClient = 0;
00071 threadStats->bytesFromClient = 0;
00072 threadStats->bytesToClient = 0;
00073
00074 }
00075 return threadStats;
00076 }
00077
00078 void aggregatePerThreadStats(struct PerThreadStats*);
00079
00080
00081 static void writeSchema (qpid::framing::Buffer& buf);
00082 void writeProperties (qpid::framing::Buffer& buf);
00083 void writeStatistics (qpid::framing::Buffer& buf,
00084 bool skipHeaders = false);
00085 void doMethod (std::string methodName,
00086 qpid::framing::Buffer& inBuf,
00087 qpid::framing::Buffer& outBuf);
00088 writeSchemaCall_t getWriteSchemaCall(void) { return writeSchema; }
00089
00090 public:
00091
00092 friend class PackageQpid;
00093
00094 Connection (ManagementAgent* agent,
00095 Manageable* coreObject, Manageable* _parent, std::string _address, uint8_t _incoming);
00096 ~Connection (void);
00097
00098
00099
00100 std::string& getPackageName (void) { return packageName; }
00101 std::string& getClassName (void) { return className; }
00102 uint8_t* getMd5Sum (void) { return md5Sum; }
00103
00104
00105 static const uint32_t METHOD_CLOSE = 1;
00106
00107
00108 inline void set_closing (uint8_t val){
00109 sys::Mutex::ScopedLock mutex(accessLock);
00110 closing = val;
00111 instChanged = true;
00112 }
00113 inline void set_authIdentity (std::string val){
00114 sys::Mutex::ScopedLock mutex(accessLock);
00115 authIdentity = val;
00116 instChanged = true;
00117 }
00118 inline void inc_framesFromClient (uint64_t by = 1){
00119 getThreadStats()->framesFromClient += by;
00120 instChanged = true;
00121 }
00122 inline void dec_framesFromClient (uint64_t by = 1){
00123 getThreadStats()->framesFromClient -= by;
00124 instChanged = true;
00125 }
00126 inline void inc_framesToClient (uint64_t by = 1){
00127 getThreadStats()->framesToClient += by;
00128 instChanged = true;
00129 }
00130 inline void dec_framesToClient (uint64_t by = 1){
00131 getThreadStats()->framesToClient -= by;
00132 instChanged = true;
00133 }
00134 inline void inc_bytesFromClient (uint64_t by = 1){
00135 getThreadStats()->bytesFromClient += by;
00136 instChanged = true;
00137 }
00138 inline void dec_bytesFromClient (uint64_t by = 1){
00139 getThreadStats()->bytesFromClient -= by;
00140 instChanged = true;
00141 }
00142 inline void inc_bytesToClient (uint64_t by = 1){
00143 getThreadStats()->bytesToClient += by;
00144 instChanged = true;
00145 }
00146 inline void dec_bytesToClient (uint64_t by = 1){
00147 getThreadStats()->bytesToClient -= by;
00148 instChanged = true;
00149 }
00150
00151 };
00152
00153 }}
00154
00155 #endif