1 karl 1.2 //%2005////////////////////////////////////////////////////////////////////////
|
2 w.white 1.1 //
3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.2 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 w.white 1.1 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 w.white 1.1 #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 w.white 1.1
|
41 w.white 1.3 struct PEGASUS_CLIENT_LINKAGE ClientOpPerformanceData
|
42 w.white 1.1 {
|
43 kumpf 1.8 /** Identifies the operation type for the statistical information
44 provided.
|
45 w.white 1.1 */
46 CIMOperationType operationType;
47
|
48 kumpf 1.8 /** Indicates whether the serverTime member contains valid data. This
49 flag is true if a WBEMServerResponseTime value is received from the
50 CIM Server, false otherwise.
|
51 w.white 1.1 */
|
52 w.white 1.3 Boolean serverTimeKnown;
|
53 w.white 1.1
|
54 kumpf 1.8 /** Contains the number of microseconds elapsed during the CIM Server
55 processing of the request.
|
56 w.white 1.1 */
57 Uint64 serverTime;
58
|
59 kumpf 1.8 /** Contains the number of microseconds elapsed during the complete
60 processing of the request, including time spent on the network and
61 in the CIM Server (serverTime).
|
62 w.white 1.1 */
63 Uint64 roundTripTime;
64
|
65 kumpf 1.8 /** Contains the size of the request message (in bytes).
|
66 w.white 1.1 */
|
67 kumpf 1.8 Uint64 requestSize;
|
68 w.white 1.1
|
69 kumpf 1.8 /** Contains the size of the response message (in bytes).
|
70 w.white 1.1 */
|
71 kumpf 1.8 Uint64 responseSize;
72 };
|
73 w.white 1.3
74
|
75 kumpf 1.8 /** A ClientOpPerformanceDataHandler subclass object may be registered with a
76 CIMClient object by a client application. The subclass object must not
77 be destructed while it is registered with a CIMClient object, so it is
78 recommended that these objects have the same scope.
79 */
|
80 w.white 1.3 class PEGASUS_CLIENT_LINKAGE ClientOpPerformanceDataHandler
81 {
82 public:
83
|
84 kumpf 1.8 virtual ~ClientOpPerformanceDataHandler();
85
86 /**
87 Processes client operation performance data. When a
88 ClientOpPerformanceDataHandler subclass object is registered with a
89 CIMClient object, this method is called by the CIMClient object with
90 performance data for each completed CIM operation.
91
92 This method may, for example, accumulate the performance data to
93 calculate average processing times for multiple operations.
94
95 Exceptions thrown by this method are not caught by the CIMClient.
96 Therefore, a client application would receive an exception from this
97 method in place of CIM operation response data.
98
99 @param item A ClientOpPerformanceData object containing performance
100 data for a single CIM operation.
101 */
102 virtual void handleClientOpPerformanceData(
103 const ClientOpPerformanceData& item) = 0;
104 };
|
105 w.white 1.3
106
107 /*
108
|
109 kumpf 1.8 The following example shows how a ClientOpPerformanceDataHandler callback may
110 be used by a client application.
|
111 w.white 1.3
|
112 kumpf 1.8 // A ClientOpPerformanceDataHandler implementation that simply prints the
113 // data from the ClientOpPerformanceData object.
|
114 w.white 1.3
115 class ClientStatisticsAccumulator : public ClientOpPerformanceDataHandler
116 {
117 public:
118
|
119 kumpf 1.8 virtual void handleClientOpPerformanceData(
120 const ClientOpPerformanceData& item)
121 {
122 cout << "ClientStatisticsAccumulator data:" << endl;
123 cout << " operationType is " << (Uint32)item.operationType << endl;
124 cout << " serverTime is " << (Uint32)item.serverTime << endl;
125 cout << " roundTripTime is " << (Uint32)item.roundTripTime << endl;
126 cout << " requestSize is " << (Uint32)item.requestSize << endl;
127 cout << " responseSize is " << (Uint32)item.responseSize << endl;
128 if (item.serverTimeKnown)
129 {
130 cout << " serverTimeKnown is true" << endl;
131 }
132 else
|
133 w.white 1.3 {
|
134 kumpf 1.8 cout << " serverTimeKnown is false" << endl;
|
135 w.white 1.3 }
|
136 kumpf 1.8 }
|
137 w.white 1.3 };
138
139 int main(int argc, char** argv)
140 {
|
141 kumpf 1.8 // Establish the namespace from the input parameters
142 String nameSpace = "root/cimv2";
|
143 w.white 1.3
|
144 kumpf 1.8 //Get hostname
145 String location = "localhost";
|
146 w.white 1.3
|
147 kumpf 1.8 //Get port number
148 Uint32 port = 5988;
|
149 w.white 1.3
|
150 kumpf 1.8 //Get user name and password
151 String userN = String::EMPTY;
152 String passW = String::EMPTY;
153
154 // Connect to the server
155
156 String className = "PG_ComputerSystem";
157 CIMClient client;
158 // Note: The ClientStatisticsAccumulator object should have the same
159 // scope as the CIMClient object.
160 ClientStatisticsAccumulator accumulator;
161
162 try
163 {
164 client.connect(location, port, userN, passW);
165 }
166 catch (Exception& e)
167 {
168 cerr << argv[0] << "Exception connecting to: " << location << endl;
169 cerr << e.getMessage() << endl;
170 exit(1);
171 kumpf 1.8 }
172
173 ///////////////////////////////////////////////////
174 // Register callback and EnumerateInstances
175 /////////////////////////////////////////////////////
176
177 client.registerClientOpPerformanceDataHandler(accumulator);
178
179 try
180 {
181 Array<CIMObjectPath> instances;
182
183 // Note: Completion of this CIMClient operation will invoke the
184 // ClientOpPerformanceDataHandler callback.
185 instances = client.enumerateInstanceNames(nameSpace, className);
186 }
187 catch (Exception& e)
188 {
189 cerr << "Exception: " << e.getMessage() << endl;
190 exit(1);
191 }
|
192 w.white 1.3
|
193 kumpf 1.8 return 0;
|
194 w.white 1.3 }
195
196 */
197
|
198 w.white 1.1
199 PEGASUS_NAMESPACE_END
200
201 #endif /* ClientOpPerformanceDataHandler_h */
202
|
203 w.white 1.3
|