FACT++  1.0
DimWriteStatistics.h
Go to the documentation of this file.
1 #ifndef FACT_DimWriteStatistics
2 #define FACT_DimWriteStatistics
3 
4 #include <set>
5 #include <string>
6 
7 // Keep these two together! Otheriwse it won't compile
8 #include <boost/bind.hpp>
9 #if BOOST_VERSION < 104400
10 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))
11 #undef BOOST_HAS_RVALUE_REFS
12 #endif
13 #endif
14 #include <boost/thread.hpp>
15 
16 #include "MessageImp.h"
17 #include "DimDescriptionService.h"
18 
20 {
21 public:
22  struct Stats
23  {
24  uint64_t freeSpace;
25  uint64_t sizeWritten;
26  uint64_t rateWritten;
27  uint64_t timeElapsed;
28 
29  Stats() : freeSpace(0), sizeWritten(0), rateWritten(0), timeElapsed(0) { }
30  };
31 
32 private:
34 
36 
37  std::string fCurrentFolder;
38  uint16_t fUpdateInterval;
39  size_t fBaseSize;
40  std::set<std::string> fOpenedFiles;
41 
43  bool fDebug;
44 
47 
49  boost::thread fThread;
50 
52  void UpdateService();
53 
55  int64_t GetFreeSpace();
56 
58  int64_t GetFileSizeOnDisk(const std::string& file) { return GetFileSizeOnDisk(file, fLog); }
59 
60  int Write(const Time &t, const std::string &txt, int qos);
61 
62 public:
64  DimWriteStatistics(const std::string& serverName, MessageImp &log);
65 
68 
70  bool SetCurrentFolder(const std::string& folder);
71 
72  bool FileOpened(const std::string& fileName);
73 
74  void SetDebugMode(bool);
75  void SetUpdateInterval(const int16_t millisec);
76 
77  const Stats &GetTotalSizeWritten() const { return fStats; }
78  uint16_t GetUpdateInterval() const { return fUpdateInterval; }
79 
81  static int64_t GetFileSizeOnDisk(const std::string& file, MessageImp &imp);
82 
83  static bool DoesPathExist(std::string path, MessageImp &log);
84 };
85 
86 #endif
uint16_t fUpdateInterval
Current folder being watched for free space.
DimWriteStatistics(const std::string &serverName, MessageImp &log)
Constructor.
The base implementation of a distributed messaging system.
Definition: MessageImp.h:10
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
DimDescribedService fDimService
bool FileOpened(const std::string &fileName)
static bool DoesPathExist(std::string path, MessageImp &log)
void SetUpdateInterval(const int16_t millisec)
uint16_t GetUpdateInterval() const
uint16_t qos
Definition: HeadersGPS.h:29
int64_t GetFreeSpace()
Returns the free space on the disk of the folder being watched (fCurrentFolder)
~DimWriteStatistics()
Default destructor.
void UpdateService()
Main loop.
int Write(const Time &t, const std::string &txt, int qos)
Stats fStats
The data structure holding the stat data.
std::set< std::string > fOpenedFiles
Total base size of all opened files.
const Stats & GetTotalSizeWritten() const
provides a statistics service telling the free space on disk and the total size written so far ...
int64_t GetFileSizeOnDisk(const std::string &file)
Returns the size on disk of a given file.
boost::thread fThread
The boost thread used to update the service.
static char * serverName
Definition: feeserver.c:183
bool SetCurrentFolder(const std::string &folder)
Configures that current folder where files are written to.
std::string fCurrentFolder
bool fDebug
List of all opened files. set is used to easily check for entries.
TT t
Definition: test_client.c:26
size_t fBaseSize
Duration, in millisecond between two service updates. 0 means no more updates.