24 boost::posix_time::time_duration timeout,
bool stackTrace =
false,
long maxCount = 0,
25 bool autostart =
false )
28 , m_maxCount( maxCount )
29 , m_stackTrace( stackTrace ) {}
39 bool m_stackTrace =
false;
44 << IncidentType::BeginEvent <<
endmsg;
49 <<
"Current memory usage is" 53 ", resident set size = " 55 if ( m_stackTrace && gSystem ) {
58 gSystem->StackTrace();
61 if ( m_maxCount > 0 && m_counter >= m_maxCount ) {
62 log <<
MSG::FATAL <<
"too much time on a single event: aborting process" <<
endmsg;
69 log <<
MSG::INFO <<
"Starting a new event after ~" << m_counter *
getTimeout().total_seconds() <<
"s" 86 if ( m_eventTimeout ) {
88 m_watchdog = std::make_unique<EventWatchdog>(
msgSvc(),
"EventWatchdog",
89 boost::posix_time::seconds( m_eventTimeout.value() ), m_stackTrace,
93 static const std::string serviceName =
"IncidentSvc";
94 m_incidentSvc = serviceLocator()->service( serviceName );
95 if ( !m_incidentSvc ) {
96 error() <<
"Cannot retrieve " << serviceName <<
endmsg;
99 debug() <<
"Register to the IncidentSvc" <<
endmsg;
100 m_incidentSvc->addListener(
this, IncidentType::BeginEvent );
102 warning() <<
"StalledEventMonitor/" <<
name() <<
" instantiated with 0 time-out: no monitoring performed" <<
endmsg;
110 if ( m_watchdog ) m_watchdog->start();
116 if ( m_watchdog ) m_watchdog->ping();
121 if ( m_watchdog ) m_watchdog->stop();
130 m_incidentSvc->removeListener(
this, IncidentType::BeginEvent );
131 m_incidentSvc.reset();
132 return base_class::finalize();
Definition of the MsgStream class used to transmit messages.
StatusCode stop() override
Stop the watchdog thread (after the event loop).
boost::posix_time::time_duration getTimeout() const
Get the current time-out value.
virtual void onStop()
User implemented function that will be called when stopping.
void handle(const Incident &) override
Notify the watchdog thread for a new event.
constexpr static const auto SUCCESS
StatusCode start() override
Start the watchdog thread (before entering the event loop).
#define DECLARE_COMPONENT(type)
Service that monitor the time taken by processing of single events using a separate thread...
This class is used for returning status codes from appropriate routines.
virtual void onPing()
User implemented function that will be called when ping is called.
StatusCode initialize() override
Initialization of the service.
Simple class for asynchronous check of time-out.
Base class for all Incidents (computing events).
constexpr static const auto FAILURE
GAUDI_API long virtualMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: priority boost.
StatusCode finalize() override
Finalization of the service.
virtual void action()
User implemented function that will be called if the time-out is reached.
GAUDI_API long pagedMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: Amount of paged memory currently occupied by the process 'pid'...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.