StalledEventMonitor Class Reference

Service that monitor the time taken by processing of single events using a separate thread. More...

#include <src/component/StalledEventMonitor.h>

Inheritance diagram for StalledEventMonitor:
Collaboration diagram for StalledEventMonitor:

Public Member Functions

 StalledEventMonitor (const std::string &name, ISvcLocator *svcLoc)
 Constructor. More...
 
 ~StalledEventMonitor () override=default
 Destructor. More...
 
StatusCode initialize () override
 Initialization of the service. More...
 
StatusCode start () override
 Start the watchdog thread (before entering the event loop). More...
 
void handle (const Incident &) override
 Notify the watchdog thread for a new event. More...
 
StatusCode stop () override
 Stop the watchdog thread (after the event loop). More...
 
StatusCode finalize () override
 Finalization of the service. More...
 
- Public Member Functions inherited from extends< BASE, 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...
 
 ~extends () override=default
 Virtual destructor. 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...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Attributes

unsigned int m_eventTimeout
 Number of seconds allowed to process a single event. More...
 
int m_maxTimeoutCount
 Number timeouts before aborting the execution (0 means never abort). More...
 
bool m_stackTrace
 Whether to print a stack-trace on timeout. More...
 
std::unique_ptr< WatchdogThreadm_watchdog
 Pointer to the watchdog thread that checks for the event timeout. More...
 
SmartIF< IIncidentSvcm_incidentSvc
 Pointer to the incident service. More...
 

Additional Inherited Members

- Public Types inherited from extends< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- 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...
 

Detailed Description

Service that monitor the time taken by processing of single events using a separate thread.

See also
WatchdogThread
Author
Marco Clemencic
Date
Apr 19, 2010

Definition at line 29 of file StalledEventMonitor.h.

Constructor & Destructor Documentation

StalledEventMonitor::StalledEventMonitor ( const std::string &  name,
ISvcLocator svcLoc 
)

Constructor.

Definition at line 84 of file StalledEventMonitor.cpp.

84  :
85  base_class(name, svcLoc) {
86 
87  declareProperty("EventTimeout", m_eventTimeout = 600,
88  "Number of seconds allowed to process a single event (0 to disable the check).");
89 
90  declareProperty("MaxTimeoutCount", m_maxTimeoutCount = 0,
91  "Number timeouts before aborting the execution (0 means never abort).");
92 
93  declareProperty("StackTrace", m_stackTrace = false,
94  "Whether to print the stack-trace on timeout.");
95 }
bool m_stackTrace
Whether to print a stack-trace on timeout.
extends base_class
Typedef to this class.
Definition: extends.h:14
int m_maxTimeoutCount
Number timeouts before aborting the execution (0 means never abort).
unsigned int m_eventTimeout
Number of seconds allowed to process a single event.
StalledEventMonitor::~StalledEventMonitor ( )
overridedefault

Destructor.

Member Function Documentation

StatusCode StalledEventMonitor::finalize ( )
override

Finalization of the service.

Definition at line 146 of file StalledEventMonitor.cpp.

146  {
147  // destroy the watchdog thread (if any)
148  m_watchdog.reset();
149  // unregistering from the IncidentSvc
150  m_incidentSvc->removeListener(this, IncidentType::BeginEvent);
152  return base_class::finalize();
153 }
std::unique_ptr< WatchdogThread > m_watchdog
Pointer to the watchdog thread that checks for the event timeout.
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to the incident service.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
virtual void removeListener(IIncidentListener *lis, const std::string &type="")=0
Remove listener.
void StalledEventMonitor::handle ( const Incident )
override

Notify the watchdog thread for a new event.

Definition at line 135 of file StalledEventMonitor.cpp.

135  {
136  if (m_watchdog) m_watchdog->ping();
137 }
std::unique_ptr< WatchdogThread > m_watchdog
Pointer to the watchdog thread that checks for the event timeout.
StatusCode StalledEventMonitor::initialize ( )
override

Initialization of the service.

Prepare the watchdog thread and configures it.

Definition at line 98 of file StalledEventMonitor.cpp.

98  {
100  if (sc.isFailure()) return sc;
101 
102 
103  if (m_eventTimeout) {
104  // create the watchdog thread
105  m_watchdog.reset( new EventWatchdog(msgSvc(),
106  "EventWatchdog",
107  boost::posix_time::seconds(m_eventTimeout),
108  m_stackTrace,
110 
111  // register to the incident service
112  static const std::string serviceName = "IncidentSvc";
113  m_incidentSvc = serviceLocator()->service(serviceName);
114  if ( ! m_incidentSvc ) {
115  error() << "Cannot retrieve " << serviceName << endmsg;
116  return StatusCode::FAILURE;
117  }
118  debug() << "Register to the IncidentSvc" << endmsg;
119  m_incidentSvc->addListener(this, IncidentType::BeginEvent);
120  } else {
121  warning() << "StalledEventMonitor/" << name()
122  << " instantiated with 0 time-out: no monitoring performed" << endmsg;
123  }
124 
125  return StatusCode::SUCCESS;
126 }
def initialize()
Definition: AnalysisTest.py:12
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::unique_ptr< WatchdogThread > m_watchdog
Pointer to the watchdog thread that checks for the event timeout.
bool m_stackTrace
Whether to print a stack-trace on timeout.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to the incident service.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
int m_maxTimeoutCount
Number timeouts before aborting the execution (0 means never abort).
unsigned int m_eventTimeout
Number of seconds allowed to process a single event.
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
StatusCode StalledEventMonitor::start ( )
override

Start the watchdog thread (before entering the event loop).

Definition at line 129 of file StalledEventMonitor.cpp.

129  {
130  if (m_watchdog) m_watchdog->start();
131  return StatusCode::SUCCESS;
132 }
std::unique_ptr< WatchdogThread > m_watchdog
Pointer to the watchdog thread that checks for the event timeout.
StatusCode StalledEventMonitor::stop ( )
override

Stop the watchdog thread (after the event loop).

Definition at line 140 of file StalledEventMonitor.cpp.

140  {
141  if (m_watchdog) m_watchdog->stop();
142  return StatusCode::SUCCESS;
143 }
std::unique_ptr< WatchdogThread > m_watchdog
Pointer to the watchdog thread that checks for the event timeout.

Member Data Documentation

unsigned int StalledEventMonitor::m_eventTimeout
private

Number of seconds allowed to process a single event.

Definition at line 55 of file StalledEventMonitor.h.

SmartIF<IIncidentSvc> StalledEventMonitor::m_incidentSvc
private

Pointer to the incident service.

Definition at line 67 of file StalledEventMonitor.h.

int StalledEventMonitor::m_maxTimeoutCount
private

Number timeouts before aborting the execution (0 means never abort).

Definition at line 58 of file StalledEventMonitor.h.

bool StalledEventMonitor::m_stackTrace
private

Whether to print a stack-trace on timeout.

Definition at line 61 of file StalledEventMonitor.h.

std::unique_ptr<WatchdogThread> StalledEventMonitor::m_watchdog
private

Pointer to the watchdog thread that checks for the event timeout.

Definition at line 64 of file StalledEventMonitor.h.


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