1 martin 1.13 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.14 //
|
3 martin 1.13 // 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.14 //
|
10 martin 1.13 // 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.14 //
|
17 martin 1.13 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.14 //
|
20 martin 1.13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.14 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.13 // 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.14 //
|
28 martin 1.13 //////////////////////////////////////////////////////////////////////////
|
29 w.white 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef ClientOpPerformanceDataHandler_h
33 #define ClientOpPerformanceDataHandler_h
34
|
35 kumpf 1.8 #include <Pegasus/Common/CIMOperationType.h>
|
36 w.white 1.3 #include <Pegasus/Client/Linkage.h>
|
37 w.white 1.1
|
38 david.dillard 1.4 PEGASUS_NAMESPACE_BEGIN
|
39 w.white 1.3
|
40 kumpf 1.12 /**
41 A ClientOpPerformanceData object contains performance data for a single
42 CIM operation. It is used by the ClientOpPerformanceDataHandler callback.
43 */
|
44 w.white 1.3 struct PEGASUS_CLIENT_LINKAGE ClientOpPerformanceData
|
45 w.white 1.1 {
|
46 kumpf 1.8 /** Identifies the operation type for the statistical information
47 provided.
|
48 w.white 1.1 */
49 CIMOperationType operationType;
50
|
51 kumpf 1.8 /** Indicates whether the serverTime member contains valid data. This
52 flag is true if a WBEMServerResponseTime value is received from the
53 CIM Server, false otherwise.
|
54 w.white 1.1 */
|
55 w.white 1.3 Boolean serverTimeKnown;
|
56 w.white 1.1
|
57 kumpf 1.8 /** Contains the number of microseconds elapsed during the CIM Server
58 processing of the request.
|
59 dave.sudlik 1.10 WARNING: This elapsed time may be constrained by limitations in the
60 granularity of the system clock on certain platforms.
|
61 w.white 1.1 */
62 Uint64 serverTime;
63
|
64 kumpf 1.8 /** Contains the number of microseconds elapsed during the complete
65 processing of the request, including time spent on the network and
66 in the CIM Server (serverTime).
|
67 dave.sudlik 1.10 WARNING: This elapsed time may be constrained by limitations in the
68 granularity of the system clock on certain platforms.
|
69 w.white 1.1 */
70 Uint64 roundTripTime;
71
|
72 kumpf 1.8 /** Contains the size of the request message (in bytes).
|
73 w.white 1.1 */
|
74 kumpf 1.8 Uint64 requestSize;
|
75 w.white 1.1
|
76 kumpf 1.8 /** Contains the size of the response message (in bytes).
|
77 w.white 1.1 */
|
78 kumpf 1.8 Uint64 responseSize;
79 };
|
80 w.white 1.3
81
|
82 kumpf 1.8 /** A ClientOpPerformanceDataHandler subclass object may be registered with a
83 CIMClient object by a client application. The subclass object must not
84 be destructed while it is registered with a CIMClient object, so it is
85 recommended that these objects have the same scope.
86 */
|
87 w.white 1.3 class PEGASUS_CLIENT_LINKAGE ClientOpPerformanceDataHandler
88 {
89 public:
90
|
91 kumpf 1.8 virtual ~ClientOpPerformanceDataHandler();
92
93 /**
94 Processes client operation performance data. When a
95 ClientOpPerformanceDataHandler subclass object is registered with a
96 CIMClient object, this method is called by the CIMClient object with
97 performance data for each completed CIM operation.
98
99 This method may, for example, accumulate the performance data to
100 calculate average processing times for multiple operations.
101
102 Exceptions thrown by this method are not caught by the CIMClient.
103 Therefore, a client application would receive an exception from this
104 method in place of CIM operation response data.
105
106 @param item A ClientOpPerformanceData object containing performance
107 data for a single CIM operation.
108 */
109 virtual void handleClientOpPerformanceData(
110 const ClientOpPerformanceData& item) = 0;
111 };
|
112 w.white 1.3
113
114 /*
115
|
116 kumpf 1.8 The following example shows how a ClientOpPerformanceDataHandler callback may
117 be used by a client application.
|
118 w.white 1.3
|
119 kumpf 1.8 // A ClientOpPerformanceDataHandler implementation that simply prints the
120 // data from the ClientOpPerformanceData object.
|
121 w.white 1.3
122 class ClientStatisticsAccumulator : public ClientOpPerformanceDataHandler
123 {
124 public:
125
|
126 kumpf 1.8 virtual void handleClientOpPerformanceData(
127 const ClientOpPerformanceData& item)
128 {
129 cout << "ClientStatisticsAccumulator data:" << endl;
130 cout << " operationType is " << (Uint32)item.operationType << endl;
131 cout << " serverTime is " << (Uint32)item.serverTime << endl;
132 cout << " roundTripTime is " << (Uint32)item.roundTripTime << endl;
133 cout << " requestSize is " << (Uint32)item.requestSize << endl;
134 cout << " responseSize is " << (Uint32)item.responseSize << endl;
135 if (item.serverTimeKnown)
136 {
137 cout << " serverTimeKnown is true" << endl;
138 }
139 else
|
140 w.white 1.3 {
|
141 kumpf 1.8 cout << " serverTimeKnown is false" << endl;
|
142 w.white 1.3 }
|
143 kumpf 1.8 }
|
144 w.white 1.3 };
145
146 int main(int argc, char** argv)
147 {
|
148 kumpf 1.8 // Establish the namespace from the input parameters
149 String nameSpace = "root/cimv2";
|
150 w.white 1.3
|
151 kumpf 1.8 //Get hostname
152 String location = "localhost";
|
153 w.white 1.3
|
154 kumpf 1.8 //Get port number
155 Uint32 port = 5988;
|
156 w.white 1.3
|
157 kumpf 1.8 //Get user name and password
|
158 kumpf 1.11 String userN;
159 String passW;
|
160 kumpf 1.8
161 // Connect to the server
162
163 String className = "PG_ComputerSystem";
164 CIMClient client;
165 // Note: The ClientStatisticsAccumulator object should have the same
166 // scope as the CIMClient object.
167 ClientStatisticsAccumulator accumulator;
168
169 try
170 {
171 client.connect(location, port, userN, passW);
172 }
173 catch (Exception& e)
174 {
175 cerr << argv[0] << "Exception connecting to: " << location << endl;
176 cerr << e.getMessage() << endl;
177 exit(1);
178 }
179
180 ///////////////////////////////////////////////////
181 kumpf 1.8 // Register callback and EnumerateInstances
182 /////////////////////////////////////////////////////
183
184 client.registerClientOpPerformanceDataHandler(accumulator);
185
186 try
187 {
188 Array<CIMObjectPath> instances;
189
190 // Note: Completion of this CIMClient operation will invoke the
191 // ClientOpPerformanceDataHandler callback.
192 instances = client.enumerateInstanceNames(nameSpace, className);
193 }
194 catch (Exception& e)
195 {
196 cerr << "Exception: " << e.getMessage() << endl;
197 exit(1);
198 }
|
199 w.white 1.3
|
200 kumpf 1.8 return 0;
|
201 w.white 1.3 }
202
203 */
204
|
205 w.white 1.1
206 PEGASUS_NAMESPACE_END
207
208 #endif /* ClientOpPerformanceDataHandler_h */
209
|
210 w.white 1.3
|