00001
00002 #ifndef _MANAGEMENT_SESSION_
00003 #define _MANAGEMENT_SESSION_
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 Session : 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 uint16_t channelId;
00046 uint64_t connectionRef;
00047 uint32_t detachedLifespan;
00048
00049
00050 uint8_t attached;
00051 uint64_t expireTime;
00052
00053
00054
00055 struct PerThreadStats {
00056 uint32_t framesOutstanding;
00057
00058 };
00059
00060 struct PerThreadStats** perThreadStatsArray;
00061
00062 inline struct PerThreadStats* getThreadStats() {
00063 int index = getThreadIndex();
00064 struct PerThreadStats* threadStats = perThreadStatsArray[index];
00065 if (threadStats == 0) {
00066 threadStats = new(PerThreadStats);
00067 perThreadStatsArray[index] = threadStats;
00068 threadStats->framesOutstanding = 0;
00069
00070 }
00071 return threadStats;
00072 }
00073
00074 void aggregatePerThreadStats(struct PerThreadStats*);
00075
00076
00077 static void writeSchema (qpid::framing::Buffer& buf);
00078 void writeProperties (qpid::framing::Buffer& buf);
00079 void writeStatistics (qpid::framing::Buffer& buf,
00080 bool skipHeaders = false);
00081 void doMethod (std::string methodName,
00082 qpid::framing::Buffer& inBuf,
00083 qpid::framing::Buffer& outBuf);
00084 writeSchemaCall_t getWriteSchemaCall(void) { return writeSchema; }
00085
00086 public:
00087
00088 friend class PackageQpid;
00089
00090 Session (ManagementAgent* agent,
00091 Manageable* coreObject, Manageable* _parent, std::string _name);
00092 ~Session (void);
00093
00094
00095
00096 std::string& getPackageName (void) { return packageName; }
00097 std::string& getClassName (void) { return className; }
00098 uint8_t* getMd5Sum (void) { return md5Sum; }
00099
00100
00101 static const uint32_t METHOD_SOLICITACK = 1;
00102 static const uint32_t METHOD_DETACH = 2;
00103 static const uint32_t METHOD_RESETLIFESPAN = 3;
00104 static const uint32_t METHOD_CLOSE = 4;
00105
00106
00107 inline void set_channelId (uint16_t val){
00108 sys::Mutex::ScopedLock mutex(accessLock);
00109 channelId = val;
00110 configChanged = true;
00111 }
00112 inline void set_connectionRef (uint64_t val){
00113 sys::Mutex::ScopedLock mutex(accessLock);
00114 connectionRef = val;
00115 configChanged = true;
00116 }
00117 inline void set_detachedLifespan (uint32_t val){
00118 sys::Mutex::ScopedLock mutex(accessLock);
00119 detachedLifespan = val;
00120 configChanged = true;
00121 }
00122 inline void set_attached (uint8_t val){
00123 sys::Mutex::ScopedLock mutex(accessLock);
00124 attached = val;
00125 instChanged = true;
00126 }
00127 inline void set_expireTime (uint64_t val){
00128 sys::Mutex::ScopedLock mutex(accessLock);
00129 expireTime = val;
00130 instChanged = true;
00131 }
00132 inline void inc_framesOutstanding (uint32_t by = 1){
00133 getThreadStats()->framesOutstanding += by;
00134 instChanged = true;
00135 }
00136 inline void dec_framesOutstanding (uint32_t by = 1){
00137 getThreadStats()->framesOutstanding -= by;
00138 instChanged = true;
00139 }
00140
00141 };
00142
00143 }}
00144
00145 #endif