(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                            "ReferenceNames",                 //    19          20
 72 kumpf           1.18       "SetProperty",                    //    20          21
 73                            "GetQualifier",                   //    21          22
 74                            "SetQualifier",                   //    22          23
 75                            "DeleteQualifier",                //    23          24
 76                            "EnumerateQualifiers",            //    24          25
 77 karl            1.22.8.5 // Entries below this point are not part of the CIM Class and are treated
 78                          // as OtherOperationTypes in the instance.
 79                            "InvokeMethod"                    //     25          Not Present index = 26
 80 karl            1.22.8.2 //EXP_PULL_BEGIN
 81 karl            1.22.8.5 //// TODO these are not defined in CIM_StatisticalData class and are
 82                          ///  represented by the Other groping with supplementary property
 83                            "OpenEnumerateInstances",         //    71          27
 84 karl            1.22.8.3   "OpenEnumerateInstancePaths",     //    72
 85 karl            1.22.8.4   "OpenReferences",                 //    73
 86 karl            1.22.8.3   "OpenReferenceNames",             //    74
 87                            "OpenAssociators",                //    75
 88                            "OpenAssociatorPaths",            //    76
 89                            "PullInstancesWithPath",          //    77
 90                            "PullInstancePaths",              //    77
 91                            "CloseEnumeration" ,              //    79
 92 karl            1.22.8.2 //EXP_PULL_END
 93 denise.eckstein 1.11     };
 94 sage            1.1      
 95                          const Uint32 StatisticalData::length = NUMBER_OF_TYPES;
 96                          
 97 karl            1.22.8.6 // Pointer to StatisticalData table if it exists.
 98                          StatisticalData* StatisticalData::table = NULL;
 99 sage            1.1      
100 karl            1.22.8.5 // If first call, create the statistical data array
101 denise.eckstein 1.11     StatisticalData* StatisticalData::current()
102                          {
103 karl            1.22.8.6     if (table == NULL)
104 denise.eckstein 1.11         {
105 karl            1.22.8.6         table = new StatisticalData();
106 denise.eckstein 1.11         }
107 karl            1.22.8.6     return table;
108 sage            1.1      }
109                          
110 karl            1.22.8.6 // Constructor clears the statisticalData Array and sets the gatherint
111                          // flag to zero
112 denise.eckstein 1.11     StatisticalData::StatisticalData()
113                          {
114                              copyGSD = 0;
115 karl            1.22.8.6     clear();
116                          }
117 w.white         1.4      
118 karl            1.22.8.6 void StatisticalData::clear()
119                          {
120                              AutoMutex autoMut(_mutex);
121 denise.eckstein 1.11         for (unsigned int i=0; i<StatisticalData::length; i++)
122                              {
123                                  numCalls[i] = 0;
124 kumpf           1.18             cimomTime[i] = 0;
125 denise.eckstein 1.11             providerTime[i] = 0;
126                                  responseSize[i] = 0;
127                                  requestSize[i] = 0;
128                              }
129 sage            1.1      }
130                          
131 karl            1.22.8.6 String StatisticalData::getRequestName(Uint16 i)
132                          {
133                              return requestName[i];
134                          }
135                          
136 karl            1.22.8.5 void StatisticalData::addToValue(Sint64 value,
137                              MessageType msgType,
138                              StatDataType t)
139 denise.eckstein 1.11     {
140 karl            1.22.8.6     // Map MessageType to statistic type. Requires multiple tests because
141                              // mapping request and responses to the request types.
142 karl            1.22.8.4     Uint16 type;
143                              if ((msgType) >= CIM_OPEN_ENUMERATE_INSTANCES_RESPONSE_MESSAGE)
144                              {
145                                  type = msgType - CIM_SET_QUALIFIER_RESPONSE_MESSAGE;
146                              }
147                              else if (msgType >= CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE)
148                              {
149                                 type = msgType - CIM_OPEN_ENUMERATE_INSTANCES_REQUEST_MESSAGE;
150                              }
151                              else if (msgType >= CIM_GET_CLASS_RESPONSE_MESSAGE)
152                              {
153                                  type = msgType - CIM_GET_CLASS_RESPONSE_MESSAGE;
154                              }
155                              else
156                              {
157 karl            1.22.8.6         type = msgType - 1;
158 karl            1.22.8.4     }
159                          
160 karl            1.22.8.5     //// KS_TODO diagnostic to confirm that the above if statements are correct
161                              //// KS_DELETE when we get bug 9786 completely integrated.
162                              PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
163                               "StatisticalData::addToValue msgType %s %u. stat type %u",
164                                         MessageTypeToString(msgType),
165                                         msgType, type ));
166                          
167 karl            1.22.8.4     // Test if valid statistic type
168 denise.eckstein 1.11         if (type >= NUMBER_OF_TYPES)
169                              {
170 marek           1.19              PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
171 denise.eckstein 1.11                  "StatData: Statistical Data Discarded.  "
172 marek           1.19                      "Invalid Request Type =  %u", type));
173 denise.eckstein 1.11              return;
174                              }
175                          
176                              if (copyGSD)
177                              {
178                                  AutoMutex autoMut(_mutex);
179                                  switch (t)
180                                  {
181 denise.eckstein 1.12                 case PEGASUS_STATDATA_SERVER:
182 denise.eckstein 1.11                     numCalls[type] += 1;
183                                          cimomTime[type] += value;
184 marek           1.20                     PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
185 denise.eckstein 1.11                         "StatData: SERVER: %s(%d): count = %"
186                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
187                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
188                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d",
189                                              (const char *)requestName[type].getCString(), type,
190 marek           1.19                         numCalls[type], value, cimomTime[type]));
191 denise.eckstein 1.11                     break;
192 denise.eckstein 1.12                 case PEGASUS_STATDATA_PROVIDER:
193 denise.eckstein 1.11                     providerTime[type] += value;
194 marek           1.20                     PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
195 denise.eckstein 1.11                         "StatData: PROVIDER: %s(%d): count = %"
196                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
197                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
198                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d",
199                                              (const char *)requestName[type].getCString(), type,
200 marek           1.19                         numCalls[type], value, providerTime[type]));
201 denise.eckstein 1.11                     break;
202 denise.eckstein 1.12             case PEGASUS_STATDATA_BYTES_SENT:
203 denise.eckstein 1.11                     responseSize[type] += value;
204 marek           1.20                     PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
205 denise.eckstein 1.11                         "StatData: BYTES_SENT: %s(%d): count = %"
206                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
207                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
208                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d",
209                                              (const char *)requestName[type].getCString(), type,
210 marek           1.19                         numCalls[type], value, responseSize[type]));
211 denise.eckstein 1.11                     break;
212 denise.eckstein 1.12             case PEGASUS_STATDATA_BYTES_READ:
213 denise.eckstein 1.11                     requestSize[type] += value;
214 marek           1.20                     PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
215 denise.eckstein 1.11                         "StatData: BYTES_READ: %s(%d): count = %"
216                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
217                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
218                                                  PEGASUS_64BIT_CONVERSION_WIDTH "d",
219                                              (const char *)requestName[type].getCString(), type,
220 marek           1.19                         numCalls[type], value, requestSize[type]));
221 denise.eckstein 1.11                     break;
222                                  }
223                              }
224 sage            1.1      }
225                          
226 mike            1.17     void StatisticalData::setCopyGSD(Boolean flag)
227 w.white         1.6      {
228 kumpf           1.18         copyGSD = flag;
229 w.white         1.6      }
230 w.white         1.4      
231 sage            1.1      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2