(file) Return to ClientOpPerformanceDataHandler.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Client

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2