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 (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~AlgErrorAuditor ()=default
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
virtual void beforeExecute (INamedInterface *alg)
 
virtual void afterExecute (INamedInterface *alg, const StatusCode &)
 
- Public Member Functions inherited from Auditor
 Auditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
 ~Auditor () override=default
 Destructor. More...
 
StatusCode sysInitialize ()
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize ()
 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::string & name () const override
 
bool isEnabled () const override
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
int outputLevel () const
 Retrieve the output level of current auditor. More...
 
void setOutputLevel (int level)
 Set the output level for current auditor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 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 setProperty (const Property &p) override
 Set a value of a property of an auditor. More...
 
StatusCode setProperty (const std::string &s) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 Implementation of IProperty::setProperty. More...
 
StatusCode getProperty (Property *p) const override
 Get the value of a property. More...
 
const PropertygetProperty (const std::string &name) const override
 Get the property by name. More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const
 Get all properties. More...
 
bool hasProperty (const std::string &name) const override
 Implementation of IProperty::hasProperty. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setProperties ()
 Set the auditor's properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
 Auditor (const std::string &name, ISvcLocator *svcloc)
 Constructor. More...
 
 ~Auditor () override=default
 Destructor. More...
 
StatusCode sysInitialize ()
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize ()
 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::string & name () const override
 
bool isEnabled () const override
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
int outputLevel () const
 Retrieve the output level of current auditor. More...
 
void setOutputLevel (int level)
 Set the output level for current auditor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 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 setProperty (const Property &p) override
 Set a value of a property of an auditor. More...
 
StatusCode setProperty (const std::string &s) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 Implementation of IProperty::setProperty. More...
 
StatusCode getProperty (Property *p) const override
 Get the value of a property. More...
 
const PropertygetProperty (const std::string &name) const override
 Get the property by name. More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const
 Get all properties. More...
 
bool hasProperty (const std::string &name) const override
 Implementation of IProperty::hasProperty. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setProperties ()
 Set the auditor's properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
- Public Member Functions inherited from implements< Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
 ~implements () override=default
 Virtual destructor. More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
 ~implements () override=default
 Virtual destructor. More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Member Functions

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

Private Attributes

BooleanProperty m_abort
 
BooleanProperty m_throw
 
int m_error
 
int m_fatal
 
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
 
typedef Gaudi::PluginService::Factory< IAuditor *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from implements< Interfaces >
using base_class = implements< Interfaces...>
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
using base_class = implements< Interfaces...>
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Attributes inherited from implements< Interfaces >
unsigned long m_refCount = 0
 Reference counter. 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 ( const std::string &  name,
ISvcLocator pSvcLocator 
)

Definition at line 8 of file AlgErrorAuditor.cpp.

9  : Auditor(name, pSvcLocator), m_error(0), m_fatal(0) {
10 
11  declareProperty( "Abort", m_abort = false,
12  "Abort job upon illegal Algorithm return code");
13  declareProperty( "Throw", m_throw = false,
14  "Throw GaudiException upon illegal Algorithm return code");
15 }
BooleanProperty m_abort
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Auditor.h:241
Auditor(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:12
BooleanProperty m_throw
const std::string & name() const override
Definition: Auditor.cpp:212
virtual AlgErrorAuditor::~AlgErrorAuditor ( )
virtualdefault

Member Function Documentation

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

Definition at line 37 of file AlgErrorAuditor.cpp.

37  {
38 
39  bool fail(false);
40  if (msgSvc()->messageCount(MSG::ERROR) != m_error && ! sc.isRecoverable() ) {
41  std::ostringstream os;
42  os << "Illegal Return Code: Algorithm " << alg->name()
43  << " reported an ERROR, but returned a StatusCode \"" << sc << "\"";
44  os << std::endl << "Error policy described in "
45  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
46 
47  MsgStream log(msgSvc(), name());
48  log << MSG::ERROR << os.str() << endmsg;
49  incrMap(alg->name(), 0);
50  fail = true;
51 
52  if (m_throw && ! m_abort) {
53  throw GaudiException(os.str(),"AlgErrorAuditor",0);
54  }
55  }
56 
58  sc != StatusCode::FAILURE ) {
59  std::ostringstream os;
60  os << "Illegal Return Code: Algorithm " << alg->name()
61  << " reported a FATAL, but returned a StatusCode \"" << sc << "\"";
62  os << std::endl << "Error policy described in "
63  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
64 
65  MsgStream log(msgSvc(), name());
66  log << MSG::ERROR << os.str() << endmsg;
67  incrMap(alg->name(), 1);
68  fail = true;
69 
70  if (m_throw && ! m_abort) {
71  throw GaudiException(os.str(),"AlgErrorAuditor",0);
72  }
73 
74  }
75 
76  if (fail && m_abort) {
77  abort();
78  }
79 
80 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:220
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
BooleanProperty m_abort
virtual const std::string & name() const =0
Retrieve the name of the instance.
void incrMap(const std::string &algName, int level)
virtual int messageCount(MSG::Level level) const =0
Get the number of messages issued at a particular level.
bool isRecoverable() const
Definition: StatusCode.h:87
BooleanProperty m_throw
const std::string & name() const override
Definition: Auditor.cpp:212
void AlgErrorAuditor::beforeExecute ( INamedInterface alg)
virtual

Definition at line 18 of file AlgErrorAuditor.cpp.

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

Reimplemented from Auditor.

Definition at line 83 of file AlgErrorAuditor.cpp.

83  {
84 
85 
86  if (m_algMap[0].size() != 0) {
87  MsgStream log(msgSvc(), name());
88  log << MSG::INFO << "Found " << m_algMap[0].size()
89  << " instances where an Algorithm::execute() produced an ERROR "
90  << "but returned a SUCCESS:" << std::endl;
91 
92  for (const auto& i : m_algMap[0] ) {
93  log << i.first << ": " << i.second << std::endl;
94  }
95 
96  log << endmsg;
97  }
98 
99  if (m_algMap[1].size() != 0) {
100  MsgStream log(msgSvc(), name());
101  log << MSG::INFO << "Found " << m_algMap[1].size()
102  << " instances where an Algorithm::execute() produced a FATAL "
103  << "but returned a SUCCESS:" << std::endl;
104 
105  for (const auto& i : m_algMap[1]) {
106  log << i.first << ": " << i.second << std::endl;
107  }
108 
109  log << endmsg;
110  }
111  return StatusCode::SUCCESS;
112 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:220
std::map< std::string, int > m_algMap[2]
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
const std::string & name() const override
Definition: Auditor.cpp:212
list i
Definition: ana.py:128
void AlgErrorAuditor::incrMap ( const std::string &  algName,
int  level 
)
private

Definition at line 115 of file AlgErrorAuditor.cpp.

115  {
116  auto i=m_algMap[level].find(alg);
117  if ( i != m_algMap[level].end()) {
118  i->second++;
119  } else {
120  m_algMap[level].emplace( alg,1 );
121  }
122 }
std::map< std::string, int > m_algMap[2]
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
list i
Definition: ana.py:128
StatusCode AlgErrorAuditor::initialize ( )
virtual

Reimplemented from Auditor.

Definition at line 24 of file AlgErrorAuditor.cpp.

24  {
25 
26  if (m_abort && m_throw) {
27  MsgStream log(msgSvc(), name());
28  log << MSG::INFO << "Both \"Throw\" and \"Abort\" options have been set."
29  << " Abort takes precedence." << endmsg;
30  }
31 
32  return StatusCode::SUCCESS;
33 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:220
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
BooleanProperty m_abort
BooleanProperty m_throw
const std::string & name() const override
Definition: Auditor.cpp:212

Member Data Documentation

BooleanProperty AlgErrorAuditor::m_abort
private

Definition at line 27 of file AlgErrorAuditor.h.

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

Definition at line 34 of file AlgErrorAuditor.h.

int AlgErrorAuditor::m_error
private

Definition at line 31 of file AlgErrorAuditor.h.

int AlgErrorAuditor::m_fatal
private

Definition at line 32 of file AlgErrorAuditor.h.

BooleanProperty AlgErrorAuditor::m_throw
private

Definition at line 27 of file AlgErrorAuditor.h.


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