Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:31:04

0001 //------------------------------------------------------------------------------
0002 // Copyright (c) 2012 by the Board of Trustees of the Leland Stanford, Jr.,
0003 // University
0004 // Copyright (c) 2012 by European Organization for Nuclear Research (CERN)
0005 // Author: Andrew Hanushevsky <abh@stanford.edu>
0006 // Author: Lukasz Janyst <ljanyst@cern.ch>
0007 //------------------------------------------------------------------------------
0008 // XRootD is free software: you can redistribute it and/or modify
0009 // it under the terms of the GNU Lesser General Public License as published by
0010 // the Free Software Foundation, either version 3 of the License, or
0011 // (at your option) any later version.
0012 //
0013 // XRootD is distributed in the hope that it will be useful,
0014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
0015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016 // GNU General Public License for more details.
0017 //
0018 // You should have received a copy of the GNU Lesser General Public License
0019 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
0020 //------------------------------------------------------------------------------
0021 
0022 //------------------------------------------------------------------------------
0023 //! When the envar XRD_CLIENTMONITOR is set to the libpath/libname.so that
0024 //! holds the monitoring object, it is automatically loaded. The following
0025 //! "C" external symbols must exist in the monitor plug-in shared library.
0026 //! It is called to obtain an instance of the XrdCl::Monitor object.
0027 //!
0028 //! @param  exec  full path name to executable provided by XrdSysUtils::ExecName
0029 //!
0030 //! @param  parms Value of XRD_CLIENTMONITOPARAM envar or null if it is not set.
0031 //!
0032 //! @return Pointer to an instance of XrdCl::Monitor or null which causes
0033 //!         monitoring to be disabled.
0034 //!
0035 //! extern "C"
0036 //! {
0037 //!   XrdCl::Monitor *XrdClGetMonitor(const char *exec, const char *parms);
0038 //! }
0039 //------------------------------------------------------------------------------
0040 
0041 #ifndef __XRD_CL_MONITOR_HH__
0042 #define __XRD_CL_MONITOR_HH__
0043 
0044 #include "XrdCl/XrdClFileSystem.hh"
0045 
0046 #include <sys/time.h>
0047 
0048 namespace XrdCl
0049 {
0050   class URL;
0051 
0052   //----------------------------------------------------------------------------
0053   //! An abstract class to describe the client-side monitoring plugin interface.
0054   //----------------------------------------------------------------------------
0055   class Monitor
0056   {
0057     public:
0058       //------------------------------------------------------------------------
0059       //! Constructor
0060       //------------------------------------------------------------------------
0061       Monitor() {}
0062 
0063       //------------------------------------------------------------------------
0064       //! Destructor
0065       //------------------------------------------------------------------------
0066       virtual ~Monitor() {}
0067 
0068       //------------------------------------------------------------------------
0069       //! Describe a server login event
0070       //------------------------------------------------------------------------
0071       struct ConnectInfo
0072       {
0073         ConnectInfo(): streams( 0 )
0074         {
0075           sTOD.tv_sec = 0; sTOD.tv_usec = 0;
0076           eTOD.tv_sec = 0; eTOD.tv_usec = 0;
0077         }
0078         std::string server;  //!< "user@host:port"
0079         std::string auth;    //!< authentication protocol used or empty if none
0080         timeval     sTOD;    //!< gettimeofday() when login started
0081         timeval     eTOD;    //!< gettimeofday() when login ended
0082         uint16_t    streams; //!< Number of streams
0083       };
0084 
0085       //------------------------------------------------------------------------
0086       //! Describe a server logout event
0087       //------------------------------------------------------------------------
0088       struct DisconnectInfo
0089       {
0090         DisconnectInfo(): rBytes(0), sBytes(0), cTime(0)
0091         {}
0092         std::string server;  //!< "user@host:port"
0093         uint64_t    rBytes;  //!< Number of bytes received
0094         uint64_t    sBytes;  //!< Number of bytes sent
0095         time_t      cTime;   //!< Seconds connected to the server
0096         Status      status;  //!< Disconnection status
0097       };
0098 
0099       //------------------------------------------------------------------------
0100       //! Describe a file open event to the monitor
0101       //------------------------------------------------------------------------
0102       struct OpenInfo
0103       {
0104         OpenInfo(): file(0), fSize(0), oFlags(0) {}
0105         const URL   *file;        //!< File in question
0106         std::string  dataServer;  //!< Actual fata server
0107         uint64_t     fSize;       //!< File size in bytes
0108         uint16_t     oFlags;      //!< OpenFlags
0109       };
0110 
0111       //------------------------------------------------------------------------
0112       //! Describe a file close event
0113       //------------------------------------------------------------------------
0114       struct CloseInfo
0115       {
0116         CloseInfo():
0117           file(0), rBytes(0), vrBytes(0), wBytes(0), vwBytes(0), vSegs(0), rCount(0),
0118           vCount(0), wCount(0), status(0)
0119         {
0120           oTOD.tv_sec = 0; oTOD.tv_usec = 0;
0121           cTOD.tv_sec = 0; cTOD.tv_usec = 0;
0122         }
0123         const URL          *file;     //!< The file in question
0124         timeval             oTOD;     //!< gettimeofday() when file was opened
0125         timeval             cTOD;     //!< gettimeofday() when file was closed
0126         uint64_t            rBytes;   //!< Total number of bytes read via read
0127         uint64_t            vrBytes;  //!< Total number of bytes read via readv
0128         uint64_t            wBytes;   //!< Total number of bytes written
0129         uint64_t            vwBytes;  //!< Total number of bytes written vie writev
0130         uint64_t            vSegs;    //!< Total count  of readv segments
0131         uint32_t            rCount;   //!< Total count  of reads
0132         uint32_t            vCount;   //!< Total count  of readv
0133         uint32_t            wCount;   //!< Total count  of writes
0134         const XRootDStatus *status;   //!< Close status
0135       };
0136 
0137       //------------------------------------------------------------------------
0138       //! Describe an encountered file-based error
0139       //------------------------------------------------------------------------
0140       struct ErrorInfo
0141       {
0142         enum Operation
0143         {
0144           ErrOpen = 0,  //!< Open (ditto)
0145           ErrRead,      //!< Read
0146           ErrReadV,     //!< Readv
0147           ErrWrite,     //!< Write
0148           ErrWriteV,    //!< WriteV
0149           ErrUnc        //!< Unclassified operation
0150         };
0151 
0152         ErrorInfo(): file(0), status(0), opCode( ErrUnc ) {}
0153         const URL          *file;    //!< The file in question
0154         const XRootDStatus *status;  //!< Status code
0155         Operation           opCode;  //!< The associated operation
0156       };
0157 
0158       //------------------------------------------------------------------------
0159       //! Describe the transfer
0160       //------------------------------------------------------------------------
0161       struct TransferInfo
0162       {
0163         TransferInfo(): origin(0), target(0) {}
0164         const URL *origin;  //!< URL of the origin
0165         const URL *target;  //!< URL of the target
0166       };
0167 
0168       //------------------------------------------------------------------------
0169       //! Describe a start of copy event. Copy events are sequential by nature.
0170       //! a copybeg event is followed by a number of open and close events. When
0171       //! the copy finishes, all files are closed and a copyend event occurs.
0172       //------------------------------------------------------------------------
0173       struct CopyBInfo
0174       {
0175         TransferInfo transfer; //!< The transfer in question
0176       };
0177 
0178       //------------------------------------------------------------------------
0179       //! Describe an end  of copy event
0180       //------------------------------------------------------------------------
0181       struct CopyEInfo
0182       {
0183         CopyEInfo(): sources(0), status(0)
0184         {
0185           bTOD.tv_sec = 0; bTOD.tv_usec = 0;
0186           eTOD.tv_sec = 0; eTOD.tv_usec = 0;
0187         }
0188         TransferInfo        transfer; //!< The transfer in question
0189         int                 sources;  //!< Number of sources used for the copy
0190         timeval             bTOD;     //!< Copy start time
0191         timeval             eTOD;     //!< Copy end time
0192         const XRootDStatus *status;   //!< Status of the copy
0193       };
0194 
0195       //------------------------------------------------------------------------
0196       //! Describe a checksum event
0197       //------------------------------------------------------------------------
0198       struct CheckSumInfo
0199       {
0200         CheckSumInfo(): oTime(0), tTime(0), isOK(false) {}
0201         TransferInfo transfer;  //!< The transfer in question
0202         std::string  cksum;     //!< Checksum as "type:value"
0203         uint64_t     oTime;     //!< Microseconds to obtain cksum from origin
0204         uint64_t     tTime;     //!< Microseconds to obtain cksum from target
0205         bool         isOK;      //!< True if checksum matched, false otherwise
0206       };
0207 
0208       //------------------------------------------------------------------------
0209       //! Event codes passed to the Event() method. Event code values not
0210       //! listed here, if encountered, should be ignored.
0211       //------------------------------------------------------------------------
0212       enum EventCode
0213       {
0214         EvCopyBeg,        //!< CopyBInfo: Copy operation started
0215         EvCopyEnd,        //!< CopyEInfo: Copy operation ended
0216         EvCheckSum,       //!< CheckSumInfo: File checksummed
0217         EvOpen,           //!< OpenInfo: File opened
0218         EvClose,          //!< CloseInfo: File closed
0219         EvErrIO,          //!< ErrorInfo: An I/O error occurred
0220         EvConnect,        //!< ConnectInfo: Login  into a server
0221         EvDisconnect      //!< DisconnectInfo: Logout from a server
0222 
0223       };
0224 
0225       //------------------------------------------------------------------------
0226       //! Inform the monitor of an event.
0227       //!
0228       //! @param evCode is the event that occurred (see enum evNum)
0229       //! @param evData is the event information structure describing the event
0230       //!               it is cast to (void *) so that one method can be used
0231       //!               and should be recast to the correct corresponding struct
0232       //------------------------------------------------------------------------
0233       virtual void Event( EventCode evCode, void *evData ) = 0;
0234   };
0235 }
0236 
0237 #endif // __XRD_CL_MONITOR_HH