| The Gaudi Framework v32r1 (f65d50dc)

JobHistory.cpp
Go to the documentation of this file.
1 //
3 // GaudiHistory/JobHistory.cpp
4 //
5 // Contains history information for a job. Imports all environment vars
6 // and info from uname
7 //
8 //
9 // @author: Charles Leggett
10 //
12
13 #include "GaudiKernel/JobHistory.h"
14 #include "GaudiKernel/Property.h"
15 #include "GaudiKernel/System.h"
16
17 #include <cstdlib>
18 #include <iostream>
19
20 using std::endl;
21 using std::ostream;
22 using std::string;
23 using std::vector;
24
25 using Gaudi::Details::PropertyBase;
26
27 //**********************************************************************
28 // Member functions.
29 //**********************************************************************
30
31 // Constructor.
32
33 JobHistory::JobHistory() : m_start_time( 0 ) {
34
35 time( &m_start_time );
36
37 std::string rel;
38
39 if ( ( rel = System::getEnv( "ATLAS_BASE_RELEASE" ) ) != "UNKNOWN" ) {
40 m_release_version = rel;
41 } else if ( ( rel = System::getEnv( "GAUDIROOT" ) ) != "UNKNOWN" ) {
42 m_release_version = rel;
43 } else {
44 m_release_version = "UNKNOWN";
45 }
46 m_dir = System::getEnv( "PWD" );
47 m_cmtconfig = System::getEnv( "CMTCONFIG" );
48
49 m_osname = System::osName();
50 m_hostname = System::hostName();
51 m_os_version = System::osVersion();
52 m_machine = System::machineType();
53
54 m_environ = System::getEnv();
55 }
56
57 JobHistory::JobHistory( const std::string& rel, const std::string& os, const std::string& host, const std::string& dir,
58 const std::string& osver, const std::string& mach, const std::string& cmtconfig,
59 const time_t& time )
60 : m_release_version( rel )
61 , m_dir( dir )
62 , m_cmtconfig( cmtconfig )
63 , m_osname( os )
64 , m_hostname( host )
65 , m_os_version( osver )
66 , m_machine( mach )
67 , m_start_time( time ) {}
68
69 //**********************************************************************
70
71 // Destructor.
72
73 JobHistory::~JobHistory() = default;
74
75 const CLID& JobHistory::classID() {
76
77 static const CLID CLID_JobHistory = 247994533;
78 return CLID_JobHistory;
79 }
80
81 void JobHistory::addProperty( const std::string& client, const PropertyBase* prop ) {
82 // if (m_props.find(prop) == m_props.end())
83 m_ppl.emplace_back( client, prop );
84 }
85
86 void JobHistory::dump( std::ostream& ost, const bool isXML, int /*ind*/ ) const {
87
88 if ( !isXML ) {
89 ost << "Release: " << release_version() << endl;
90 ost << "OS: " << os() << endl;
91 ost << "OS ver: " << os_version() << endl;
92 ost << "Host: " << hostname() << endl;
93 ost << "Machine: " << machine() << endl;
94 ost << "Run dir: " << dir() << endl;
95 ost << "CMTCONFIG: " << cmtconfig() << endl;
96 ost << "Job start time: " << start_time() << endl << endl;
97 ost << "Properties: [" << endl;
98 ;
99 for ( const auto& ipprop : propertyPairs() ) {
100 const std::string& client = ipprop.first;
101 const PropertyBase* prop = ipprop.second;
102 ost << client << ": ";
103 prop->fillStream( ost );
104 ost << endl;
105 }
106 ost << "]" << endl;
107 for ( const auto& itr : environment() ) ost << itr << endl;
108 } else {
109 }
110 }
111
112 //**********************************************************************
113 // Free functions.
114 //**********************************************************************
115
116 // Output stream.
117
118 ostream& operator<<( ostream& lhs, const JobHistory& rhs ) {
119 rhs.dump( lhs, false );
120 return lhs;
121 }
122
123 //**********************************************************************
plotSpeedupsPyRoot.time
def time
Definition: plotSpeedupsPyRoot.py:152
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:369
System.h
JobHistory::m_ppl
PropertyPairList m_ppl
Definition: JobHistory.h:40
JobHistory::m_dir
std::string m_dir
Definition: JobHistory.h:29
std::endl
T endl(T... args)
JobHistory::m_os_version
std::string m_os_version
Definition: JobHistory.h:34
JobHistory::os
std::string os() const
Definition: JobHistory.h:63
Containers::vector
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
Definition: KeyedObjectManager.h:29
JobHistory::machine
std::string machine() const
Definition: JobHistory.h:66
JobHistory::m_osname
std::string m_osname
Definition: JobHistory.h:32
JobHistory::dir
std::string dir() const
Definition: JobHistory.h:67
JobHistory::~JobHistory
virtual ~JobHistory()
JobHistory::m_hostname
std::string m_hostname
Definition: JobHistory.h:33
JobHistory::environment
std::vector< std::string > environment() const
Definition: JobHistory.h:69
JobHistory
JobHistory class definition.
Definition: JobHistory.h:22
JobHistory::start_time
time_t start_time() const
Definition: JobHistory.h:72
std::string
STL class.
JobHistory::m_environ
std::vector< std::string > m_environ
Definition: JobHistory.h:37
JobHistory::JobHistory
JobHistory()
Definition: JobHistory.cpp:33
JobHistory.h
JobHistory::m_start_time
time_t m_start_time
Definition: JobHistory.h:43
JobHistory::addProperty
void addProperty(const std::string &, const Gaudi::Details::PropertyBase *)
Definition: JobHistory.cpp:81
JobHistory::hostname
std::string hostname() const
Definition: JobHistory.h:64
JobHistory::cmtconfig
std::string cmtconfig() const
Definition: JobHistory.h:68
operator<<
ostream & operator<<(ostream &lhs, const JobHistory &rhs)
Definition: JobHistory.cpp:118
JobHistory::dump
void dump(std::ostream &, const bool isXML=false, int indent=0) const override
Definition: JobHistory.cpp:86
JobHistory::m_cmtconfig
std::string m_cmtconfig
Definition: JobHistory.h:30
System::osName
GAUDI_API const std::string & osName()
OS name.
Definition: System.cpp:309
JobHistory::m_machine
std::string m_machine
Definition: JobHistory.h:35
JobHistory::os_version
std::string os_version() const
Definition: JobHistory.h:65
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Gaudi::Details::PropertyBase::fillStream
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:49
JobHistory::m_release_version
std::string m_release_version
Definition: JobHistory.h:28
System::hostName
GAUDI_API const std::string & hostName()
Host name.
Definition: System.cpp:303
JobHistory::propertyPairs
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:71
Property.h
System::osVersion
GAUDI_API const std::string & osVersion()
OS version.
Definition: System.cpp:315
JobHistory::classID
static const CLID & classID()
Definition: JobHistory.cpp:75
System::machineType
GAUDI_API const std::string & machineType()
Machine type.
Definition: System.cpp:321
JobHistory::release_version
std::string release_version() const
Definition: JobHistory.h:62
std::ostream
STL class.
std::vector::emplace_back
T emplace_back(T... args)