The Gaudi Framework  v29r0 (ff2e7097)
AlgErrorAuditor Class Reference

Monitors the cpu time usage of each algorithm. More...

#include <src/AlgErrorAuditor.h>

Inheritance diagram for AlgErrorAuditor:
Collaboration diagram for AlgErrorAuditor:

Public Member Functions

 ~AlgErrorAuditor () override=default
 
StatusCode initialize () override
 
StatusCode finalize () override
 
void beforeExecute (INamedInterface *alg) override
 
void afterExecute (INamedInterface *alg, const StatusCode &) override
 
- Public Member Functions inherited from Auditor
 Auditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
 Auditor (const Auditor &a)=delete
 
Auditoroperator= (const Auditor &rhs)=delete
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize () override
 Finalization method invoked by the framework. More...
 
void before (StandardEventType, INamedInterface *) override
 The following methods are meant to be implemented by the child class... More...
 
void before (StandardEventType, const std::string &) override
 
void before (CustomEventTypeRef, INamedInterface *) override
 
void before (CustomEventTypeRef, const std::string &) override
 
void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
void after (StandardEventType, const std::string &, const StatusCode &) override
 
void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 
void beforeInitialize (INamedInterface *) override
 
void afterInitialize (INamedInterface *) override
 
void beforeReinitialize (INamedInterface *) override
 
void afterReinitialize (INamedInterface *) override
 
void beforeExecute (INamedInterface *) override
 
void afterExecute (INamedInterface *, const StatusCode &) override
 
void beforeFinalize (INamedInterface *) override
 
void afterFinalize (INamedInterface *) override
 
void beforeBeginRun (INamedInterface *) override
 
void afterBeginRun (INamedInterface *) override
 
void beforeEndRun (INamedInterface *) override
 
void afterEndRun (INamedInterface *) override
 
const std::stringname () const override
 
bool isEnabled () const override
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator. More...
 
