xrootd
XrdMonCtrArchiver.hh
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* */
3 /* XrdMonCtrArchiver.hh */
4 /* */
5 /* (c) 2005 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 XRDMONCTRARCHIVER_HH
14 #define XRDMONCTRARCHIVER_HH
15 
16 #include "XrdMon/XrdMonTypes.hh"
17 #include "pthread.h"
18 #include <vector>
19 using std::vector;
20 
21 class XrdMonCtrPacket;
22 class XrdMonCtrWriter;
24 
25 // Class responsible for archiving packets in log files.
26 // Manages heartbeat for writers (writers inactive for 24 hours
27 // are closed). It does not interpret data inside packet.
28 
29 extern "C" void* decHDFlushHeartBeat(void* arg);
30 extern "C" void* decRTFlushHeartBeat(void* arg);
31 
33 public:
34  XrdMonCtrArchiver(const char* cBaseDir,
35  const char* dBaseDir,
36  const char* rtLogDir,
37  kXR_int64 maxFileSize,
38  int ctrBufSize,
39  int rtBufSize,
40  bool onlineDec,
41  bool rtDec);
43  void operator()();
44 
45  static int _decHDFlushDelay; // number of sec between flushes of decoded
46  // history data to disk
47  static int _decRTFlushDelay; // number of sec between flushes of decoded
48  // "current" data to disk
49 
50 private:
51  void check4InactiveSenders();
53  friend void* decHDFlushHeartBeat(void* arg);
54  friend void* decRTFlushHeartBeat(void* arg);
55 
56 private:
57  enum { TIMESTAMP_FREQ = 10000, // re-take time every X packets
58  MAX_INACTIVITY = 60*60*24 // kill writer if no activity for 24 hours
59  };
60 
61  vector<XrdMonCtrWriter*> _writers;
62 
64  pthread_t _decHDFlushThread; // history data
65  pthread_t _decRTFlushThread; // real time data
66 
68  int _heartbeat; // number of packets since the last time check
69 };
70 
71 #endif /* XRDMONCTRARCHIVER_HH */