xrootd
|
00001 /*****************************************************************************/ 00002 /* */ 00003 /* XrdMonDecDictInfo.hh */ 00004 /* */ 00005 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00006 /* All Rights Reserved */ 00007 /* Produced by Jacek Becla for Stanford University under contract */ 00008 /* DE-AC02-76SF00515 with the Department of Energy */ 00009 /*****************************************************************************/ 00010 00011 // $Id$ 00012 00013 #ifndef XRDMONDECDICTINFO_HH 00014 #define XRDMONDECDICTINFO_HH 00015 00016 #include "XrdMon/XrdMonCommon.hh" 00017 #include "XrdMon/XrdMonTypes.hh" 00018 #include "XrdSys/XrdSysHeaders.hh" 00019 00020 #include <string> 00021 #include <strings.h> 00022 #include <string.h> 00023 00024 using std::ostream; 00025 using std::string; 00026 00027 class XrdMonDecTraceInfo; 00028 00029 class XrdMonDecDictInfo { 00030 public: 00031 00032 enum TYPE { OPEN, CLOSE }; 00033 00034 XrdMonDecDictInfo(); 00035 XrdMonDecDictInfo(dictid_t id, 00036 dictid_t uniqueId, 00037 const char* theString, 00038 int len, 00039 senderid_t senderId); 00040 XrdMonDecDictInfo(const char* buf, int& pos); 00041 00042 dictid_t xrdId() const { return _myXrdId; } 00043 dictid_t uniqueId() const { return _myUniqueId; } 00044 senderid_t senderId() const { return _senderId; } 00045 00046 bool isClosed() const { return 0 != _close; } 00047 int stringSize() const; 00048 const char* convert2string() const; 00049 const char* writeRT2BufferOpenFile(kXR_int64 fSize) const; 00050 const char* writeRT2BufferCloseFile() const; 00051 void writeSelf2buf(char* buf, int& pos) const; 00052 00053 void openFile(kXR_int32 t, kXR_int64 fSize); 00054 void closeFile(kXR_int64 bytesR, kXR_int64 bytesW, kXR_int32 t); 00055 bool addTrace(const XrdMonDecTraceInfo& trace); 00056 00057 int mySize() const; 00058 00059 private: 00060 int doOne(const char* s, char* buf, int len, char delim) { 00061 int x = 0; 00062 while ( x < len && *(s+x) != delim ) { 00063 ++x; 00064 } 00065 if ( x >= len ) { 00066 return -1; 00067 } 00068 00069 memcpy(buf, s, x); 00070 *(buf+x) = '\0'; 00071 return x; 00072 } 00073 00074 dictid_t _myXrdId; // the one that come inside packet, not unique 00075 dictid_t _myUniqueId; // unique (across all dictIds for given xrd server) 00076 00077 string _user; 00078 kXR_int16 _pid; 00079 string _cHost; // client host 00080 string _path; 00081 senderid_t _senderId; 00082 kXR_int32 _open; 00083 kXR_int32 _close; 00084 00085 kXR_int64 _fSize; 00086 kXR_int64 _noRBytes; // no bytes read 00087 kXR_int64 _noWBytes; // no bytes writen 00088 00089 friend ostream& operator<<(ostream& o, 00090 const XrdMonDecDictInfo& m); 00091 }; 00092 00093 #endif /* XRDMONDECDICTINFO_HH */