source: trunk/FACT++/src/DimWriteStatistics.h@ 19102

Last change on this file since 19102 was 17343, checked in by tbretz, 11 years ago
Removed DimWriteStatistics::CreateDirectory - can be replaced by boost::filesystem::create_directories (we loose the ability to set permissions explicitly, but linux users are used to get inherited permission for directory creation anyway
File size: 2.5 KB
Line 
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
19class DimWriteStatistics
20{
21public:
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
32private:
33 MessageImp &fLog;
34
35 DimDescribedService fDimService;
36
37 std::string fCurrentFolder; /// Current folder being watched for free space
38 uint16_t fUpdateInterval; /// Duration, in millisecond between two service updates. 0 means no more updates
39 size_t fBaseSize; /// Total base size of all opened files
40 std::set<std::string> fOpenedFiles; /// List of all opened files. set is used to easily check for entries
41
42 /// Bool indicating if debug information should be printed
43 bool fDebug;
44
45 /// The data structure holding the stat data
46 Stats fStats;
47
48 /// The boost thread used to update the service
49 boost::thread fThread;
50
51 ///Main loop
52 void UpdateService();
53
54 ///Returns the free space on the disk of the folder being watched (fCurrentFolder)
55 int64_t GetFreeSpace();
56
57 ///Returns the size on disk of a given file
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
62public:
63 ///Constructor
64 DimWriteStatistics(const std::string& serverName, MessageImp &log);
65
66 ///Default destructor
67 ~DimWriteStatistics();
68
69 ///Configures that current folder where files are written to
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
80 ///Returns the size on disk of a given file
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
Note: See TracBrowser for help on using the repository browser.