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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2