CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FileHandler.h
Go to the documentation of this file.
1 // $Id: FileHandler.h,v 1.21 2012/04/04 12:16:57 mommsen Exp $
3 
4 #ifndef EventFilter_StorageManager_FileHandler_h
5 #define EventFilter_StorageManager_FileHandler_h
6 
12 
13 #include "boost/shared_ptr.hpp"
14 
15 #include <stdint.h>
16 #include <string>
17 #include <sys/types.h>
18 
19 
20 namespace stor {
21 
22  class I2OChain;
23 
33  {
34  public:
35 
37  (
39  const DbFileHandlerPtr,
40  const uint64_t& maxFileSize
41  );
42 
43  virtual ~FileHandler() {};
44 
48  void writeEvent(const I2OChain&);
49 
53  bool tooOld(const utils::TimePoint_t currentTime = utils::getCurrentTime());
54 
58  bool isFromLumiSection(const uint32_t lumiSection);
59 
64  bool tooLarge(const uint64_t& dataSize);
65 
66 
68  // File parameter getters //
70 
74  uint32_t events() const;
75 
79  uint32_t lumiSection() const
80  { return fileRecord_->lumiSection; }
81 
85  uint64_t fileSize() const;
86 
91 
92 
93  protected:
94 
98  virtual void do_writeEvent(const I2OChain& event) = 0;
99 
100 
102  // File bookkeeping //
104 
109  void updateDatabase() const;
110 
111 
116  void insertFileInDatabase() const;
117 
118 
120  // File system interaction //
122 
126  void moveFileToClosed
127  (
129  );
130 
131 
132  private:
133 
138  uint64_t checkFileSizeMatch(const std::string& fileName, const uint64_t& size) const;
139 
143  bool sizeMismatch(const uint64_t& initialSize, const uint64_t& finalSize) const;
144 
148  void makeFileReadOnly(const std::string& fileName) const;
149 
153  void checkAdler32(const std::string& fileName) const;
154 
158  void renameFile(const std::string& openFileName, const std::string& closedFileName) const;
159 
164  void checkDirectories() const;
165 
169  double calcPctDiff(const uint64_t&, const uint64_t&) const;
170 
171 
172  private:
173 
174  //Prevent copying of the FileHandler
175  FileHandler(FileHandler const&);
177 
178 
179  protected:
180 
183 
184  utils::TimePoint_t firstEntry_; // time when first event was writen
185  utils::TimePoint_t lastEntry_; // time when latest event was writen
186 
188 
189  private:
190 
191  const uint64_t maxFileSize_; // maximal file size in bytes
192 
193  const std::string logPath_; // log path
194  const std::string logFile_; // log file including path
195  std::string cmsver_; // CMSSW version string
196  };
197 
198 } // stor namespace
199 
200 #endif // EventFilter_StorageManager_FileHandler_h
201 
202 
TimePoint_t getCurrentTime()
Definition: Utils.h:158
uint64_t fileSize() const
Definition: FileHandler.cc:178
void moveFileToClosed(const FilesMonitorCollection::FileRecord::ClosingReason &)
Definition: FileHandler.cc:190
virtual void closeFile(const FilesMonitorCollection::FileRecord::ClosingReason &)=0
const uint64_t maxFileSize_
Definition: FileHandler.h:191
std::string cmsver_
Definition: FileHandler.h:195
virtual ~FileHandler()
Definition: FileHandler.h:43
void insertFileInDatabase() const
Definition: FileHandler.cc:100
boost::shared_ptr< FileRecord > FileRecordPtr
utils::TimePoint_t firstEntry_
Definition: FileHandler.h:184
const std::string logFile_
Definition: FileHandler.h:194
bool sizeMismatch(const uint64_t &initialSize, const uint64_t &finalSize) const
Definition: FileHandler.cc:252
boost::shared_ptr< DbFileHandler > DbFileHandlerPtr
Definition: DbFileHandler.h:71
const std::string logPath_
Definition: FileHandler.h:193
FileHandler(FilesMonitorCollection::FileRecordPtr, const DbFileHandlerPtr, const uint64_t &maxFileSize)
Definition: FileHandler.cc:26
utils::TimePoint_t lastEntry_
Definition: FileHandler.h:185
void updateDatabase() const
Definition: FileHandler.cc:70
boost::posix_time::ptime TimePoint_t
Definition: Utils.h:35
void writeEvent(const I2OChain &)
Definition: FileHandler.cc:47
const DiskWritingParams & diskWritingParams_
Definition: FileHandler.h:187
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void makeFileReadOnly(const std::string &fileName) const
Definition: FileHandler.cc:259
FileHandler & operator=(FileHandler const &)
bool tooOld(const utils::TimePoint_t currentTime=utils::getCurrentTime())
Definition: FileHandler.cc:129
void renameFile(const std::string &openFileName, const std::string &closedFileName) const
Definition: FileHandler.cc:314
unsigned long long uint64_t
Definition: Time.h:15
virtual void do_writeEvent(const I2OChain &event)=0
FilesMonitorCollection::FileRecordPtr fileRecord_
Definition: FileHandler.h:181
uint32_t lumiSection() const
Definition: FileHandler.h:79
uint64_t checkFileSizeMatch(const std::string &fileName, const uint64_t &size) const
Definition: FileHandler.cc:216
void checkDirectories() const
Definition: FileHandler.cc:330
bool tooLarge(const uint64_t &dataSize)
Definition: FileHandler.cc:158
const DbFileHandlerPtr dbFileHandler_
Definition: FileHandler.h:182
tuple size
Write out results.
double calcPctDiff(const uint64_t &, const uint64_t &) const
Definition: FileHandler.cc:339
bool isFromLumiSection(const uint32_t lumiSection)
Definition: FileHandler.cc:144
void checkAdler32(const std::string &fileName) const
Definition: FileHandler.cc:271
uint32_t events() const
Definition: FileHandler.cc:172