20#include <boost/functional/hash.hpp>
36 testInvariant ()
const
43 DiskWriterXRD (
const std::string& val_path)
48 const char *tmpdir = getenv (
"TMPDIR");
50 boost::hash_combine (hash, std::hash<pid_t>() (getpid()));
51 std::size_t tries = 0;
55 throw std::runtime_error (
"infinite loop trying to create tempory file for DiskWriterXRD");
57 auto time = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
58 boost::hash_combine (hash, std::hash<
decltype(time)>() (time));
59 std::size_t hash16 {hash};
60 while (hash16 > 0xffff)
61 hash16 = (hash16&0xffff) ^ (hash16 >> 16);
63 std::ostringstream
str;
69 <<
"-" << std::format(
"{:04x}", hash16);
71 if (gSystem->AccessPathName (
m_tmp.c_str()) != 0)
72 m_file.reset (TFile::Open (
m_tmp.c_str(),
"CREATE"));
90 }
catch (std::exception& e)
92 std::cerr <<
"exception closing file " <<
m_path <<
": "
93 << e.what() << std::endl;
97 std::cerr <<
"unknown exception closing file " <<
m_path << std::endl;
104 std::string DiskWriterXRD ::
113 TFile *DiskWriterXRD ::
123 void DiskWriterXRD ::
136 std::random_device rd;
137 std::mt19937 gen (rd());
138 bool success =
false;
153 std::cerr <<
"encountered error copying files to XRD path: \"" <<
m_path <<
"\"" << std::endl;
161 unsigned seconds = std::uniform_int_distribution<>(30,60) (gen);
162 std::cerr <<
"sleeping for " << seconds <<
" seconds before retrying" << std::endl;
163 std::this_thread::sleep_for (std::chrono::seconds(seconds));
166 std::cerr <<
"giving up, leaving file at " <<
m_tmp << std::endl;
167 throw std::runtime_error (
"failed to copy file to XRD");
#define RCU_DESTROY_INVARIANT(x)
#define RCU_CHANGE_INVARIANT(x)
#define RCU_REQUIRE2_SOFT(x, y)
#define RCU_NEW_INVARIANT(x)
#define RCU_READ_INVARIANT(x)
#define RCU_THROW_MSG(message)
std::string m_tmp
the temporary path being used
std::string m_path
the path being used
std::unique_ptr< TFile > m_file
the actual file object
void close()
closes the file we are writing to
void exec(const std::string &cmd)
effects: execute the given command guarantee: strong failures: out of memory II failures: system fail...
std::string quote(const std::string &name)
effects: quote the given name to protect it from the shell returns: the quoted name guarantee: strong...
This module provides a lot of global definitions, forward declarations and includes that are used by ...