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.19 2011/07/05 13:25:43 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 DiskWritingParams&,
41  const uint64_t& maxFileSize
42  );
43 
44  virtual ~FileHandler() {};
45 
49  void writeEvent(const I2OChain&);
50 
54  bool tooOld(const utils::TimePoint_t currentTime = utils::getCurrentTime());
55 
59  bool isFromLumiSection(const uint32_t lumiSection);
60 
65  bool tooLarge(const uint64_t& dataSize);
66 
67 
69  // File parameter getters //
71 
75  uint32_t events() const;
76 
80  uint32_t lumiSection() const
81  { return fileRecord_->lumiSection; }
82 
86  uint64_t fileSize() const;
87 
92 
93 
94  protected:
95 
99  virtual void do_writeEvent(const I2OChain& event) = 0;
100 
101 
103  // File bookkeeping //
105 
110  void updateDatabase() const;
111 
112 
117  void insertFileInDatabase() const;
118 
119 
121  // File system interaction //
123 
127  void moveFileToClosed
128  (
130  );
131 
132 
133  private:
134 
139  uint64_t checkFileSizeMatch(const std::string& fileName, const uint64_t& size) const;
140 
144  bool sizeMismatch(const uint64_t& initialSize, const uint64_t& finalSize) const;
145 
149  void makeFileReadOnly(const std::string& fileName) const;
150 
154  void checkAdler32(const std::string& fileName) const;
155 
159  void renameFile(const std::string& openFileName, const std::string& closedFileName) const;
160 
165  void checkDirectories() const;
166 
170  std::string logFile(const DiskWritingParams&) const;
171 
175  double calcPctDiff(const uint64_t&, const uint64_t&) const;
176 
177 
178  private:
179 
180  //Prevent copying of the FileHandler
181  FileHandler(FileHandler const&);
183 
184 
185  protected:
186 
189 
190  utils::TimePoint_t firstEntry_; // time when first event was writen
191  utils::TimePoint_t lastEntry_; // time when latest event was writen
192 
194 
195  private:
196 
197  const uint64_t maxFileSize_; // maximal file size in bytes
198 
199  const std::string logPath_; // log path
200  const std::string logFile_; // log file including path
201  std::string cmsver_; // CMSSW version string
202  };
203 
204 } // stor namespace
205 
206 #endif // EventFilter_StorageManager_FileHandler_h
207 
208 
TimePoint_t getCurrentTime()
Definition: Utils.h:158
uint64_t fileSize() const
Definition: FileHandler.cc:181
void moveFileToClosed(const FilesMonitorCollection::FileRecord::ClosingReason &)
Definition: FileHandler.cc:193
virtual void closeFile(const FilesMonitorCollection::FileRecord::ClosingReason &)=0
const uint64_t maxFileSize_
Definition: FileHandler.h:197
FileHandler(FilesMonitorCollection::FileRecordPtr, const DbFileHandlerPtr, const DiskWritingParams &, const uint64_t &maxFileSize)
Definition: FileHandler.cc:26
std::string cmsver_
Definition: FileHandler.h:201
virtual ~FileHandler()
Definition: FileHandler.h:44
void insertFileInDatabase() const
Definition: FileHandler.cc:102
boost::shared_ptr< FileRecord > FileRecordPtr
utils::TimePoint_t firstEntry_
Definition: FileHandler.h:190
const std::string logFile_
Definition: FileHandler.h:200
bool sizeMismatch(const uint64_t &initialSize, const uint64_t &finalSize) const
Definition: FileHandler.cc:255
boost::shared_ptr< DbFileHandler > DbFileHandlerPtr
Definition: DbFileHandler.h:65
const std::string logPath_
Definition: FileHandler.h:199
utils::TimePoint_t lastEntry_
Definition: FileHandler.h:191
void updateDatabase() const
Definition: FileHandler.cc:71
boost::posix_time::ptime TimePoint_t
Definition: Utils.h:35
void writeEvent(const I2OChain &)
Definition: FileHandler.cc:48
const DiskWritingParams & diskWritingParams_
Definition: FileHandler.h:193
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:262
FileHandler & operator=(FileHandler const &)
bool tooOld(const utils::TimePoint_t currentTime=utils::getCurrentTime())
Definition: FileHandler.cc:132
void renameFile(const std::string &openFileName, const std::string &closedFileName) const
Definition: FileHandler.cc:317
unsigned long long uint64_t
Definition: Time.h:15
virtual void do_writeEvent(const I2OChain &event)=0
FilesMonitorCollection::FileRecordPtr fileRecord_
Definition: FileHandler.h:187
uint32_t lumiSection() const
Definition: FileHandler.h:80
uint64_t checkFileSizeMatch(const std::string &fileName, const uint64_t &size) const
Definition: FileHandler.cc:219
void checkDirectories() const
Definition: FileHandler.cc:333
std::string logFile(const DiskWritingParams &) const
bool tooLarge(const uint64_t &dataSize)
Definition: FileHandler.cc:161
const DbFileHandlerPtr dbFileHandler_
Definition: FileHandler.h:188
tuple size
Write out results.
double calcPctDiff(const uint64_t &, const uint64_t &) const
Definition: FileHandler.cc:342
bool isFromLumiSection(const uint32_t lumiSection)
Definition: FileHandler.cc:147
void checkAdler32(const std::string &fileName) const
Definition: FileHandler.cc:274
uint32_t events() const
Definition: FileHandler.cc:175