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

  1 martin 1.21 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.22 //
  3 martin 1.21 // 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.22 //
 10 martin 1.21 // 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.22 //
 17 martin 1.21 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.22 //
 20 martin 1.21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.22 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.21 // 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.22 //
 28 martin 1.21 //////////////////////////////////////////////////////////////////////////
 29 sage   1.1  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #include "StatisticalData.h"
 33 denise.eckstein 1.11 #include "Tracer.h"
 34 sage            1.1  
 35                      PEGASUS_NAMESPACE_BEGIN
 36                      
 37 jim.wunderlich  1.14 
 38                      // The table on the right represents the mapping from the enumerated types
 39 kumpf           1.18 // in the CIM_CIMOMStatisticalDate class ValueMap versus the internal
 40                      // message type defined in Message.h. This conversion is performed by
 41 jim.wunderlich  1.14 // getOpType() in CIMOMStatDataProvider.cpp.
 42                      //
 43                      
 44 kumpf           1.18 String StatisticalData::requestName[] =
 45 denise.eckstein 1.11 {
 46 kumpf           1.18                                     // Enumerated     ValueMap Value
 47 jim.wunderlich  1.14                                     // value from     from class
 48 karl            1.22.8.5                                     // Pegasus        CIM_StatisticalData
 49 jim.wunderlich  1.14                                         // message type
 50                                                              // -------------- -------------------
 51 karl            1.22.8.6 //"Unknown",                        //                 0   default
 52                          //"Other",                          //                 1   mapped
 53                          //"Batched",                        //                 2   not used
 54 kumpf           1.18       "GetClass",                       //     1           3
 55                            "GetInstance",                    //     2           4
 56 karl            1.22.8.5   "IndicationDelivery",             //     3          26
 57 kumpf           1.18       "DeleteClass",                    //     4           5
 58                            "DeleteInstance",                 //     5           6
 59                            "CreateClass",                    //     6           7
 60 jim.wunderlich  1.16       "CreateInstance",                 //     7           8
 61                            "ModifyClass",                    //     8           9
 62 kumpf           1.18       "ModifyInstance",                 //     9          10
 63                            "EnumerateClasses",               //    10          11
 64 karl            1.22.8.5   "EnumerateClassNames",            //    12          12
 65                            "EnumerateInstances",             //    13          13
 66                            "EnumerateInstanceNames",         //    14          14
 67                            "ExecQuery",                      //    15          15
 68                            "Associators",                    //    16          16
 69                            "AssociatorNames",                //    17          17
 70                            "References",                     //    18          18
 71 karl            1.22.8.7   "ReferenceNames",                 //    19          19
 72                            "GetProperty",                    //    20          20
 73                            "SetProperty",                    //    21          21
 74                            "GetQualifier",                   //    22          22
 75                            "SetQualifier",                   //    23          23
 76                            "DeleteQualifier",                //    24          24
 77                            "EnumerateQualifiers",            //    25          25
 78 karl            1.22.8.5 // Entries below this point are not part of the CIM Class and are treated
 79 karl            1.22.8.7 // as OtherOperationTypes in the CIM_CIMOMStatisticalData instance.
 80                            "InvokeMethod",                    //    26          Not Present index = 26
 81 karl            1.22.8.2 //EXP_PULL_BEGIN
 82 karl            1.22.8.8 //// These are not defined in CIM_StatisticalData class and are
 83 karl            1.22.8.5 ///  represented by the Other groping with supplementary property
 84                            "OpenEnumerateInstances",         //    71          27
 85 karl            1.22.8.3   "OpenEnumerateInstancePaths",     //    72
 86 karl            1.22.8.7   "OpenAssociators",                //    73
 87                            "OpenAssociatorPaths",           //     74
 88                            "OpenReferences",                 //    75
 89                            "OpenReferenceNames",             //    76
 90                            "OpenQueryInstances",             //    77
 91                            "PullInstancesWithPath",          //    78
 92                            "PullInstancePaths",              //    79
 93                            "CloseEnumeration" ,              //    80
 94 karl            1.22.8.2 //EXP_PULL_END
 95 denise.eckstein 1.11     };
 96 sage            1.1      
 97                          const Uint32 StatisticalData::length = NUMBER_OF_TYPES;
 98                          
 99 karl            1.22.8.6 // Pointer to StatisticalData table if it exists.
