XrdMonDecPreProcess.hh

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*                                                                           */
00003 /*                           XrdMonDecPreProcess.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: XrdMonDecPreProcess.hh 22437 2008-03-04 14:35:16Z rdm $
00012 
00013 #ifndef XRDMONDECPREPROCESS_HH
00014 #define XRDMONDECPREPROCESS_HH
00015 
00016 #include "XrdMon/XrdMonCommon.hh"
00017 #include "XrdMon/XrdMonDecOnePacket.hh"
00018 #include <deque>
00019 #include <fstream>
00020 #include <utility>
00021 #include <vector>
00022 using std::deque;
00023 using std::pair;
00024 using std::vector;
00025 
00026 // preprocesses input file, checks for lost packets
00027 // and fixes order of packets. If order has to change,
00028 // it stores output in a tmp file.
00029 // When it returns, theFile is an open file (tmp file or original)
00030 
00031 class XrdMonDecPreProcess {
00032 public:
00033     XrdMonDecPreProcess(fstream& theFile, 
00034                         kXR_int64 fSize, 
00035                         sequen_t lastSeq,
00036                         kXR_int32 ignoreIfBefore,
00037                         vector< pair<packetlen_t, kXR_int64> >& allPackets);
00038     void operator()();
00039     
00040 private:
00041     void checkFile();
00042     kXR_char previousSeq() const;
00043     bool outOfOrder(XrdMonDecOnePacket& packet);
00044     void keepPacket(XrdMonDecOnePacket& packet);
00045     void add2TempBuf(XrdMonDecOnePacket& packet);
00046     int processOnePacket(const char* buf, 
00047                          int bytesLeft, 
00048                          kXR_int64 fPos, 
00049                          kXR_int32& xrdStartTime);
00050     void reportAndThrowIfTooBad();
00051 
00052 private:
00053     fstream& _file;
00054     kXR_int64 _fSize;
00055 
00056     enum { TBUFSIZE = 20, MAXTBUFELEM = TBUFSIZE-1 };
00057     // temporary buffer holding TBUFSIZE last packets    
00058     XrdMonDecOnePacket _tempBuf[TBUFSIZE];
00059     short _tempBufPos;
00060     bool _markNextSlotAsSpecial;
00061 
00062     kXR_int32 _ignoreIfBefore; // ignore packets that arrived before given time
00063     
00064     vector< pair<packetlen_t, kXR_int64> >& _allPackets;
00065     
00066     // for report purposes
00067     vector<int> _lostPackets;
00068     vector<int> _oooPackets;
00069     
00070     sequen_t _lastSeq; // last seq from the previous log file
00071 };
00072 
00073 #endif /* XRDMONDECPREPROCESS_HH */

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