(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 StatisticalData::current()->addToValue( \
 65 karl    1.33.8.4     message.size(), response->getType(), \
 66                      StatisticalData::PEGASUS_STATDATA_BYTES_SENT);
 67 w.white 1.10     
 68 w.white 1.8      #define STAT_SERVEREND_ERROR \
 69                  response->endServer();
 70                  
 71 kumpf   1.30     /*
 72                      The request size value must be stored (requSize) and passed to the
 73                      StatisticalData object at the end of processing other wise it will be
 74                      the ONLY vlaue that is passed to the client which reports the current
 75                      state of the object, not the pevious (one command ago) state
 76                  */
 77 w.white 1.8      
 78 sage    1.1      #define STAT_BYTESREAD \
 79 kumpf   1.30     StatisticalData::current()->requSize = contentLength;
 80 w.white 1.10     
 81 sage    1.1      #else
 82                  #define STAT_GETSTARTTIME
 83                  #define STAT_SERVERSTART
 84                  #define STAT_SERVEREND
 85                  #define STAT_SERVEREND_ERROR
 86                  #define STAT_BYTESREAD
 87 w.white 1.12     #define STAT_BYTESSENT
 88 sage    1.1      #endif
 89                  
 90 kumpf   1.25     class PEGASUS_COMMON_LINKAGE StatProviderTimeMeasurement
 91                  {
 92                  public:
 93                      StatProviderTimeMeasurement(CIMMessage* message)
 94                          : _message(message)
 95                      {
 96                  #ifndef PEGASUS_DISABLE_PERFINST
 97 kumpf   1.29             _startTimeMicroseconds = TimeValue::getCurrentTime().toMicroseconds();
 98 kumpf   1.25     #endif
 99                      }
100                  
101                      ~StatProviderTimeMeasurement()
102                      {
103                  #ifndef PEGASUS_DISABLE_PERFINST
104 kumpf   1.29             _message->setProviderTime(
105                              TimeValue::getCurrentTime().toMicroseconds() -
106                                  _startTimeMicroseconds);
107 kumpf   1.25     #endif
108                      }
109                  
110                  private:
111                      StatProviderTimeMeasurement();
112                      StatProviderTimeMeasurement(const StatProviderTimeMeasurement&);
113                      StatProviderTimeMeasurement& operator=(const StatProviderTimeMeasurement&);
114                  
115                      CIMMessage* _message;
116 kumpf   1.29         Uint64 _startTimeMicroseconds;
117 kumpf   1.25     };
118                  
119 sage    1.1      class PEGASUS_COMMON_LINKAGE StatisticalData
120                  {
121 kumpf   1.30     public:
122 karl    1.33.8.5     // Statistical data type is Request Type - 3;
123 kumpf   1.30         enum StatRequestType
124                      {
125 karl    1.33.8.5 //      UNKNOWN,
126                  //      OTHER,        // Other type not defined
127                  //      BATCHED,      // NOT used by Pegasus
128 karl    1.33.8.4         GET_CLASS,    // 0
129 kumpf   1.30             GET_INSTANCE,
130                          INDICATION_DELIVERY,
131                          DELETE_CLASS,
132                          DELETE_INSTANCE,
133                          CREATE_CLASS,
134                          CREATE_INSTANCE,
135                          MODIFY_CLASS,
136                          MODIFY_INSTANCE,
137                          ENUMERATE_CLASSES,
138 karl    1.33.8.4         ENUMERATE_CLASS_NAMES,  // 10
139 kumpf   1.30             ENUMERATE_INSTANCES,
140                          ENUMERATE_INSTANCE_NAMES,
141                          EXEC_QUERY,
142                          ASSOCIATORS,
143                          ASSOCIATOR_NAMES,
144                          REFERENCES,
145                          REFERENCE_NAMES,
146                          GET_PROPERTY,
147                          SET_PROPERTY,
148 karl    1.33.8.5         GET_QUALIFIER,   // 20
149 kumpf   1.30             SET_QUALIFIER,
150                          DELETE_QUALIFIER,
151 karl    1.33.8.5         ENUMERATE_QUALIFIERS,  // 23
152                  // Types beyond the here are NOT part of the valueMap,Values defined
153                  // in CIM_CIMOMStatisticalData.mof and must be treated as Other in
154                  // the preperation of the instance output.
155                          INVOKE_METHOD,  // 24
156 kumpf   1.30             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                      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 kumpf   1.30         Sint64 responseSize[NUMBER_OF_TYPES];
178                      Sint64 requestSize[NUMBER_OF_TYPES];
179                      Sint64 requSize;    //tempory storage for requestSize vlaue
180                      Boolean copyGSD;
181 karl    1.33.8.4 
182 kumpf   1.30         static StatisticalData* cur;
183 karl    1.33.8.4 
184 karl    1.33.8.5     /** Add the value parameter to the current value for the
185                          messagetype msgType and the StatDataType
186 karl    1.33.8.4 
187 karl    1.33.8.5         @param value Sint64 type to add
188                          @param msgType Pegasus message type (may be either request
189                                         or response
190                          @param t StatDataType stat type to which value is added
191                       */
192                      void addToValue(Sint64 value, MessageType msgType, StatDataType t);
193                  
194                      /**
195                          Get the name for the statistics type
196                       */
197 kumpf   1.30         static String requestName[];
198 karl    1.33.8.4 
199 kumpf   1.30         void setCopyGSD(Boolean flag);
200 sage    1.1      
201 kumpf   1.30     protected:
202                      Mutex _mutex;
203 sage    1.1      };
204                  
205                  
206                  PEGASUS_NAMESPACE_END
207                  #endif
208                  

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2