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 // internal CIM_StatisticalData
49 // message type
50 // -------------- -------------------
|
51 kumpf 1.18 "GetClass", // 1 3
52 "GetInstance", // 2 4
53 "IndicationDelivery", // 3 26
54 "DeleteClass", // 4 5
55 "DeleteInstance", // 5 6
56 "CreateClass", // 6 7
|
57 jim.wunderlich 1.16 "CreateInstance", // 7 8
58 "ModifyClass", // 8 9
|
59 kumpf 1.18 "ModifyInstance", // 9 10
60 "EnumerateClasses", // 10 11
61 "EnumerateClassNames", // 11 12
62 "EnumerateInstances", // 12 13
63 "EnumerateInstanceNames", // 13 14
64 "ExecQuery", // 14 15
65 "Associators", // 15 16
66 "AssociatorNames", // 16 17
67 "References", // 17 18
68 "ReferenceNames", // 18 19
69 "GetProperty", // 19 20
70 "SetProperty", // 20 21
71 "GetQualifier", // 21 22
72 "SetQualifier", // 22 23
73 "DeleteQualifier", // 23 24
74 "EnumerateQualifiers", // 24 25
|
75 karl 1.22.8.2 //EXP_PULL_BEGIN
|
76 karl 1.22.8.3 //// TODO these are not defined in CIM_StatisticalData class
77 "OpenEnumerateInstances", // 71
78 "OpenEnumerateInstancePaths", // 72
|
79 karl 1.22.8.4 "OpenReferences", // 73
|
80 karl 1.22.8.3 "OpenReferenceNames", // 74
81 "OpenAssociators", // 75
82 "OpenAssociatorPaths", // 76
83 "PullInstancesWithPath", // 77
84 "PullInstancePaths", // 77
85 "CloseEnumeration" , // 79
|
86 karl 1.22.8.2 //EXP_PULL_END
|
87 jim.wunderlich 1.16 "InvokeMethod" // 25 Not Present
|
88 denise.eckstein 1.11 };
|
89 sage 1.1
90 const Uint32 StatisticalData::length = NUMBER_OF_TYPES;
91
92 StatisticalData* StatisticalData::cur = NULL;
93
|
94 denise.eckstein 1.11 StatisticalData* StatisticalData::current()
95 {
96 if (cur == NULL)
97 {
98 cur = new StatisticalData();
99 }
100 return cur;
|
101 sage 1.1 }
102
|
103 denise.eckstein 1.11 StatisticalData::StatisticalData()
104 {
105 copyGSD = 0;
|
106 w.white 1.4
|
107 denise.eckstein 1.11 for (unsigned int i=0; i<StatisticalData::length; i++)
108 {
109 numCalls[i] = 0;
|
110 kumpf 1.18 cimomTime[i] = 0;
|
111 denise.eckstein 1.11 providerTime[i] = 0;
112 responseSize[i] = 0;
113 requestSize[i] = 0;
114 }
|
115 sage 1.1 }
116
|
117 karl 1.22.8.4 void StatisticalData::addToValue(Sint64 value, MessageType msgType, Uint32 t)
|
118 denise.eckstein 1.11 {
|
119 karl 1.22.8.4 // Map MessageType to statistic type
120 Uint16 type;
121 if ((msgType) >= CIM_OPEN_ENUMERATE_INSTANCES_RESPONSE_MESSAGE)
122 {
123 type = msgType - CIM_SET_QUALIFIER_RESPONSE_MESSAGE;
124 }
125 else if (msgType >= CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE)
126 {
127 type = msgType - CIM_OPEN_ENUMERATE_INSTANCES_REQUEST_MESSAGE;
128 }
129 else if (msgType >= CIM_GET_CLASS_RESPONSE_MESSAGE)
130 {
131 type = msgType - CIM_GET_CLASS_RESPONSE_MESSAGE;
132 }
133 else
134 {
135 type = msgType - 1;
136 }
137
138 cout << "StatisticalData::addToValue " << MessageTypeToString(msgType)
139 << " # " << msgType << " stat type " << type << endl;
140 karl 1.22.8.4 // Test if valid statistic type
|
141 denise.eckstein 1.11 if (type >= NUMBER_OF_TYPES)
142 {
|
143 marek 1.19 PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
|
144 denise.eckstein 1.11 "StatData: Statistical Data Discarded. "
|
145 marek 1.19 "Invalid Request Type = %u", type));
|
146 denise.eckstein 1.11 return;
147 }
148
149 if (copyGSD)
150 {
151 AutoMutex autoMut(_mutex);
152 switch (t)
153 {
|
154 denise.eckstein 1.12 case PEGASUS_STATDATA_SERVER:
|
155 denise.eckstein 1.11 numCalls[type] += 1;
156 cimomTime[type] += value;
|
157 marek 1.20 PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
|
158 denise.eckstein 1.11 "StatData: SERVER: %s(%d): count = %"
159 PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
160 PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
161 PEGASUS_64BIT_CONVERSION_WIDTH "d",
162 (const char *)requestName[type].getCString(), type,
|
163 marek 1.19 numCalls[type], value, cimomTime[type]));
|
164 denise.eckstein 1.11 break;
|
165 denise.eckstein 1.12 case PEGASUS_STATDATA_PROVIDER:
|
166 denise.eckstein 1.11 providerTime[type] += value;
|
167 marek 1.20 PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
|
168 denise.eckstein 1.11 "StatData: PROVIDER: %s(%d): count = %"
169 PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
170 PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
171 PEGASUS_64BIT_CONVERSION_WIDTH "d",
172 (const char *)requestName[type].getCString(), type,
|
173 marek 1.19 numCalls[type], value, providerTime[type]));
|
174 denise.eckstein 1.11 break;
|
175 denise.eckstein 1.12 case PEGASUS_STATDATA_BYTES_SENT:
|
176 denise.eckstein 1.11 responseSize[type] += value;
|
177 marek 1.20 PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
|
178 denise.eckstein 1.11 "StatData: BYTES_SENT: %s(%d): count = %"
179 PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
180 PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
181 PEGASUS_64BIT_CONVERSION_WIDTH "d",
182 (const char *)requestName[type].getCString(), type,
|
183 marek 1.19 numCalls[type], value, responseSize[type]));
|
184 denise.eckstein 1.11 break;
|
185 denise.eckstein 1.12 case PEGASUS_STATDATA_BYTES_READ:
|
186 denise.eckstein 1.11 requestSize[type] += value;
|
187 marek 1.20 PEG_TRACE((TRC_STATISTICAL_DATA, Tracer::LEVEL4,
|
188 denise.eckstein 1.11 "StatData: BYTES_READ: %s(%d): count = %"
189 PEGASUS_64BIT_CONVERSION_WIDTH "d; value = %"
190 PEGASUS_64BIT_CONVERSION_WIDTH "d; total = %"
191 PEGASUS_64BIT_CONVERSION_WIDTH "d",
192 (const char *)requestName[type].getCString(), type,
|
193 marek 1.19 numCalls[type], value, requestSize[type]));
|
194 denise.eckstein 1.11 break;
195 }
196 }
|
197 sage 1.1 }
198
|
199 mike 1.17 void StatisticalData::setCopyGSD(Boolean flag)
|
200 w.white 1.6 {
|
201 kumpf 1.18 copyGSD = flag;
|
202 w.white 1.6 }
|
203 w.white 1.4
|
204 sage 1.1 PEGASUS_NAMESPACE_END
|