Skip to content
Snippets Groups Projects
Commit bade57e7 authored by Giovanna Lazzari Miotto's avatar Giovanna Lazzari Miotto :mushroom:
Browse files

cleanup

parent 956c3bee
No related branches found
No related tags found
No related merge requests found
......@@ -22,18 +22,6 @@ namespace fs = std::filesystem;
class OutputFile {
public:
// OutputFile(FILE* filePtr, std::string fileName, FRDFileHeader_v2 fileHeader, uint32_t
// lumisection,
// uint32_t index, std::string rundir)
// : filePtr_(filePtr),
// fileName_(fileName),
// fileHeader_(fileHeader),
// lumisection_(lumisection),
// index_(index),
// rundir_(rundir) {}
// OutputFile() : filePtr_(NULL), fileName_(""), fileHeader_(0, 0, 0, 0, 0, 0) {}
OutputFile(std::string_view filepath, std::string_view filename, std::string_view run_dir,
FRDFileHeader_v2 header, uint32_t num_lumisection, uint32_t file_index)
: filepath_(filepath),
......@@ -43,18 +31,14 @@ class OutputFile {
lumisection_(num_lumisection),
index_(file_index) {
try {
LOG(FATAL) << "Attempting open file: '" << filepath_ << "'";
file_.open(filepath_, std::ios_base::out | std::ios_base::binary);
if (!file_.is_open()) {
LOG(FATAL) << "Could not open file: '" << filepath_ << "'";
}
} catch (std::exception& e) {
LOG(FATAL) << "Could not open file: '" << filepath_ << "', exception: " << e.what();
} catch (const fstream::failure& e) {
LOG(FATAL) << "Exception opening file" << filepath_ << "', exception: " << e.what();
}
}
OutputFile(const OutputFile&) = delete; // Delete copy constructor
OutputFile& operator=(const OutputFile&) = delete; // Delete copy assignment operator
OutputFile(const OutputFile&) = delete;
OutputFile& operator=(const OutputFile&) = delete;
OutputFile(OutputFile&& other) noexcept
: filepath_(std::move(other.filepath_)),
......@@ -94,15 +78,13 @@ class OutputFile {
file_.seekp(pos, std::ios::beg); // Move write position
}
bool exists() { return file_.is_open(); }
std::string GetFullPath() const { return filepath_; }
void Rename(const std::string& new_path) {
fs::path from = GetFullPath();
fs::path to = new_path;
LOG(FATAL) << "Renaming from '" << from << "' to '" << to << "' now.";
LOG(TRACE) << "Renaming from '" << from << "' to '" << to << "' now.";
try {
fs::rename(from, to);
......
......@@ -19,11 +19,6 @@ tbb::concurrent_bounded_queue<std::shared_ptr<OutputFile>> OutputFileHandler::fi
std::atomic<bool> OutputFileHandler::file_handler_running_{true};
void OutputFileHandler::enqueue_current_file_for_close_and_move_maybe() {
LOG(FATAL) << "____ Enqueue called.";
LOG(FATAL) << "____ Is outputFile? " << (outputFile_ != nullptr);
if (outputFile_) LOG(FATAL) << "____ Does outputFile exist()? " << (outputFile_->exists());
if (outputFile_ && outputFile_->exists()) {
LOG(TRACE) << "queueing file: " << outputFile_->getFileName() << " for closing, queue size now "
<< files_to_close_.size();
......@@ -64,10 +59,10 @@ std::shared_ptr<OutputFile>& OutputFileHandler::getFile(uint32_t run, uint32_t i
enqueue_current_file_for_close_and_move_maybe();
if (is_new_run) {
run_NOrbits_ = 0;
LOG(FATAL) << "Previous run: " << current_run_number_ << " | New run: " << run;
LOG(TRACE) << "Previous run: " << current_run_number_ << " | New run: " << run;
}
if (is_new_index) {
LOG(FATAL) << "Previous index: " << current_index_ << " | New index: " << index;
LOG(TRACE) << "Previous index: " << current_index_ << " | New index: " << index;
}
current_index_ = static_cast<int>(index);
......@@ -182,11 +177,6 @@ void OutputFileHandler::close_and_rename::operator()() const {
std::string permanent_path(outputFile->getRunDir() + "/" + outputFile->getFileName());
outputFile->Rename(permanent_path);
// std::string from = outputFile->getRunDir() + "/" + working_dir_ + "/" +
// outputFile.getFileName(); std::string to = outputFile->getRunDir() + "/" +
// outputFile.getFileName(); if (rename(from.c_str(), to.c_str()) != 0) {
// LOG(ERROR) << tools::strerror("File rename of " + outputFile.getFileName() + " failed");
// }
if (outputFile->Index() == outputfilehandler_->max_index_per_ls_ &&
outputfilehandler_->getCMSSWHeaders()) { // end of lumisection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment