xrootd
XrdMonDecPacketDecoder.hh
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* */
3 /* XrdMonDecPacketDecoder.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 #ifndef XRDMONDECPACKETDECODER_HH
13 #define XRDMONDECPACKETDECODER_HH
14 
15 #include "XrdMon/XrdMonHeader.hh"
16 #include "XrdMon/XrdMonDecSink.hh"
17 #include <utility> // for pair
18 #include <sys/time.h>
19 using std::pair;
20 
22 public:
23  XrdMonDecPacketDecoder(const char* baseDir,
24  const char* rtLogDir,
25  int rtBufSize);
26 
27  XrdMonDecPacketDecoder(const char* baseDir,
28  bool saveTraces,
29  int maxTraceLogSize,
30  kXR_int32 upToTime);
31 
32  void init(dictid_t min, dictid_t max, const string& senderHP);
33  sequen_t lastSeq() const { return _sink.lastSeq(); }
34 
35  void operator()(const XrdMonHeader& header,
36  const char* packet,
37  senderid_t senderId=INVALID_SENDER_ID);
38 
39  void reset(senderid_t senderId);
40 
41  bool stopNow() const { return _stopNow; }
42 
45 
46 private:
47  typedef pair<kXR_int32, kXR_int32> TimePair; // <beg time, end time>
48 
49  struct CalcTime {
50  CalcTime(float f, kXR_int32 t, int e)
52  float timePerTrace;
54  int endOffset;
55  };
56 
57  CalcTime& f();
58 
59  typedef pair<float, kXR_int32> FloatTime; // <time per trace, beg time next wind>
60 
61  void checkLostPackets(const XrdMonHeader& header);
62 
63  void decodeTracePacket(const char* packet,
64  int packetLen,
65  senderid_t senderId);
66  void decodeDictPacket(const char* packet,
67  int packetLen,
68  senderid_t senderId);
69  void decodeUserPacket(const char* packet,
70  int packetLen,
71  senderid_t senderId);
72  void decodeStagePacket(const char* packet,
73  int packetLen,
74  senderid_t senderId);
75 
76  TimePair decodeTime(const char* packet);
77  void decodeRWRequest(const char* packet,
78  kXR_int32 timestamp,
79  senderid_t senderId);
80  void decodeOpen(const char* packet,
81  kXR_int32 timestamp,
82  senderid_t senderId);
83  void decodeClose(const char* packet,
84  kXR_int32 timestamp,
85  senderid_t senderId);
86  void decodeDisconnect(const char* packet,
87  kXR_int32 timestamp,
88  senderid_t senderId);
89 
90  CalcTime prepareTimestamp(const char* packet,
91  int& offset,
92  int len,
93  kXR_int32& begTime);
94 private:
96  bool _stopNow;
97 
98  kXR_int32 _upToTime; // for decoding parts of log file
99 };
100 
101 #endif /* XRDMONDECPACKETDECODER_HH */