All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ()
 
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...
 
virtual ~Auditor ()
 Destructor. More...
 
StatusCode sysInitialize ()
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize ()
 Finalization method invoked by the framework. More...
 
virtual void before (StandardEventType, INamedInterface *)
 The following methods are meant to be implemented by the child class... More...
 
virtual void before (StandardEventType, const std::string &)
 Audit the start of a standard "event" for callers that do not implement INamedInterface. More...
 
virtual void before (CustomEventTypeRef, INamedInterface *)
 Audit the start of a custom "event". More...
 
virtual void before (CustomEventTypeRef, const std::string &)
 Audit the start of a custom "event" for callers that do not implement INamedInterface. More...
 
virtual void after (StandardEventType, INamedInterface *, const StatusCode &)
 Audit the end of a standard "event". More...
 
virtual void after (StandardEventType, const std::string &, const StatusCode &)
 Audit the end of a standard "event" for callers that do not implement INamedInterface. More...
 
virtual void after (CustomEventTypeRef, INamedInterface *, const StatusCode &)
 Audit the end of a custom "event". More...
 
virtual void after (CustomEventTypeRef, const std::string &, const StatusCode &)
 Audit the end of a custom "event" for callers that do not implement INamedInterface. More...
 
virtual void beforeInitialize (INamedInterface *)
 
virtual void afterInitialize (INamedInterface *)
 
virtual void beforeReinitialize (INamedInterface *)
 
virtual void afterReinitialize (INamedInterface *)
 
virtual void beforeFinalize (INamedInterface *)
 
virtual void afterFinalize (INamedInterface *)
 
virtual void beforeBeginRun (INamedInterface *)
 
virtual void afterBeginRun (INamedInterface *)
 
virtual void beforeEndRun (INamedInterface *)
 
virtual void afterEndRun (INamedInterface *)
 
virtual const std::string & name () const
 Retrieve the name of the instance. More...
 
virtual bool isEnabled () const
 Tell if the auditor is enabled or not. More...
 
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...
 
virtual StatusCode setProperty (const Property &p)
 Set a value of a property of an auditor. More...
 
virtual StatusCode setProperty (const std::string &s)
 Implementation of IProperty::setProperty. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Implementation of IProperty::setProperty. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the value of a property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const
 Get all properties. 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 extend_interfaces2< IAuditor, IProperty >
virtual ~extend_interfaces2 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IAuditor
 DeclareInterfaceID (IAuditor, 3, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. 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::Factory2
< IAuditor *, const
std::string &, ISvcLocator * > 
Factory
 
- Public Types inherited from implements2< IAuditor, IProperty >
typedef implements2 base_class
 Typedef to this class. More...
 
typedef extend_interfaces2
< IAuditor, IProperty
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces2< IAuditor, IProperty >
typedef mpl::fold< typename
IAuditor::iid::iids::type,
typename
IProperty::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IAuditor
enum  StandardEventType {
  Initialize, ReInitialize, Execute, BeginRun,
  EndRun, Finalize, Start, Stop,
  ReStart
}
 Defines the standard (= used by the framework) auditable event types. More...
 
typedef std::string CustomEventType
 Type used to allow users to specify a custom event to be audit. More...
 
typedef const CustomEventTypeCustomEventTypeRef
 Used in function calls for optimization purposes. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. 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 }
virtual const std::string & name() const
Retrieve the name of the instance.
Definition: Auditor.cpp:218
BooleanProperty m_abort
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Auditor.h:233
Auditor(const std::string &name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:14
BooleanProperty m_throw
AlgErrorAuditor::~AlgErrorAuditor ( )
virtual

Definition at line 17 of file AlgErrorAuditor.cpp.

17  {
18 }

Member Function Documentation

void AlgErrorAuditor::afterExecute ( INamedInterface ,
const StatusCode  
)
virtual
Deprecated:
use after

Reimplemented from Auditor.

Definition at line 41 of file AlgErrorAuditor.cpp.

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

Reimplemented from Auditor.

Definition at line 22 of file AlgErrorAuditor.cpp.

22  {
23  m_error = msgSvc()->messageCount(MSG::ERROR);
24  m_fatal = msgSvc()->messageCount(MSG::FATAL);
25 }
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:226
StatusCode AlgErrorAuditor::finalize ( )
virtual

Reimplemented from Auditor.

Definition at line 87 of file AlgErrorAuditor.cpp.

87  {
88 
89 
90  std::map<std::string,int>::const_iterator itr;
91  if (m_algMap[0].size() != 0) {
92  MsgStream log(msgSvc(), name());
93  log << MSG::INFO << "Found " << m_algMap[0].size()
94  << " instances where an Algorithm::execute() produced an ERROR "
95  << "but returned a SUCCESS:" << std::endl;
96 
97  for (itr = m_algMap[0].begin(); itr != m_algMap[0].end(); ++itr) {
98  log << itr->first << ": " << itr->second << std::endl;
99  }
100 
101  log << endmsg;
102  }
103 
104  if (m_algMap[1].size() != 0) {
105  MsgStream log(msgSvc(), name());
106  log << MSG::INFO << "Found " << m_algMap[1].size()
107  << " instances where an Algorithm::execute() produced a FATAL "
108  << "but returned a SUCCESS:" << std::endl;
109 
110  for (itr = m_algMap[1].begin(); itr != m_algMap[1].end(); ++itr) {
111  log << itr->first << ": " << itr->second << std::endl;
112  }
113 
114  log << endmsg;
115  }
116 
117 
118  return StatusCode::SUCCESS;
119 
120 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual const std::string & name() const
Retrieve the name of the instance.
Definition: Auditor.cpp:218
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:226
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:243
void AlgErrorAuditor::incrMap ( const std::string &  algName,
int  level 
)
private

Definition at line 123 of file AlgErrorAuditor.cpp.

123  {
124  std::map<std::string, int>::iterator itr;
125  if ( (itr=m_algMap[level].find(alg)) != m_algMap[level].end()) {
126  itr->second++;
127  } else {
128  m_algMap[level].insert( std::pair<std::string,int>(alg,1) );
129  }
130 }
std::map< std::string, int > m_algMap[2]
tuple end
Definition: IOTest.py:101
StatusCode AlgErrorAuditor::initialize ( )
virtual

Reimplemented from Auditor.

Definition at line 28 of file AlgErrorAuditor.cpp.

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

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: