29 fileRecord_(fileRecord),
30 dbFileHandler_(dbFileHandler),
32 lastEntry_(firstEntry_),
33 diskWritingParams_(dwParams),
34 maxFileSize_(maxFileSize),
39 if(cmsver_[0]==
'"') cmsver_=cmsver_.substr(1,cmsver_.size()-2);
43 insertFileInDatabase();
50 std::ostringstream
msg;
51 msg <<
"Tried to write an event to "
53 <<
"which has already been closed.";
54 XCEPT_RAISE(stor::exception::DiskWriting, msg.str());
71 std::ostringstream currentStat;
81 std::string currentStatString (currentStat.str());
83 of << currentStatString;
90 std::ostringstream oss;
91 oss <<
"./closeFile.pl "
94 <<
" --NEVENTS " <<
events()
98 <<
" --STATUS " <<
"closed"
108 <<
" --APPNAME CMSSW"
109 <<
" --TYPE streamer"
111 <<
" --CHECKSUM " << std::hex <<
adler_
112 <<
" --CHECKSUMIND " << std::hex << 0
121 std::ostringstream oss;
122 oss <<
"./insertFile.pl "
125 <<
" --NEVENTS " <<
events()
139 <<
" --APPNAME CMSSW"
140 <<
" --TYPE streamer"
142 <<
" --CHECKSUMIND 0"
217 const uint64_t openFileSize = checkFileSizeMatch(openFileName, fileSize());
219 makeFileReadOnly(openFileName);
222 renameFile(openFileName, closedFileName);
224 catch (stor::exception::DiskWriting&
e)
226 XCEPT_RETHROW(stor::exception::DiskWriting,
227 "Could not move streamer file to closed area.", e);
229 fileRecord_->isOpen =
false;
230 fileRecord_->whyClosed =
reason;
231 checkFileSizeMatch(closedFileName, openFileSize);
238 struct stat64 statBuff;
239 int statStatus = stat64(fileName.c_str(), &statBuff);
241 struct stat statBuff;
242 int statStatus = stat(fileName.c_str(), &statBuff);
244 if ( statStatus != 0 )
247 std::ostringstream
msg;
248 msg <<
"Error checking the status of file "
250 <<
": " << strerror(errno);
251 XCEPT_RAISE(stor::exception::DiskWriting, msg.str());
257 std::ostringstream
msg;
258 msg <<
"Found an unexpected file size when trying to move"
259 <<
" the file to the closed state. File " << fileName
260 <<
" has an actual size of " << statBuff.st_size
261 <<
" (" << statBuff.st_blocks <<
" blocks)"
262 <<
" instead of the expected size of " << size
263 <<
" (" << (size/512)+1 <<
" blocks).";
264 XCEPT_RAISE(stor::exception::FileTruncation, msg.str());
267 return static_cast<uint64_t>(statBuff.st_size);
273 double pctDiff =
calcPctDiff(initialSize, finalSize);
280 int ronly = chmod(fileName.c_str(), S_IREAD|S_IRGRP|S_IROTH);
282 std::ostringstream
msg;
283 msg <<
"Unable to change permissions of " << fileName
284 <<
" to read only: " << strerror(errno);
285 XCEPT_RAISE(stor::exception::DiskWriting, msg.str());
292 const std::string& openFileName,
293 const std::string& closedFileName
296 int result = rename( openFileName.c_str(), closedFileName.c_str() );
299 std::ostringstream
msg;
300 msg <<
"Unable to move " << openFileName <<
" to "
301 << closedFileName <<
": " << strerror(errno);
302 XCEPT_RAISE(stor::exception::DiskWriting, msg.str());
318 if (value1 == value2)
return 0;
321 return ( largerValue > 0 ? (largerValue - smallerValue) / largerValue : 0 );
TimePoint_t getCurrentTime()
uint64_t fileSize() const
void moveFileToClosed(const FilesMonitorCollection::FileRecord::ClosingReason &)
virtual void closeFile(const FilesMonitorCollection::FileRecord::ClosingReason &)=0
utils::Duration_t lumiSectionTimeOut_
double fileSizeTolerance_
const uint64_t maxFileSize_
FileHandler(FilesMonitorCollection::FileRecordPtr, const DbFileHandlerPtr, const DiskWritingParams &, const uint64_t &maxFileSize)
std::string smInstanceString_
void insertFileInDatabase() const
boost::shared_ptr< FileRecord > FileRecordPtr
long secondsSinceEpoch(TimePoint_t const &)
utils::TimePoint_t firstEntry_
const T & max(const T &a, const T &b)
bool sizeMismatch(const uint64_t &initialSize, const uint64_t &finalSize) const
boost::shared_ptr< DbFileHandler > DbFileHandlerPtr
utils::TimePoint_t lastEntry_
void updateDatabase() const
boost::posix_time::ptime TimePoint_t
void writeEvent(const I2OChain &)
const DiskWritingParams & diskWritingParams_
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 checkDirectory(const std::string &)
void makeFileReadOnly(const std::string &fileName) const
bool tooOld(const utils::TimePoint_t currentTime=utils::getCurrentTime())
void renameFile(const std::string &openFileName, const std::string &closedFileName) const
std::string getReleaseVersion()
unsigned long long uint64_t
virtual void do_writeEvent(const I2OChain &event)=0
FilesMonitorCollection::FileRecordPtr fileRecord_
uint64_t checkFileSizeMatch(const std::string &fileName, const uint64_t &size) const
void checkDirectories() const
bool tooLarge(const uint64_t &dataSize)
const DbFileHandlerPtr dbFileHandler_
tuple size
Write out results.
double calcPctDiff(const uint64_t &, const uint64_t &) const
void writeToSummaryCatalog() const
bool isFromLumiSection(const uint32_t lumiSection)
std::string timeStamp(TimePoint_t)