ClientOpPerformanceDataHandler.h
1 //%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 // 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 //
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31 
32 #ifndef ClientOpPerformanceDataHandler_h
33 #define ClientOpPerformanceDataHandler_h
34 
35 #include <Pegasus/Common/CIMOperationType.h>
36 #include <Pegasus/Client/Linkage.h>
37 
38 PEGASUS_NAMESPACE_BEGIN
39 
44 struct PEGASUS_CLIENT_LINKAGE ClientOpPerformanceData
45 {
49  CIMOperationType operationType;
50 
55  Boolean serverTimeKnown;
56 
62  Uint64 serverTime;
63 
70  Uint64 roundTripTime;
71 
74  Uint64 requestSize;
75 
78  Uint64 responseSize;
79 };
80 
81 
87 class PEGASUS_CLIENT_LINKAGE ClientOpPerformanceDataHandler
88 {
89 public:
90 
92 
109  virtual void handleClientOpPerformanceData(
110  const ClientOpPerformanceData& item) = 0;
111 };
112 
113 
114 /*
115 
116 The following example shows how a ClientOpPerformanceDataHandler callback may
117 be used by a client application.
118 
119 // A ClientOpPerformanceDataHandler implementation that simply prints the
120 // data from the ClientOpPerformanceData object.
121 
122 class ClientStatisticsAccumulator : public ClientOpPerformanceDataHandler
123 {
124 public:
125 
126  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  {
141  cout << " serverTimeKnown is false" << endl;
142  }
143  }
144 };
145 
146 int main(int argc, char** argv)
147 {
148  // Establish the namespace from the input parameters
149  String nameSpace = "root/cimv2";
150 
151  //Get hostname
152  String location = "localhost";
153 
154  //Get port number
155  Uint32 port = 5988;
156 
157  //Get user name and password
158  String userN;
159  String passW;
160 
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 
181  // Register callback and EnumerateInstances
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 
200  return 0;
201 }
202 
203 */
204 
205 
206 PEGASUS_NAMESPACE_END
207 
208 #endif /* ClientOpPerformanceDataHandler_h */
209 
210 
Uint64 responseSize
Definition: ClientOpPerformanceDataHandler.h:78
Definition: ClientOpPerformanceDataHandler.h:44
Uint64 roundTripTime
Definition: ClientOpPerformanceDataHandler.h:70
Boolean serverTimeKnown
Definition: ClientOpPerformanceDataHandler.h:55
CIMOperationType operationType
Definition: ClientOpPerformanceDataHandler.h:49
Uint64 serverTime
Definition: ClientOpPerformanceDataHandler.h:62
Definition: ClientOpPerformanceDataHandler.h:87
Uint64 requestSize
Definition: ClientOpPerformanceDataHandler.h:74