(file) Return to CIMOMStatDataProvider.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ControlProviders / Statistic

  1 martin 1.25 //%LICENSE////////////////////////////////////////////////////////////////
  2             // 
  3             // 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             // 
 10             // 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             // 
 17             // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19             // 
 20             // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21             // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 22 martin 1.25 // 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             // 
 28             //////////////////////////////////////////////////////////////////////////
 29 w.white 1.1  //
 30              //%/////////////////////////////////////////////////////////////////////////////
 31              
 32              #include "CIMOMStatDataProvider.h"
 33 kumpf   1.15 #include <Pegasus/Common/PegasusVersion.h>
 34 karl    1.6  
 35              PEGASUS_USING_STD;
 36 w.white 1.1  PEGASUS_NAMESPACE_BEGIN
 37              
 38 w.white 1.5  CIMOMStatDataProvider::CIMOMStatDataProvider()
 39 w.white 1.1  {
 40 dave.sudlik 1.23     for (Uint32 i=0; i<StatisticalData::length; i++)
 41                      {
 42                          char buffer[32];
 43 kumpf       1.24         sprintf(buffer, "%u", i);
 44 dave.sudlik 1.23         _references[i] = CIMObjectPath(
 45                              "CIM_CIMOMStatisticalData.InstanceID=\"CIM_CIMOMStatisticalData"+
 46                              String(buffer)+"\"");
 47                      }
 48 w.white     1.7  
 49 w.white     1.1  }
 50                  
 51 w.white     1.5  CIMOMStatDataProvider::~CIMOMStatDataProvider()
 52 w.white     1.1  {
 53                  }
 54                  
 55                  void CIMOMStatDataProvider::getInstance(
 56 dave.sudlik 1.23     const OperationContext & context,
 57                      const CIMObjectPath & instanceReference,
 58                      const Boolean includeQualifiers,
 59                      const Boolean includeClassOrigin,
 60                      const CIMPropertyList & propertyList,
 61                      InstanceResponseHandler & handler)
 62                  {
 63                      CIMObjectPath localReference = CIMObjectPath(
 64                          String::EMPTY,
 65                          CIMNamespaceName(),
 66                          instanceReference.getClassName(),
 67                          instanceReference.getKeyBindings());
 68                  
 69                      // begin processing the request
 70                      handler.processing();
 71 w.white     1.1  
 72 dave.sudlik 1.23     // instance index corresponds to reference index
 73                      for (Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
 74                      {
 75                          if (localReference == _references[i])
 76                          {
 77                              // deliver requested instance
 78                              handler.deliver(getInstance(i, instanceReference));
 79                              break;
 80                          }
 81                      }
 82                  
 83                      // complete processing the request
 84                      handler.complete();
 85 w.white     1.1  }
 86                  
 87                  void CIMOMStatDataProvider::enumerateInstances(
 88 dave.sudlik 1.23     const OperationContext & context,
 89                      const CIMObjectPath & classReference,
 90                      const Boolean includeQualifiers,
 91                      const Boolean includeClassOrigin,
 92                      const CIMPropertyList & propertyList,
 93                      InstanceResponseHandler & handler)
 94 w.white     1.1  {
 95                      // begin processing the request
 96 dave.sudlik 1.23     handler.processing();
 97                  
 98                      // instance index corresponds to reference index
 99                      for (Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
100                      {
101                          // deliver instance
102                          handler.deliver(getInstance(i, classReference));
103                  
104                      }
105 w.white     1.1  
106 dave.sudlik 1.23     // complete processing the request
107                      handler.complete();
108 w.white     1.1  }
109                  
110                  void CIMOMStatDataProvider::enumerateInstanceNames(
111 dave.sudlik 1.23     const OperationContext & context,
112                      const CIMObjectPath & classReference,
113                      ObjectPathResponseHandler & handler)
114                  {
115                      // begin processing the request
116                      handler.processing();
117                  
118                      for (Uint32 i = 0; i < StatisticalData::NUMBER_OF_TYPES; i++)
119                      {
120                          // deliver reference
121                          handler.deliver(_references[i]);
122                      }
123 w.white     1.1  
124 dave.sudlik 1.23     // complete processing the request
125                      handler.complete();
126 w.white     1.1  }
127                  
128                  void CIMOMStatDataProvider::modifyInstance(
129 dave.sudlik 1.23     const OperationContext & context,
130                      const CIMObjectPath & instanceReference,
131                      const CIMInstance & instanceObject,
132                      const Boolean includeQualifiers,
133                      const CIMPropertyList & propertyList,
134                      ResponseHandler & handler)
135 w.white     1.1  {
136 dave.sudlik 1.23     throw CIMNotSupportedException("StatisticalData::modifyInstance");
137 w.white     1.1  }
138                  
139                  void CIMOMStatDataProvider::createInstance(
140 dave.sudlik 1.23     const OperationContext & context,
141                      const CIMObjectPath & instanceReference,
142                      const CIMInstance & instanceObject,
143                      ObjectPathResponseHandler & handler)
144 w.white     1.1  {
145 dave.sudlik 1.23     throw CIMNotSupportedException("StatisticalData::createInstance");
146 w.white     1.1  }
147                  
148                  void CIMOMStatDataProvider::deleteInstance(
149 dave.sudlik 1.23     const OperationContext & context,
150                      const CIMObjectPath & instanceReference,
151                      ResponseHandler & handler)
152 w.white     1.1  {
153 dave.sudlik 1.23     throw CIMNotSupportedException("StatisticalData::deleteInstance");
154 w.white     1.1  }
155                  
156 dave.sudlik 1.23 CIMInstance CIMOMStatDataProvider::getInstance(
157                      Uint16 type, 
158                      CIMObjectPath cimRef)
159 w.white     1.1  {
160                  
161 dave.sudlik 1.23     StatisticalData* sd = StatisticalData::current();
162                      char buffer[32];
163 kumpf       1.24     sprintf(buffer, "%hu", type);
164 w.white     1.1  
165 dave.sudlik 1.23     checkObjectManager();
166 w.white     1.3  
167 dave.sudlik 1.23     CIMDateTime cimom_time = CIMDateTime((sd->cimomTime[type]), true);
168                      CIMDateTime provider_time = CIMDateTime((sd->providerTime[type]), true);
169                      Uint16 mof_type = getOpType(type);
170 w.white     1.1  
171 w.white     1.17 
172 w.white     1.1  
173 dave.sudlik 1.23     CIMInstance requestedInstance("CIM_CIMOMStatisticalData");
174                      requestedInstance.addProperty(CIMProperty("InstanceID",
175                          CIMValue("CIM_CIMOMStatisticalData"+String(buffer))));
176                      requestedInstance.addProperty(CIMProperty("OperationType",
177                          CIMValue(mof_type)));
178                      requestedInstance.addProperty(CIMProperty("NumberOfOperations",
179                          CIMValue((Uint64)sd->numCalls[type])));
180                      requestedInstance.addProperty(CIMProperty("CimomElapsedTime",
181                          CIMValue(cimom_time)));
182                      requestedInstance.addProperty(CIMProperty("ProviderElapsedTime",
183                          CIMValue(provider_time)));
184                      requestedInstance.addProperty(CIMProperty("RequestSize",
185                          CIMValue((Uint64)sd->requestSize[type])));
186                      requestedInstance.addProperty(CIMProperty("ResponseSize",
187                          CIMValue((Uint64)sd->responseSize[type])));
188                      requestedInstance.addProperty( CIMProperty("Description",
189                          CIMValue(String("CIMOM performance statistics for CIM request "))));
190                      requestedInstance.addProperty(CIMProperty("Caption",
191                          CIMValue(String("CIMOM performance statistics for CIM request"))));
192 a.arora     1.8  
193 dave.sudlik 1.23     requestedInstance.setPath(_references[type]);
194 w.white     1.1  
195 dave.sudlik 1.23     return requestedInstance;
196 w.white     1.1  }
197                  
198 w.white     1.14 /*CIMDateTime CIMOMStatDataProvider::toDateTime(Sint64 date)
199 dave.sudlik 1.23 { 
200                      // Break millisecond value into days, hours, minutes, seconds and 
201                      // milliseconds.
202                      // Turn each number into a string and append them to each other.
203 w.white     1.3  
204 dave.sudlik 1.23     const Sint64 oneDay = Sint64(864) * 100000000;
205 w.white     1.4  
206                          Sint64 ndays = date/oneDay;        //one day = 8.64*10^10 millisecond
207 dave.sudlik 1.23         Sint64 rem = date % oneDay;      //rem_1 is remander of above operation
208 karl        1.11         char buf_day[9];
209 w.white     1.10         sprintf(buf_day,"%08d",(int)ndays);
210 w.white     1.3  
211                  String test = String(buf_day);
212                  
213 dave.sudlik 1.23         //one hour = 3.6*10^9 milliseconds
214                          Sint64 nhour = rem/PEGASUS_UINT64_LITERAL(3600000000);  
215                          //rem_2 is remander of above operation
216                          Sint64 rem_2 = rem%PEGASUS_UINT64_LITERAL(3600000000);    
217 karl        1.11         char buf_hour[3];
218 w.white     1.10         sprintf(buf_hour,"%02d",(int)nhour);
219 w.white     1.3  
220                  String hour = String(buf_hour);
221                  String dh = test.append(String(buf_hour));
222                  //printf("this is test now after append\n");// %s\n", test.getCString());
223                  
224 w.white     1.4          Sint64 nmin = rem_2/60000000;  // one minute = 6*10^7
225 w.white     1.3          Sint64 rem_3 = rem_2%60000000;
226 karl        1.11         char buf_minute[3];
227 w.white     1.10         sprintf(buf_minute,"%02d",(int)nmin);
228 w.white     1.3  
229                  String dhm = dh.append(String(buf_minute));
230                  //printf("after second append this is test %s\n", test.getCString());
231                  
232 w.white     1.4          Sint64 nsecond = rem_3/1000000; //one second = 10^6 milliseconds
233 karl        1.11         char buf_second[3];
234 w.white     1.10         sprintf(buf_second,"%02d",(int)nsecond);
235 w.white     1.3  
236                  String dhms = dhm.append(String(buf_second));
237                  //printf("after third append this is test\n");// %s \n",test.getCString());
238                  
239                  
240                          Sint64 nmilsec = rem_3%1000000;
241 karl        1.11         char buf_milsec[20];
242 w.white     1.10         sprintf(buf_milsec,".%06d:000",(int)nmilsec);
243 w.white     1.3  
244                  String dhmsm = dhms.append(String(buf_milsec));
245 karl        1.13     //cout << "String for datetime= " << dhmsm << endl;
246                      CIMDateTime ans;
247                      try
248                      {
249                          ans.set(dhmsm);
250                      }
251                      catch(Exception& e)
252                      {
253 dave.sudlik 1.23         cout << "Error in string convert of " << dhmsm << " " << 
254                              e.getMessage() << endl;;
255 karl        1.13         ans.clear();
256                      }
257 w.white     1.4  //cout<<"this is being passed back for toDateTime" << ans.toString() << endl;
258 w.white     1.3  
259                          return ans;
260                  
261 w.white     1.14 } */
262 w.white     1.3  
263 karl        1.13 
264 w.white     1.3  void CIMOMStatDataProvider::checkObjectManager()
265                  {
266 dave.sudlik 1.23     StatisticalData* sData = StatisticalData::current();
267 ms.aruran   1.22 
268 dave.sudlik 1.23     if (!sData->copyGSD)
269                      {  
270                         //set all values to 0 if CIM_ObjectManager is False
271                  
272                          for (Uint16 i=0; i<StatisticalData::length; i++)
273                          {
274                              sData->numCalls[i] = 0;
275                              sData->cimomTime[i] = 0;
276                              sData->providerTime[i] = 0;
277                              sData->responseSize[i] = 0;
278                              sData->requestSize[i] = 0;
279                          }
280                      }
281 w.white     1.3  }
282                  
283                  
284 ms.aruran   1.22 // This conversion makes make the OperationType attribute of the
285 jim.wunderlich 1.20 // CIM_CIMOMStatisticalData instances agree with DMTF spec.
286 ms.aruran      1.22 // The CIM_StatisticalData class specifys type 0 as "unknown"
287 jim.wunderlich 1.20 // and 1 as "other"
288                     //
289 ms.aruran      1.22 // The internal message types are subject to change so the symblic
290                     // enumerated values are used within a select statement rather than
291                     // a one dimensional array that is simply indexed to determine the
292                     // output type.
293 w.white        1.1  
294 w.white        1.3  Uint16 CIMOMStatDataProvider::getOpType(Uint16 type)
295                     {
296 jim.wunderlich 1.20     Uint16 outType;
297 w.white        1.3  
298 jim.wunderlich 1.20     switch (type)
299                         {
300 dave.sudlik    1.23         case StatisticalData::GET_CLASS:
301                                 outType= 3 ;
302                                 break;
303                     
304                             case StatisticalData::GET_INSTANCE:
305                                 outType= 4;
306                                 break;
307                     
308                             case StatisticalData::INDICATION_DELIVERY:
309                                 outType= 26;
310                                 break;
311                     
312                             case StatisticalData::DELETE_CLASS:
313                                 outType= 5;
314                                 break;
315                     
316                             case StatisticalData::DELETE_INSTANCE:
317                                 outType= 6;
318                                 break;
319                     
320                             case StatisticalData::CREATE_CLASS:
321 dave.sudlik    1.23             outType= 7;
322                                 break;
323                     
324                             case StatisticalData::CREATE_INSTANCE:
325                                 outType= 8;
326                                 break;
327                     
328                             case StatisticalData::MODIFY_CLASS:
329                                 outType= 9;
330                                 break;
331                     
332                             case StatisticalData::MODIFY_INSTANCE:
333                                 outType= 10;
334                                 break;
335                     
336                             case StatisticalData::ENUMERATE_CLASSES:
337                                 outType= 11;
338                                 break;
339                     
340                             case StatisticalData::ENUMERATE_CLASS_NAMES:
341                                 outType= 12;
342 dave.sudlik    1.23             break;
343                     
344                             case StatisticalData::ENUMERATE_INSTANCES:
345                                 outType= 13;
346                                 break;
347                     
348                             case StatisticalData::ENUMERATE_INSTANCE_NAMES:
349                                 outType= 14;
350                                 break;
351                     
352                             case StatisticalData::EXEC_QUERY:
353                                 outType= 15;
354                                 break;
355                     
356                             case StatisticalData::ASSOCIATORS:
357                                 outType= 16;
358                                 break;
359                     
360                             case StatisticalData::ASSOCIATOR_NAMES:
361                                 outType= 17;
362                                 break;
363 dave.sudlik    1.23 
364                             case StatisticalData::REFERENCES:
365                                 outType= 18;
366                                 break;
367                     
368                             case StatisticalData::REFERENCE_NAMES:
369                                 outType= 19;
370                                 break;
371                     
372                             case StatisticalData::GET_PROPERTY:
373                                 outType= 20;
374                                 break;
375                     
376                             case StatisticalData::SET_PROPERTY:
377                                 outType= 21;
378                                 break;
379                     
380                             case StatisticalData::GET_QUALIFIER:
381                                 outType= 22;
382                                 break;
383                     
384 dave.sudlik    1.23         case StatisticalData::SET_QUALIFIER:
385                                 outType= 23;
386                                 break;
387                     
388                             case StatisticalData::DELETE_QUALIFIER:
389                                 outType= 24;
390                                 break;
391                     
392                             case StatisticalData::ENUMERATE_QUALIFIERS:
393                                 outType= 25;
394                                 break;
395                     
396                             case StatisticalData::INVOKE_METHOD:
397                                 outType= 1;
398                                 break;
399 jim.wunderlich 1.20 
400                             default:
401 dave.sudlik    1.23             // This type is unknown so output "Unknown"
402                                 outType=0;
403                                 break;
404 jim.wunderlich 1.20     }
405 w.white        1.1  
406 jim.wunderlich 1.20     return outType;
407 w.white        1.1  }
408                     
409                     PEGASUS_NAMESPACE_END
410 dave.sudlik    1.23     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2