13#include <TTimeStamp.h>
58 const char* fractionString =
59 gSystem->Getenv(
"XAOD_ACCESSTRACER_FRACTION" );
60 if( fractionString ) {
62 const Double_t fraction = strtod( fractionString, &endptr );
63 if( endptr != fractionString ) {
71 ::TRandom rng( ::TTimeStamp().GetNanoSec() );
86 ::Info(
"xAOD::TFileAccessTracer",
90 ::TString hdr =
"POST /";
95 hdr += gSystem->HostName();
97 hdr +=
"User-Agent: xAODRootAccess\r\n";
98 hdr +=
"Content-Type: application/json\r\n";
99 hdr +=
"Content-Length: ";
109 pld +=
"\"accessedFiles\": [";
116 pld += info.fullFilePath();
124 pld +=
"\"accessedContainers\": [";
126 for(
const auto& bs :
m_readStats->containers() ) {
127 if( ! bs.second.readEntries() ) {
134 pld += bs.second.GetName();
136 pld += bs.second.readEntries();
144 pld +=
"\"accessedBranches\": [";
146 for(
const auto& branch :
m_readStats->branches() ) {
155 pld += bs->GetName();
167 const char* pandaID = gSystem->Getenv(
"PandaID" );
169 pld +=
", \"PandaID\": ";
173 const char* taskID = gSystem->Getenv(
"PanDA_TaskID" );
175 pld +=
", \"PanDA_TaskID\": ";
182 pld +=
", \"ROOT_RELEASE\": \"";
185 pld +=
", \"ReportRate\": ";
190 pld +=
", \"ReadCalls\": ";
192 pld +=
", \"ReadSize\": ";
195 pld +=
", \"CacheSize\": ";
201 hdr += TString::Format(
"%i", pld.Length() );
203 const ::TString
msg = hdr + pld;
212 if( ! socket.
send(
msg ).isSuccess() ) {
226 std::lock_guard< std::mutex > lock(
m_mutex );
231 gSystem->BaseName(
file.GetName() ) } );
240 std::lock_guard< std::mutex > lock(
m_mutex );
248 std::lock_guard< std::mutex > lock(
m_mutex );
262 std::lock_guard< std::mutex > lock(
m_mutex );
270 std::lock_guard< std::mutex > lock(
m_mutex );
Class describing the access statistics of one (sub-)branch.
::Long64_t readEntries() const
Get how many entries were read from this branch.
Singleton object holding on to the process's I/O statistics.
Helper class storing information about the accessed files.
::TString filePath
The full path to the file.
::TString fileName
The name of the file.
::TString fullFilePath() const
Function returning the full file path.
bool operator<(const AccessedFile &rhs) const
Operator to be able to put this into an std::set.
void add(const ::TFile &file)
Add information about a new file that got accessed.
void setMonitoredFraction(::Double_t value)
Set the fraction of jobs that should send monitoring information.
::Double_t monitoredFraction() const
Fraction of jobs that should send monitoring information.
const std::string & serverAddress() const
The address of the server that information is sent to.
::Double_t m_monitoredFraction
Fraction of jobs that should send monitoring information.
~TFileAccessTracer()
Destructor.
ReadStats * m_readStats
Object describing the job's xAOD access statistics.
std::mutex m_mutex
Mutex for modifying the object.
::TInetAddress m_serverInetAddress
Technical address of the server.
static void enableDataSubmission(::Bool_t value)
Function for turning data submission on/off.
TFileAccessTracer()
Default constructor.
void setServerAddress(const std::string &addr)
Set the address of the server that information is sent to.
std::set< AccessedFile > m_accessedFiles
List of all the input files that were accessed in the job.
std::string m_serverAddress
Address of the server to send monitoring information to.
Very simple wrapper around POSIX sockets.
StatusCode send(const TString &payload)
Function sending a message to the connected address.
StatusCode connect(const TInetAddress &address, int port)
Function connecting to the specified address.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
static std::atomic_bool s_enableDataSumbission(true)