100                          StatisticalData* StatisticalData::table = NULL;
101 sage            1.1      
102 karl            1.22.8.5 // If first call, create the statistical data array
103 denise.eckstein 1.11     StatisticalData* StatisticalData::current()
104                          {
105 karl            1.22.8.6     if (table == NULL)
106 denise.eckstein 1.11         {
107 karl            1.22.8.6         table = new StatisticalData();
108 denise.eckstein 1.11         }
109 karl            1.22.8.6     return table;
110 sage            1.1      }
111                          
112 karl            1.22.8.6 // Constructor clears the statisticalData Array and sets the gatherint
113                          // flag to zero
114 denise.eckstein 1.11     StatisticalData::StatisticalData()
115                          {
116                              copyGSD = 0;
117 karl            1.22.8.6     clear();
118                          }
119 w.white         1.4      
120 karl            1.22.8.6 void StatisticalData::clear()
121                          {
122                              AutoMutex autoMut(_mutex);
123 denise.eckstein 1.11         for (unsigned int i=0; i<StatisticalData::length; i++)
124                              {
125                                  numCalls[i] = 0;
126 kumpf           1.18             cimomTime[i] = 0;
127 denise.eckstein 1.11             providerTime[i] = 0;
128                                  responseSize[i] = 0;
129                                  requestSize[i] = 0;
130                              }
131 sage            1.1      }
132                          
133 karl            1.22.8.6 String StatisticalData::getRequestName(Uint16 i)
134                          {
135                              return requestName[i];
136                          }
137                          
138 karl            1.22.8.5 void StatisticalData::addToValue(Sint64 value,
139                              MessageType msgType,
140                              StatDataType t)
141 denise.eckstein 1.11     {
142 karl            1.22.8.6     // Map MessageType to statistic type. Requires multiple tests because
143                              // mapping request and responses to the request types.
144 karl            1.22.8.4     Uint16 type;
145 karl            1.22.8.7 
146                              if ((msgType) >= CIM_OPEN_ENUMERATE_INSTANCES_REQUEST_MESSAGE)
147 karl            1.22.8.4     {
148 karl            1.22.8.7         type = msgType - CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE;
149 karl            1.22.8.4     }
150                              else if (msgType >= CIM_GET_CLASS_RESPONSE_MESSAGE)
151                              {
152                                  type = msgType - CIM_GET_CLASS_RESPONSE_MESSAGE;
153                              }
154                              else
155                              {
156 karl            1.22.8.6         type = msgType - 1;
157 karl            1.22.8.4     }
158                          
159                              // Test if valid statistic type
160 denise.eckstein 1.11         if (type >= NUMBER_OF_TYPES)
161                              {
162 marek           1.19              PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
163 denise.eckstein 1.11                  "StatData: Statistical Data Discarded.  "
164 marek           1.19                      "Invalid Request Type =  %u", type));
165 denise.eckstein 1.11              return;
166                              }
167 karl            1.22.8.7     //// Diagnostic to confirm message type conversion. Normally commented
168                              //// out
169                          //  PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
170                          //   "StatisticalData::addToValue msgType %s %u. stat type %u %s",
171                          //             MessageTypeToString(msgType),
172                          //             msgType, type, (const char*)requestName[type].getCString() ));
173 denise.eckstein 1.11     
174                              if (copyGSD)
175                              {
176                                  AutoMutex autoMut(_mutex);
177                                  switch (t)
178                                  {
179 denise.eckstein 1.12                 case PEGASUS_STATDATA_SERVER:
180 denise.eckstein 1.11                     numCalls[type] += 1;
181                                          cimomTime[type] += value;
182 marek           1.20                     PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
183 denise.eckstein 1.11                         "StatData: SERVER: %s(%d): count = %"
184                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
185                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
186                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d",
187                                              (const char *)requestName[type].getCString(), type,
188 marek           1.19                         numCalls[type], value, cimomTime[type]));
189 denise.eckstein 1.11                     break;
190 denise.eckstein 1.12                 case PEGASUS_STATDATA_PROVIDER:
191 denise.eckstein 1.11                     providerTime[type] += value;
192 marek           1.20                     PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
193 denise.eckstein 1.11                         "StatData: PROVIDER: %s(%d): count = %"
194                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
195                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
196                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d",
197                                              (const char *)requestName[type].getCString(), type,
198 marek           1.19                         numCalls[type], value, providerTime[type]));
199 denise.eckstein 1.11                     break;
200 denise.eckstein 1.12             case PEGASUS_STATDATA_BYTES_SENT:
201 denise.eckstein 1.11                     responseSize[type] += value;
202 marek           1.20                     PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
203 denise.eckstein 1.11                         "StatData: BYTES_SENT: %s(%d): count = %"
204                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
205                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
206                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d",
207                                              (const char *)requestName[type].getCString(), type,
208 marek           1.19                         numCalls[type], value, responseSize[type]));
209 denise.eckstein 1.11                     break;
210 denise.eckstein 1.12             case PEGASUS_STATDATA_BYTES_READ:
211 denise.eckstein 1.11                     requestSize[type] += value;
212 marek           1.20                     PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
213 denise.eckstein 1.11                         "StatData: BYTES_READ: %s(%d): count = %"
214                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
215                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
216                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d",
217                                              (const char *)requestName[type].getCString(), type,
218 marek           1.19                         numCalls[type], value, requestSize[type]));
219 denise.eckstein 1.11                     break;
220                                  }
221                              }
222 sage            1.1      }
223                          
224 mike            1.17     void StatisticalData::setCopyGSD(Boolean flag)
225 w.white         1.6      {
226 kumpf           1.18         copyGSD = flag;
227 w.white         1.6      }
228 w.white         1.4      
229 sage            1.1      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2