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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2