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
33 #ifndef ClientOpPerformanceDataHandler_h
34 #define ClientOpPerformanceDataHandler_h
35
36
37 #include <Pegasus/Common/CIMOperationType.h>
|
38 w.white 1.3 #include <Pegasus/Client/Linkage.h>
39 #include <Pegasus/Client/ClientPerfDataStore.h>
|
40 w.white 1.1 #include <iostream>
41
|
42 david.dillard 1.4 PEGASUS_NAMESPACE_BEGIN
|
43 w.white 1.3
|
44 w.white 1.1
45
|
46 w.white 1.3 struct PEGASUS_CLIENT_LINKAGE ClientOpPerformanceData
|
47 w.white 1.1 {
|
48 w.white 1.3 /** Identifies operation type for statistical information being
49 provided
|
50 w.white 1.1 */
51 CIMOperationType operationType;
52
|
53 w.white 1.3 /** serverTimeKnown is true if the CIM server has sent back
54 a valid WBEMServerResponseTime header field.
|
55 w.white 1.1 */
|
56 w.white 1.3 Boolean serverTimeKnown;
|
57 w.white 1.1
|
58 w.white 1.3 /** serverTime is the number of micro seconds the CIM Server
|
59 w.white 1.1 has taken to process request.
60 */
61 Uint64 serverTime;
62
|
63 w.white 1.3 /** roundTripTime is the number of micro seconds a request/response
|
64 w.white 1.1 has spent in the network and server combined. roundTripTime includes
65 serverTime
66 */
67 Uint64 roundTripTime;
68
69 /**requestSize is the request message size in bytes.
70 */
71 Uint64 requestSize;
72
73 /**responseSize is the response message size in bytes.
74 */
75 Uint64 responseSize;
76 };
|
77 w.white 1.3
78
79
80 /** A sub-class of the ClientOpPerformanceDataHandler class is registered by
|
81 w.white 1.5 the client app. This sub-class should have the same scope as the CIMClient object
82 that is registering it.
|
83 w.white 1.3 */
84 class PEGASUS_CLIENT_LINKAGE ClientOpPerformanceDataHandler
85 {
86 public:
87
88 /**Callback method held by the ClientOpPerformanceDataHandler class. It is
89 called by the CIMClient library for each operation performed against the
90 server. The client application implements this method in a derived class
91 of this class, and does whatever it wants to do with the
92 raw data item it gets as an argument. For instance, it can accumulate the
93 single values to allow calculating the average across a number of operations.
|
94 w.white 1.5 Exceptions thrown by this method are not handled by the CIMClient code. The
95 exception will appear to the client application and causes the server respones
96 information not to be delivered.
|
97 w.white 1.3 @param item The client statistics data item being delivered.
98 */
|
99 w.white 1.1
|
100 w.white 1.3 virtual void handleClientOpPerformanceData (const ClientOpPerformanceData & item) = 0;
101 };
102
103
104 /*
105
106 The following example shows how the callback function can be used by a client application
107
108
109 // An implementation of a client statistics catcher that prints all the data in the
110 // ClientOpPerformanceData object
111
112 class ClientStatisticsAccumulator : public ClientOpPerformanceDataHandler
113 {
114 public:
115
116 virtual void handleClientOpPerformanceData (const ClientOpPerformanceData & item)
117 {
118 cout << "This is the client app talking" << endl;
119 cout << "operationType is " << (Uint32)item.operationType << endl;
120 cout << "serverTime is " << (Uint32)item.serverTime << endl;
121 w.white 1.3 cout << "roundTripTime is " << (Uint32)item.roundTripTime << endl;
122 cout << "requestSize is " << (Uint32)item.requestSize << endl;
123 cout << "responseSize is " << (Uint32)item.responseSize << endl;
124 if (item.serverTimeKnown) {
125 cout << "serverTimeKnow is true" << endl;
126 }
127 else{
128 cout << "serverTimeKnow is false" << endl;
129 }
130 }
131 };
132
133
134
135
136 int main(int argc, char** argv)
137 {
138 // Establish the namespace from the input parameters
139 String nameSpace = "root/cimv2";
140
141 //Get hostname
142 w.white 1.3 String location = "localhost";
143
144 //Get port number
145 Uint32 port = 5988;
146
147 //Get user name and password
148 String userN = String::EMPTY;
149 String passW = String::EMPTY;
150
151
152 //The next sectoin of code connects to the server
153
154 String className = "PG_ComputerSystem";
155 CIMClient client;
|
156 w.white 1.5 //NOTE: ClientStatisticsAccumulator variable must have the same
157 // scope as the CIMClient variable
158 ClientStatisticsAccumulator accumulator = ClientStatisticsAccumulator();
|
159 w.white 1.3
160 try
161 {
162 client.connect(location, port, userN, passW);
163 }
164
165 catch (Exception& e)
166 {
167 cerr << argv[0] << " Exception connecting to : " << location << endl;
168 cerr << e.getMessage() << endl;
169 exit(1);
170 }
171
172 Array<CIMObjectPath> instances;
173
174 ///////////////////////////////////////////////////
175 // Register callback and EnumerateInstances
176 /////////////////////////////////////////////////////
177
178 client.registerClientOpPerformanceDataHandler(accumulator);
179
180 w.white 1.3
181 //issue command to use callback
182
183 try
184 {
185 instances = client.enumerateInstanceNames(nameSpace,
186 className);
187 }
188 catch (Exception& e)
189 {
190 cerr << "Exception : " << e.getMessage() << endl;
191 exit(1);
192 }
193
194
195 return 0;
196 }
197
198 */
199
|
200 w.white 1.1
201 PEGASUS_NAMESPACE_END
202
203 #endif /* ClientOpPerformanceDataHandler_h */
204
|
205 w.white 1.3
|