(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.23                                     // Pegasus        CIM_StatisticalData
 49 jim.wunderlich  1.14                                     // message type
 50                                                          // -------------- -------------------
 51 karl            1.23 //"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.23   "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.23   "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                        "GetProperty",                    //    20          20
 73                        "SetProperty",                    //    21          21
 74                        "GetQualifier",                   //    22          22
 75                        "SetQualifier",                   //    23          23
 76                        "DeleteQualifier",                //    24          24
 77                        "EnumerateQualifiers",            //    25          25
 78                      // Entries below this point are not part of the CIM Class and are treated
 79                      // as OtherOperationTypes in the CIM_CIMOMStatisticalData instance.
 80                        "InvokeMethod"                    //    26          Not Present index = 26
 81                      
 82 denise.eckstein 1.11 };
 83 sage            1.1  
 84                      const Uint32 StatisticalData::length = NUMBER_OF_TYPES;
 85                      
 86 karl            1.23 // Pointer to StatisticalData table if it exists.
 87                      StatisticalData* StatisticalData::table = NULL;
 88 sage            1.1  
 89 karl            1.23 // If first call, create the statistical data array
 90 denise.eckstein 1.11 StatisticalData* StatisticalData::current()
 91                      {
 92 karl            1.23     if (table == NULL)
 93 denise.eckstein 1.11     {
 94 karl            1.23         table = new StatisticalData();
 95 denise.eckstein 1.11     }
 96 karl            1.23     return table;
 97 sage            1.1  }
 98                      
 99 karl            1.23 // Constructor clears the statisticalData Array and sets the gatherint
100                      // flag to zero
101 denise.eckstein 1.11 StatisticalData::StatisticalData()
102                      {
103                          copyGSD = 0;
104 karl            1.23     clear();
105                      }
106 w.white         1.4  
107 karl            1.23 void StatisticalData::clear()
108                      {
109                          AutoMutex autoMut(_mutex);
110 denise.eckstein 1.11     for (unsigned int i=0; i<StatisticalData::length; i++)
111                          {
112                              numCalls[i] = 0;
113 kumpf           1.18         cimomTime[i] = 0;
114 denise.eckstein 1.11         providerTime[i] = 0;
115                              responseSize[i] = 0;
116                              requestSize[i] = 0;
117                          }
118 sage            1.1  }
119                      
120 karl            1.23 
121                      String StatisticalData::getRequestName(Uint16 i)
122                      {
123                          return requestName[i];
124                      }
125                      
126                      void StatisticalData::addToValue(Sint64 value,
127                          MessageType msgType,
128                          StatDataType t)
129 denise.eckstein 1.11 {
130 karl            1.23     // Map MessageType to statistic type. Requires multiple tests because
131                          // mapping request and responses to the request types.
132                          Uint16 type;
133                      
134                          // if is response type, substract starting point of responses.
135                          if (msgType >= CIM_GET_CLASS_RESPONSE_MESSAGE)
136                          {
137                              type = msgType - CIM_GET_CLASS_RESPONSE_MESSAGE;
138                          }
139                          else
140                          {
141                              type = msgType - 1;
142                          }
143                      
144                          // Test if valid statistic type
145 denise.eckstein 1.11     if (type >= NUMBER_OF_TYPES)
146                          {
147 marek           1.19          PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
148 denise.eckstein 1.11              "StatData: Statistical Data Discarded.  "
149 marek           1.19                  "Invalid Request Type =  %u", type));
150 denise.eckstein 1.11          return;
151                          }
152                      
153                          if (copyGSD)
154                          {
155                              AutoMutex autoMut(_mutex);
156                              switch (t)
157                              {
158 denise.eckstein 1.12             case PEGASUS_STATDATA_SERVER:
159 denise.eckstein 1.11                 numCalls[type] += 1;
160                                      cimomTime[type] += value;
161 marek           1.20                 PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
162 denise.eckstein 1.11                     "StatData: SERVER: %s(%d): count = %"
163                                              PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
164                                              PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
165                                              PEGASUS_64BIT_CONVERSION_WIDTH "d",
166                                          (const char *)requestName[type].getCString(), type,
167 marek           1.19                     numCalls[type], value, cimomTime[type]));
168 denise.eckstein 1.11                 break;
169 denise.eckstein 1.12             case PEGASUS_STATDATA_PROVIDER:
170 denise.eckstein 1.11                 providerTime[type] += value;
171 marek           1.20                 PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
172 denise.eckstein 1.11                     "StatData: PROVIDER: %s(%d): count = %"
173                                              PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
174                                              PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
175                                              PEGASUS_64BIT_CONVERSION_WIDTH "d",
176                                          (const char *)requestName[type].getCString(), type,
177 marek           1.19                     numCalls[type], value, providerTime[type]));
178 denise.eckstein 1.11                 break;
179 denise.eckstein 1.12         case PEGASUS_STATDATA_BYTES_SENT:
180 denise.eckstein 1.11                 responseSize[type] += value;
181 marek           1.20                 PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
182 denise.eckstein 1.11                     "StatData: BYTES_SENT: %s(%d): count = %"
183                                              PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
184                                              PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
185                                              PEGASUS_64BIT_CONVERSION_WIDTH "d",
186                                          (const char *)requestName[type].getCString(), type,
187 marek           1.19                     numCalls[type], value, responseSize[type]));
188 denise.eckstein 1.11                 break;
189 denise.eckstein 1.12         case PEGASUS_STATDATA_BYTES_READ:
190 denise.eckstein 1.11                 requestSize[type] += value;
191 marek           1.20                 PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
192 denise.eckstein 1.11                     "StatData: BYTES_READ: %s(%d): count = %"
193                                              PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
194                                              PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
195                                              PEGASUS_64BIT_CONVERSION_WIDTH "d",
196                                          (const char *)requestName[type].getCString(), type,
197 marek           1.19                     numCalls[type], value, requestSize[type]));
198 denise.eckstein 1.11                 break;
199                              }
200                          }
201 sage            1.1  }
202                      
203 mike            1.17 void StatisticalData::setCopyGSD(Boolean flag)
204 w.white         1.6  {
205 kumpf           1.18     copyGSD = flag;
206 w.white         1.6  }
207 w.white         1.4  
208 sage            1.1  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2