template<class T >
StatusCode service (const std::string &name, T *&svc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T = IService>
SmartIF< T > service (const std::string &name, bool createIf=false) const
 
StatusCode setProperties ()
 Set the auditor's properties. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
 PropertyHolder ()=default
 
 ~PropertyHolder () override=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Private Member Functions

void incrMap (const std::string &algName, int level)
 

Private Attributes

Gaudi::Property< bool > m_abort {this, "Abort", false, "abort job upon illegal Algorithm return code"}
 
Gaudi::Property< bool > m_throw {this, "Throw", false, "throw GaudiException upon illegal Algorithm return code"}
 
int m_error = 0
 
int m_fatal = 0
 
std::map< std::string, int > m_algMap [2]
 

Additional Inherited Members

- Public Types inherited from Auditor
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
using base_class = CommonMessaging
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Detailed Description

Monitors the cpu time usage of each algorithm.

Author
David Quarrie

Definition at line 15 of file AlgErrorAuditor.h.

Constructor & Destructor Documentation

AlgErrorAuditor::~AlgErrorAuditor ( )
overridedefault

Member Function Documentation

void AlgErrorAuditor::afterExecute ( INamedInterface alg,
const StatusCode sc 
)
override

Definition at line 25 of file AlgErrorAuditor.cpp.

26 {
27 
28  bool fail( false );
29  if ( msgSvc()->messageCount( MSG::ERROR ) != m_error && !sc.isRecoverable() ) {
31  os << "Illegal Return Code: Algorithm " << alg->name() << " reported an ERROR, but returned a StatusCode \"" << sc
32  << "\"";
33  os << std::endl
34  << "Error policy described in "
35  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
36 
37  error() << os.str() << endmsg;
38  incrMap( alg->name(), 0 );
39  fail = true;
40 
41  if ( m_throw && !m_abort ) {
42  throw GaudiException( os.str(), "AlgErrorAuditor", 0 );
43  }
44  }
45 
46  if ( msgSvc()->messageCount( MSG::FATAL ) != m_fatal && sc != StatusCode::FAILURE ) {
48  os << "Illegal Return Code: Algorithm " << alg->name() << " reported a FATAL, but returned a StatusCode \"" << sc
49  << "\"";
50  os << std::endl
51  << "Error policy described in "
52  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
53 
54  error() << os.str() << endmsg;
55  incrMap( alg->name(), 1 );
56  fail = true;
57 
58  if ( m_throw && !m_abort ) {
59  throw GaudiException( os.str(), "AlgErrorAuditor", 0 );
60  }
61  }
62 
63  if ( fail && m_abort ) {
64  abort();
65  }
66 }
Define general base for Gaudi exception.
virtual int messageCount(MSG::Level level) const =0
Get the number of messages issued at a particular level.
T endl(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
void incrMap(const std::string &algName, int level)
bool isRecoverable() const
Definition: StatusCode.h:87
Gaudi::Property< bool > m_abort
Gaudi::Property< bool > m_throw
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
T abort(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual const std::string & name() const =0
Retrieve the name of the instance.
void AlgErrorAuditor::beforeExecute ( INamedInterface alg)
override

Definition at line 8 of file AlgErrorAuditor.cpp.

9 {
12 }
virtual int messageCount(MSG::Level level) const =0
Get the number of messages issued at a particular level.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
StatusCode AlgErrorAuditor::finalize ( )
overridevirtual

Reimplemented from Auditor.

Definition at line 68 of file AlgErrorAuditor.cpp.

69 {
70 
71  if ( m_algMap[0].size() != 0 ) {
72  info() << "Found " << m_algMap[0].size() << " instances where an Algorithm::execute() produced an ERROR "
73  << "but returned a SUCCESS:" << std::endl;
74 
75  for ( const auto& i : m_algMap[0] ) {
76  msgStream() << i.first << ": " << i.second << std::endl;
77  }
78 
79  msgStream() << endmsg;
80  }
81 
82  if ( m_algMap[1].size() != 0 ) {
83  info() << "Found " << m_algMap[1].size() << " instances where an Algorithm::execute() produced a FATAL "
84  << "but returned a SUCCESS:" << std::endl;
85 
86  for ( const auto& i : m_algMap[1] ) {
87  msgStream() << i.first << ": " << i.second << std::endl;
88  }
89 
90  msgStream() << endmsg;
91  }
92  return StatusCode::SUCCESS;
93 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
std::map< std::string, int > m_algMap[2]
T endl(T...args)
T size(T...args)
MsgStream & msgStream() const
Return an uninitialized MsgStream.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void AlgErrorAuditor::incrMap ( const std::string algName,
int  level 
)
private

Definition at line 95 of file AlgErrorAuditor.cpp.

96 {
97  auto i = m_algMap[level].find( alg );
98  if ( i != m_algMap[level].end() ) {
99  i->second++;
100  } else {
101  m_algMap[level].emplace( alg, 1 );
102  }
103 }
std::map< std::string, int > m_algMap[2]
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
T find(T...args)
T emplace(T...args)
StatusCode AlgErrorAuditor::initialize ( )
overridevirtual

Reimplemented from Auditor.

Definition at line 14 of file AlgErrorAuditor.cpp.

15 {
16 
17  if ( m_abort && m_throw ) {
18  info() << "Both \"Throw\" and \"Abort\" options have been set."
19  << " Abort takes precedence." << endmsg;
20  }
21 
22  return StatusCode::SUCCESS;
23 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Gaudi::Property< bool > m_abort
Gaudi::Property< bool > m_throw
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

Member Data Documentation

Gaudi::Property<bool> AlgErrorAuditor::m_abort {this, "Abort", false, "abort job upon illegal Algorithm return code"}
private

Definition at line 28 of file AlgErrorAuditor.h.

std::map<std::string, int> AlgErrorAuditor::m_algMap[2]
private

Definition at line 36 of file AlgErrorAuditor.h.

int AlgErrorAuditor::m_error = 0
private

Definition at line 33 of file AlgErrorAuditor.h.

int AlgErrorAuditor::m_fatal = 0
private

Definition at line 34 of file AlgErrorAuditor.h.

Gaudi::Property<bool> AlgErrorAuditor::m_throw {this, "Throw", false, "throw GaudiException upon illegal Algorithm return code"}
private

Definition at line 29 of file AlgErrorAuditor.h.


The documentation for this class was generated from the following files: