#include <FileHandler.h>
Public Member Functions | |
virtual void | closeFile (const FilesMonitorCollection::FileRecord::ClosingReason &)=0 |
uint32_t | events () const |
FileHandler (FilesMonitorCollection::FileRecordPtr, const DbFileHandlerPtr, const uint64_t &maxFileSize) | |
uint64_t | fileSize () const |
bool | isFromLumiSection (const uint32_t lumiSection) |
uint32_t | lumiSection () const |
bool | tooLarge (const uint64_t &dataSize) |
bool | tooOld (const utils::TimePoint_t currentTime=utils::getCurrentTime()) |
void | writeEvent (const I2OChain &) |
virtual | ~FileHandler () |
Protected Member Functions | |
virtual void | do_writeEvent (const I2OChain &event)=0 |
void | insertFileInDatabase () const |
void | moveFileToClosed (const FilesMonitorCollection::FileRecord::ClosingReason &) |
void | updateDatabase () const |
Protected Attributes | |
const DbFileHandlerPtr | dbFileHandler_ |
const DiskWritingParams & | diskWritingParams_ |
FilesMonitorCollection::FileRecordPtr | fileRecord_ |
utils::TimePoint_t | firstEntry_ |
utils::TimePoint_t | lastEntry_ |
Private Member Functions | |
double | calcPctDiff (const uint64_t &, const uint64_t &) const |
void | checkAdler32 (const std::string &fileName) const |
void | checkDirectories () const |
uint64_t | checkFileSizeMatch (const std::string &fileName, const uint64_t &size) const |
FileHandler (FileHandler const &) | |
void | makeFileReadOnly (const std::string &fileName) const |
FileHandler & | operator= (FileHandler const &) |
void | renameFile (const std::string &openFileName, const std::string &closedFileName) const |
bool | sizeMismatch (const uint64_t &initialSize, const uint64_t &finalSize) const |
Private Attributes | |
std::string | cmsver_ |
const std::string | logFile_ |
const std::string | logPath_ |
const uint64_t | maxFileSize_ |
Abstract representation of a physical file
Definition at line 32 of file FileHandler.h.
stor::FileHandler::FileHandler | ( | FilesMonitorCollection::FileRecordPtr | fileRecord, |
const DbFileHandlerPtr | dbFileHandler, | ||
const uint64_t & | maxFileSize | ||
) |
Definition at line 26 of file FileHandler.cc.
|
inlinevirtual |
Definition at line 43 of file FileHandler.h.
|
private |
|
private |
Return the relative difference btw to file sizes
Definition at line 339 of file FileHandler.cc.
Referenced by sizeMismatch().
|
private |
Compare Adler32 checksum of file with calculated one
Definition at line 271 of file FileHandler.cc.
References a, cms::Adler32(), b, stor::DiskWritingParams::checkAdler32_, diskWritingParams_, mergeVDriftHistosByStation::file, fileRecord_, recoMuon::in, lumiQueryAPI::msg, and findQualityFiles::size.
|
private |
Check if all directories needed for the file output are available. Throws a stor::execption::NoSuchDirectory when a directory does not exist.
Definition at line 330 of file FileHandler.cc.
References stor::utils::checkDirectory(), diskWritingParams_, stor::DiskWritingParams::filePath_, and fileRecord_.
|
private |
Check that the file size matches the given size. Returns the actual size.
Definition at line 216 of file FileHandler.cc.
References fileRecord_, stor::FilesMonitorCollection::FileRecord::inaccessible, lumiQueryAPI::msg, sizeMismatch(), and stor::FilesMonitorCollection::FileRecord::truncated.
|
pure virtual |
Close the file
Implemented in stor::EventFileHandler, and stor::FRDFileHandler.
Referenced by isFromLumiSection(), Vispa.Main.Application.Application::tabCloseRequest(), tooLarge(), and tooOld().
|
protectedpure virtual |
Write the I2OChain to the file
Implemented in stor::EventFileHandler, and stor::FRDFileHandler.
Referenced by writeEvent().
uint32_t stor::FileHandler::events | ( | ) | const |
Return the number of events in the file
Definition at line 172 of file FileHandler.cc.
References fileRecord_.
Referenced by insertFileInDatabase(), tooLarge(), and updateDatabase().
uint64_t stor::FileHandler::fileSize | ( | ) | const |
Return the size of the file in bytes
Definition at line 178 of file FileHandler.cc.
References fileRecord_.
Referenced by insertFileInDatabase(), tooLarge(), and updateDatabase().
|
protected |
Write command to insert a new file into the CMS_STOMGR.TIER0_INJECTION table into the logFile_.
Definition at line 100 of file FileHandler.cc.
References cmsver_, dbFileHandler_, diskWritingParams_, events(), fileRecord_, fileSize(), firstEntry_, stor::DiskWritingParams::hostName_, stor::DiskWritingParams::initialSafetyLevel_, stor::utils::secondsSinceEpoch(), stor::DiskWritingParams::setupLabel_, and stor::DiskWritingParams::smInstanceString_.
bool stor::FileHandler::isFromLumiSection | ( | const uint32_t | lumiSection | ) |
Returns true if the file corresponds to the given lumi section
Definition at line 144 of file FileHandler.cc.
References closeFile(), fileRecord_, and stor::FilesMonitorCollection::FileRecord::LSended.
Referenced by stor::StreamHandler::closeFilesForLumiSection().
|
inline |
Return the luminosity section the file belongs to
Definition at line 79 of file FileHandler.h.
References fileRecord_.
|
private |
Changes the file permissions to read-only
Definition at line 259 of file FileHandler.cc.
References lumiQueryAPI::msg.
|
protected |
Move index and streamer file to "closed" directory
Definition at line 190 of file FileHandler.cc.
References stor::FilesMonitorCollection::FileRecord::closed, alignCSCRings::e, stor::FilesMonitorCollection::FileRecord::open, Association::reason, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by stor::FRDFileHandler::closeFile(), and stor::EventFileHandler::closeFile().
|
private |
|
private |
Rename the file
Definition at line 314 of file FileHandler.cc.
References lumiQueryAPI::msg, stor::FilesMonitorCollection::FileRecord::notClosed, and query::result.
|
private |
Check that the 2 sizes agree
Definition at line 252 of file FileHandler.cc.
References calcPctDiff(), diskWritingParams_, and stor::DiskWritingParams::fileSizeTolerance_.
Referenced by checkFileSizeMatch().
bool stor::FileHandler::tooLarge | ( | const uint64_t & | dataSize | ) |
Returns true if the additional data size would push the file size beyond maxFileSize.
Definition at line 158 of file FileHandler.cc.
References closeFile(), events(), fileSize(), maxFileSize_, and stor::FilesMonitorCollection::FileRecord::size.
bool stor::FileHandler::tooOld | ( | const utils::TimePoint_t | currentTime = utils::getCurrentTime() | ) |
Returns true if the file has not seen any recent events
Definition at line 129 of file FileHandler.cc.
References closeFile(), diskWritingParams_, lastEntry_, stor::DiskWritingParams::lumiSectionTimeOut_, seconds(), and stor::FilesMonitorCollection::FileRecord::timeout.
Referenced by stor::StreamHandler::closeTimedOutFiles().
|
protected |
Write command to update the file information in the CMS_STOMGR.TIER0_INJECTION table into the logFile_.
Definition at line 70 of file FileHandler.cc.
References cmsver_, dbFileHandler_, diskWritingParams_, events(), fileRecord_, fileSize(), firstEntry_, stor::DiskWritingParams::hostName_, stor::DiskWritingParams::initialSafetyLevel_, lastEntry_, stor::utils::secondsSinceEpoch(), stor::DiskWritingParams::setupLabel_, and stor::DiskWritingParams::smInstanceString_.
Referenced by stor::FRDFileHandler::closeFile(), and stor::EventFileHandler::closeFile().
void stor::FileHandler::writeEvent | ( | const I2OChain & | event | ) |
Write the event contained in the I2OChain
Definition at line 47 of file FileHandler.cc.
References do_writeEvent(), fileRecord_, stor::utils::getCurrentTime(), lastEntry_, and lumiQueryAPI::msg.
|
private |
Definition at line 195 of file FileHandler.h.
Referenced by insertFileInDatabase(), and updateDatabase().
|
protected |
Definition at line 182 of file FileHandler.h.
Referenced by insertFileInDatabase(), and updateDatabase().
|
protected |
Definition at line 187 of file FileHandler.h.
Referenced by checkAdler32(), checkDirectories(), insertFileInDatabase(), sizeMismatch(), tooOld(), and updateDatabase().
|
protected |
Definition at line 181 of file FileHandler.h.
Referenced by checkAdler32(), checkDirectories(), checkFileSizeMatch(), stor::FRDFileHandler::closeFile(), stor::EventFileHandler::closeFile(), events(), fileSize(), insertFileInDatabase(), isFromLumiSection(), lumiSection(), updateDatabase(), writeEvent(), and stor::EventFileHandler::writeHeader().
|
protected |
Definition at line 184 of file FileHandler.h.
Referenced by insertFileInDatabase(), and updateDatabase().
|
protected |
Definition at line 185 of file FileHandler.h.
Referenced by tooOld(), updateDatabase(), writeEvent(), and stor::EventFileHandler::writeHeader().
|
private |
Definition at line 194 of file FileHandler.h.
|
private |
Definition at line 193 of file FileHandler.h.
|
private |
Definition at line 191 of file FileHandler.h.
Referenced by tooLarge().