source: trunk/src/testing/QUANTA/include/QUANTAnet_perfMonitor_c.hxx @ 4

Revision 4, 7.6 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/******************************************************************************
2 * QUANTA - A toolkit for High Performance Data Sharing
3 * Copyright (C) 2003 Electronic Visualization Laboratory, 
4 * University of Illinois at Chicago
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 *  * Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *  * Redistributions in binary form must reproduce the above
14 *    copyright notice, this list of conditions and the following disclaimer
15 *    in the documentation and/or other materials provided with the distribution.
16 *  * Neither the name of the University of Illinois at Chicago nor
17 *    the names of its contributors may be used to endorse or promote
18 *    products derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * Direct questions, comments etc about Quanta to cavern@evl.uic.edu
33 *****************************************************************************/
34
35#ifndef _QUANTANET_PERFMONITOR_C
36#define _QUANTANET_PERFMONITOR_C
37
38
39#include "QUANTAnet_socketbase_c.hxx"
40#include "QUANTAnet_perfDaemon_c.hxx"
41
42class QUANTAnet_perfDaemonClient_c;
43
44
45/**
46This class does the performance monitoring calculations for QUANTA.
47The calculations in the QUANTAnet_socketbase class are used by an instance
48of this class, included in other higher level modules (an instance of this class is not generally created by the user).
49
50Along with the API documentation, is also included, a note on the calculated parameters, the units of calculation and how they are calculated.
51
52As mentioned, in general, an instance of this class need not be created by the user. Instead the API's provided in the higher level classes (like the showStats, logStats and sendStats) should be directly invoked whenever network monitoring statistics is required. This is because the monitoring is done in all the networking classes automatically for every data flow over a network, using an instance of this class. The user can hence use the API's of the higher level classes as mentioned above, which would ensure statistics to be extracted whenever required.
53
54API calls should be made by the user as often as required to obtain the
55monitored statistics in the netlogger format ( <label,value> pairs).
56
57Currectly, the following capabilities have been provided with the performance monitoring: statistics can be displayed instantaneously, logged into a user specified logfile or sent to another remote daemon for further analysis
58 */
59
60
61
62class QUANTAnet_perfMonitor_c: public QUANTAnet_socketbase_c
63{
64public:
65   
66    ///Return values
67    //@{
68    ///Operation successful
69    static const int OK; //=0
70   
71    ///Operation Failed
72    static const int FAILED;  //=1
73    //@}
74    /// Default constructor allocates memory for IP strings.
75    QUANTAnet_perfMonitor_c();
76    /// Copy constructor creates a deep copy of another object.
77    QUANTAnet_perfMonitor_c(const QUANTAnet_perfMonitor_c&);
78
79    virtual ~QUANTAnet_perfMonitor_c();
80
81    //set the source and destination IPs of the machines communicating over the network - not to be used by the user
82    void setIPs(const char* selfIp, const char* remoteIp);
83   
84    //set the source and destination ports of the machines communicating over the network - not to be used by the user
85
86    void setPorts(int selfPort, int remotePort);
87   
88       /**
89       Displays the resultant statistics instantaneously in the netlogger format - this should be typically done after a read/write is done  a network.
90
91Also, it should be noted that a showStats call should be made at the end of atleast one send and receive for two-way information (the same applies for logStats and sendStats)
92
93        @param streamInfo
94        A label describing the stream that is being monitored.
95
96        @param comment
97        A comment on the event that marks the time at which the stream is being monitored
98     */
99
100    void showStats(char* streamInfo, char* comment);
101
102   /**
103       This logs performance statistics in a file. The user opens a file and passes the file pointer with this function and results of monitoring are written into the logfile.
104     
105       @param streamInfo
106        A label describing the stream that is being monitored.
107
108        @param comment
109        A comment on the event that marks the time at which the stream is being monitored
110       
111        @param filePtr
112        File pointer to the file in which the results of monitoring are to be stored
113
114        @return
115        Either QUANTAnet_perfMonitor_c::OK or QUANTAnet_perfMonitor_c::FAILED
116     */
117   
118    int logStats(char* streamInfo, char* comment, FILE* filePtr);
119
120   /**
121       Sends the performance statistics to a remote perfdaemon -for further analysis of the monitored data - the initSendStats API should be called first, before calling a sendStats (In order to connect to the perfdaemon initially)
122
123(Note: A typical example of sendStats is given in the (QUANTA_DISTRIB_DIR/demos/tcpreflector/ directory)
124
125       @param streamInfo
126        A label describing the stream that is being monitored.
127
128        @param comment
129        A comment on the event that marks the time at which the stream is being monitored
130 
131        @return
132        Either QUANTAnet_perfMonitor_c::OK or QUANTAnet_perfMonitor_c::FAILED
133       
134     */
135
136    int sendStats(char* streamInfo, char* comment);
137   
138    /**
139       Initialize sendStats - provide the IP of the perfDaemon and an optional port number to connect to. This should be done initially  before using the sendStats API.
140
141       @param monitorClientIP
142       IP address of the perfDameon to connect to
143       
144       @param port
145       Port number at which the perfDaemon is running -this is optional. The default port number for perfDaemon is 9500 -so a different port number has to be specified if the perfDaemon is running on a different port.
146
147       @return
148       Either QUANTAnet_perfMonitor_c::OK or QUANTAnet_perfMonitor_c::FAILED
149     */
150
151
152    int initSendStats(const char* monitorClientIP, int port = QUANTAnet_perfDaemon_c::DEFAULT_PORT);
153   
154    /**
155       Properly delete the perfDaemonClient after sendStats is done
156     */
157
158    void exitSendStats();
159   
160private:
161
162    //source and destination IP's of the machines communicating over the network
163    char *selfIp, *remoteIp;
164   
165   //source and destination ports of the machines communicating over the network   
166
167    int selfPort, remotePort;
168   
169    //The buffer in which the resultant stats is stored in netlogger format
170
171    char* resultantStats;
172   
173    //A perfDaemonClient used to connect to a perfDaemon to send the resultant statistics
174
175    QUANTAnet_perfDaemonClient_c* aClient;
176   
177    //Upate the performance statistics
178    void updateStats(char* streamInfo, char* comment);
179   
180   
181};
182
183
184
185
186#endif
187
188
189
190
191
192
193
194
Note: See TracBrowser for help on using the repository browser.