XrdMonDecPacketDecoder.hh

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*                                                                           */
00003 /*                        XrdMonDecPacketDecoder.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: XrdMonDecPacketDecoder.hh 24468 2008-06-22 16:47:03Z ganis $
00012 #ifndef XRDMONDECPACKETDECODER_HH
00013 #define XRDMONDECPACKETDECODER_HH
00014 
00015 #include "XrdMon/XrdMonHeader.hh"
00016 #include "XrdMon/XrdMonDecSink.hh"
00017 #include <utility> // for pair
00018 #include <sys/time.h>
00019 using std::pair;
00020 
00021 class XrdMonDecPacketDecoder {
00022 public:
00023     XrdMonDecPacketDecoder(const char* baseDir, 
00024                            const char* rtLogDir,
00025                            int rtBufSize);
00026 
00027     XrdMonDecPacketDecoder(const char* baseDir,
00028                            bool saveTraces,
00029                            int maxTraceLogSize,
00030                            kXR_int32 upToTime);
00031 
00032     void init(dictid_t min, dictid_t max, const string& senderHP);
00033     sequen_t lastSeq() const { return _sink.lastSeq(); }
00034     
00035     void operator()(const XrdMonHeader& header,
00036                     const char* packet,
00037                     senderid_t senderId=INVALID_SENDER_ID);
00038 
00039     void reset(senderid_t senderId);
00040     
00041     bool     stopNow() const { return _stopNow; }
00042 
00043     void flushHistoryData() { return _sink.flushHistoryData(); }
00044     void flushRealTimeData() { return _sink.flushRealTimeData(); }
00045     
00046 private:
00047     typedef pair<kXR_int32, kXR_int32> TimePair; // <beg time, end time>
00048 
00049     struct CalcTime {
00050         CalcTime(float f, kXR_int32 t, int e)
00051             : timePerTrace(f), begTimeNextWindow(t), endOffset(e) {}
00052         float  timePerTrace;
00053         kXR_int32 begTimeNextWindow;
00054         int    endOffset;
00055     };
00056     
00057     CalcTime& f();
00058     
00059     typedef pair<float, kXR_int32> FloatTime; // <time per trace, beg time next wind>
00060 
00061     void checkLostPackets(const XrdMonHeader& header);
00062     
00063     void decodeTracePacket(const char* packet,
00064                            int packetLen,
00065                            senderid_t senderId);
00066     void decodeDictPacket(const char* packet,
00067                           int packetLen,
00068                           senderid_t senderId);
00069     void decodeUserPacket(const char* packet,
00070                           int packetLen,
00071                           senderid_t senderId);
00072     void decodeStagePacket(const char* packet,
00073                            int packetLen,
00074                            senderid_t senderId);
00075 
00076     TimePair decodeTime(const char* packet);
00077     void decodeRWRequest(const char* packet,
00078                          kXR_int32 timestamp,
00079                          senderid_t senderId);
00080     void decodeOpen(const char* packet,
00081                     kXR_int32 timestamp,
00082                     senderid_t senderId);
00083     void decodeClose(const char* packet,
00084                      kXR_int32 timestamp,
00085                      senderid_t senderId);
00086     void decodeDisconnect(const char* packet,
00087                           kXR_int32 timestamp,
00088                           senderid_t senderId);
00089 
00090     CalcTime prepareTimestamp(const char* packet, 
00091                               int& offset, 
00092                               int len, 
00093                               kXR_int32& begTime);
00094 private:
00095     XrdMonDecSink _sink;
00096     bool          _stopNow;
00097 
00098     kXR_int32     _upToTime; // for decoding parts of log file
00099 };
00100 
00101 #endif /* XRDMONDECPACKETDECODER_HH */

Generated on Tue Jul 5 14:46:42 2011 for ROOT_528-00b_version by  doxygen 1.5.1