(file) Return to StatisticalData.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 karl  1.21 //%2006////////////////////////////////////////////////////////////////////////
  2 sage  1.1  //
  3 karl  1.13 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.7  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.13 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.15 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.21 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 sage  1.1  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15            // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18            // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20 kumpf 1.3  // 
 21 sage  1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34 kumpf 1.25 #ifndef Pegasus_StatisticalData_h
 35            #define Pegasus_StatisticalData_h
 36 sage  1.1  
 37            #include <Pegasus/Common/Config.h>
 38 w.white 1.11 #include <iostream>
 39 sage    1.1  #include <cstring>
 40 mike    1.24 #include <Pegasus/Common/Linkage.h>
 41 kumpf   1.6  #include <Pegasus/Common/InternalException.h>
 42 sage    1.1  #include <Pegasus/Common/String.h>
 43              #include <Pegasus/Common/CIMProperty.h>
 44              #include <Pegasus/Common/CIMInstance.h>
 45 w.white 1.8  #include <Pegasus/Common/CIMDateTime.h>
 46 kumpf   1.25 #include <Pegasus/Common/CIMMessage.h>
 47 mike    1.24 #include <Pegasus/Common/Mutex.h>
 48              #include <Pegasus/Common/Time.h>
 49 sage    1.1  
 50              PEGASUS_NAMESPACE_BEGIN
 51              
 52 karl    1.14 #ifndef PEGASUS_DISABLE_PERFINST
 53 sage    1.1  
 54              #define STAT_GETSTARTTIME \
 55 kumpf   1.29 Uint64 serverStartTimeMicroseconds = \
 56                  TimeValue::getCurrentTime().toMicroseconds();
 57 w.white 1.8  
 58              #define STAT_SERVERSTART \
 59 kumpf   1.29 request->setServerStartTime(serverStartTimeMicroseconds);
 60 w.white 1.8  
 61 sage    1.1  #define STAT_SERVEREND \
 62 w.white 1.8  response->endServer();\
 63 w.white 1.12 
 64              #define STAT_BYTESSENT \
 65 kumpf   1.30 Uint16 statType = (response->getType() >= CIM_GET_CLASS_RESPONSE_MESSAGE) ? \
 66                  response->getType() - CIM_GET_CLASS_RESPONSE_MESSAGE : \
 67                  response->getType() - 1; \
 68              StatisticalData::current()->addToValue( \
 69                  message.size(), statType, StatisticalData::PEGASUS_STATDATA_BYTES_SENT);
 70 w.white 1.10 
 71              
 72 w.white 1.8  #define STAT_SERVEREND_ERROR \
 73              response->endServer();
 74              
 75 kumpf   1.30 /*
 76                  The request size value must be stored (requSize) and passed to the
 77                  StatisticalData object at the end of processing other wise it will be
 78                  the ONLY vlaue that is passed to the client which reports the current
 79                  state of the object, not the pevious (one command ago) state
 80              */
 81 w.white 1.8  
 82 sage    1.1  #define STAT_BYTESREAD \
 83 kumpf   1.30 Uint16 statType = (request->getType() >= CIM_GET_CLASS_RESPONSE_MESSAGE) ? \
 84                  request->getType() - CIM_GET_CLASS_RESPONSE_MESSAGE : \
 85                  request->getType() - 1; \
 86              StatisticalData::current()->requSize = contentLength;
 87 w.white 1.10 
 88 sage    1.1  #else
 89              #define STAT_GETSTARTTIME
 90              #define STAT_SERVERSTART
 91              #define STAT_SERVEREND
 92              #define STAT_SERVEREND_ERROR
 93              #define STAT_BYTESREAD
 94 w.white 1.12 #define STAT_BYTESSENT
 95 sage    1.1  #endif
 96              
 97 kumpf   1.25 class PEGASUS_COMMON_LINKAGE StatProviderTimeMeasurement
 98              {
 99              public:
100                  StatProviderTimeMeasurement(CIMMessage* message)
101                      : _message(message)
102                  {
103              #ifndef PEGASUS_DISABLE_PERFINST
104 kumpf   1.29         _startTimeMicroseconds = TimeValue::getCurrentTime().toMicroseconds();
105 kumpf   1.25 #endif
106                  }
107              
108                  ~StatProviderTimeMeasurement()
109                  {
110              #ifndef PEGASUS_DISABLE_PERFINST
111 kumpf   1.29         _message->setProviderTime(
112                          TimeValue::getCurrentTime().toMicroseconds() -
113                              _startTimeMicroseconds);
114 kumpf   1.25 #endif
115                  }
116              
117              private:
118                  StatProviderTimeMeasurement();
119                  StatProviderTimeMeasurement(const StatProviderTimeMeasurement&);
120                  StatProviderTimeMeasurement& operator=(const StatProviderTimeMeasurement&);
121              
122                  CIMMessage* _message;
123 kumpf   1.29     Uint64 _startTimeMicroseconds;
124 kumpf   1.25 };
125              
126 sage    1.1  class PEGASUS_COMMON_LINKAGE StatisticalData
127              {
128 kumpf   1.30 public:
129                  enum StatRequestType
130                  {
131                      GET_CLASS,
132                      GET_INSTANCE,
133                      INDICATION_DELIVERY,
134                      DELETE_CLASS,
135                      DELETE_INSTANCE,
136                      CREATE_CLASS,
137                      CREATE_INSTANCE,
138                      MODIFY_CLASS,
139                      MODIFY_INSTANCE,
140                      ENUMERATE_CLASSES,
141                      ENUMERATE_CLASS_NAMES,
142                      ENUMERATE_INSTANCES,
143                      ENUMERATE_INSTANCE_NAMES,
144                      EXEC_QUERY,
145                      ASSOCIATORS,
146                      ASSOCIATOR_NAMES,
147                      REFERENCES,
148                      REFERENCE_NAMES,
149 kumpf   1.30         GET_PROPERTY,
150                      SET_PROPERTY,
151                      GET_QUALIFIER,
152                      SET_QUALIFIER,
153                      DELETE_QUALIFIER,
154                      ENUMERATE_QUALIFIERS,
155                      INVOKE_METHOD,
156                      NUMBER_OF_TYPES
157                  };
158              
159                  enum StatDataType
160                  {
161                      PEGASUS_STATDATA_SERVER,
162                      PEGASUS_STATDATA_PROVIDER,
163                      PEGASUS_STATDATA_BYTES_SENT,
164                      PEGASUS_STATDATA_BYTES_READ
165                  };
166              
167                  static const Uint32 length;
168                  static StatisticalData* current();
169              
170 kumpf   1.30     StatisticalData();
171              
172                  timeval timestamp;
173              
174                  Sint64 numCalls[NUMBER_OF_TYPES];
175                  Sint64 cimomTime[NUMBER_OF_TYPES];
176                  Sint64 providerTime[NUMBER_OF_TYPES];
177                  Sint64 responseSize[NUMBER_OF_TYPES];
178                  Sint64 requestSize[NUMBER_OF_TYPES];
179                  Sint64 requSize;    //tempory storage for requestSize vlaue
180                  Boolean copyGSD;
181                  static StatisticalData* cur;
182                  void addToValue(Sint64 value, Uint16 type, Uint32 t);
183                  static String requestName[];
184                  void setCopyGSD(Boolean flag);
185 sage    1.1  
186 kumpf   1.30 protected:
187                  Mutex _mutex;
188 sage    1.1  };
189              
190              
191              PEGASUS_NAMESPACE_END
192              #endif
193              

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2