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 () 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
 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 override
 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 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

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
 
- Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
using base_class = CommonMessaging
 
- 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 ( 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:232
Auditor(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:12
BooleanProperty m_throw
virtual AlgErrorAuditor::~AlgErrorAuditor ( )
virtualdefault

Member Function Documentation

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

Definition at line 36 of file AlgErrorAuditor.cpp.

36  {
37 
38  bool fail(false);
39  if (msgSvc()->messageCount(MSG::ERROR) != m_error && ! sc.isRecoverable() ) {
41  os << "Illegal Return Code: Algorithm " << alg->name()
42  << " reported an ERROR, but returned a StatusCode \"" << sc << "\"";
43  os << std::endl << "Error policy described in "
44  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
45 
46  error() << os.str() << endmsg;
47  incrMap(alg->name(), 0);
48  fail = true;
49 
50  if (m_throw && ! m_abort) {
51  throw GaudiException(os.str(),"AlgErrorAuditor",0);
52  }
53  }
54 
56  sc != StatusCode::FAILURE ) {
58  os << "Illegal Return Code: Algorithm " << alg->name()
59  << " reported a FATAL, but returned a StatusCode \"" << sc << "\"";
60  os << std::endl << "Error policy described in "
61  << "https://twiki.cern.ch/twiki/bin/view/AtlasComputing/ReportingErrors";
62 
63  error() << os.str() << endmsg;
64  incrMap(alg->name(), 1);
65  fail = true;
66 
67  if (m_throw && ! m_abort) {
68  throw GaudiException(os.str(),"AlgErrorAuditor",0);
69  }
70 
71  }
72 
73  if (fail && m_abort) {
74  abort();
75  }
76 
77 }
Define general base for Gaudi exception.
T endl(T...args)
BooleanProperty m_abort
virtual const std::string & name() const =0
Retrieve the name of the instance.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
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
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:244
void AlgErrorAuditor::beforeExecute ( INamedInterface alg)
virtual

Definition at line 18 of file AlgErrorAuditor.cpp.

18  {
21 }
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 ( )
virtual

Reimplemented from Auditor.

Definition at line 80 of file AlgErrorAuditor.cpp.

80  {
81 
82 
83  if (m_algMap[0].size() != 0) {
84  info() << "Found " << m_algMap[0].size()
85  << " instances where an Algorithm::execute() produced an ERROR "
86  << "but returned a SUCCESS:" << std::endl;
87 
88  for (const auto& i : m_algMap[0] ) {
89  msgStream() << i.first << ": " << i.second << std::endl;
90  }
91 
92  msgStream() << endmsg;
93  }
94 
95  if (m_algMap[1].size() != 0) {
96  info() << "Found " << m_algMap[1].size()
97  << " instances where an Algorithm::execute() produced a FATAL "
98  << "but returned a SUCCESS:" << std::endl;
99 
100  for (const auto& i : m_algMap[1]) {
101  msgStream() << i.first << ": " << i.second << std::endl;
102  }
103 
104  msgStream() << endmsg;
105  }
106  return StatusCode::SUCCESS;
107 }
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.
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void AlgErrorAuditor::incrMap ( const std::string algName,
int  level 
)
private

Definition at line 110 of file AlgErrorAuditor.cpp.

110  {
111  auto i=m_algMap[level].find(alg);
112  if ( i != m_algMap[level].end()) {
113  i->second++;
114  } else {
115  m_algMap[level].emplace( alg,1 );
116  }
117 }
std::map< std::string, int > m_algMap[2]
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
T find(T...args)
T emplace(T...args)
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  info() << "Both \"Throw\" and \"Abort\" options have been set."
28  << " Abort takes precedence." << endmsg;
29  }
30 
31  return StatusCode::SUCCESS;
32 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
BooleanProperty m_abort
BooleanProperty m_throw
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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: