xrootd
XrdMonDecPreProcess.hh
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* */
3 /* XrdMonDecPreProcess.hh */
4 /* */
5 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* All Rights Reserved */
7 /* Produced by Jacek Becla for Stanford University under contract */
8 /* DE-AC02-76SF00515 with the Department of Energy */
9 /*****************************************************************************/
10 
11 // $Id$
12 
13 #ifndef XRDMONDECPREPROCESS_HH
14 #define XRDMONDECPREPROCESS_HH
15 
16 #include "XrdMon/XrdMonCommon.hh"
18 #include <deque>
19 #include <fstream>
20 #include <utility>
21 #include <vector>
22 using std::deque;
23 using std::pair;
24 using std::vector;
25 
26 // preprocesses input file, checks for lost packets
27 // and fixes order of packets. If order has to change,
28 // it stores output in a tmp file.
29 // When it returns, theFile is an open file (tmp file or original)
30 
32 public:
33  XrdMonDecPreProcess(fstream& theFile,
34  kXR_int64 fSize,
35  sequen_t lastSeq,
36  kXR_int32 ignoreIfBefore,
37  vector< pair<packetlen_t, kXR_int64> >& allPackets);
38  void operator()();
39 
40 private:
41  void checkFile();
42  kXR_char previousSeq() const;
43  bool outOfOrder(XrdMonDecOnePacket& packet);
44  void keepPacket(XrdMonDecOnePacket& packet);
45  void add2TempBuf(XrdMonDecOnePacket& packet);
46  int processOnePacket(const char* buf,
47  int bytesLeft,
48  kXR_int64 fPos,
49  kXR_int32& xrdStartTime);
51 
52 private:
53  fstream& _file;
55 
56  enum { TBUFSIZE = 20, MAXTBUFELEM = TBUFSIZE-1 };
57  // temporary buffer holding TBUFSIZE last packets
59  short _tempBufPos;
61 
62  kXR_int32 _ignoreIfBefore; // ignore packets that arrived before given time
63 
64  vector< pair<packetlen_t, kXR_int64> >& _allPackets;
65 
66  // for report purposes
67  vector<int> _lostPackets;
68  vector<int> _oooPackets;
69 
70  sequen_t _lastSeq; // last seq from the previous log file
71 };
72 
73 #endif /* XRDMONDECPREPROCESS_HH */