26 boost::posix_time::time_duration timeout,
bool stackTrace =
false,
long maxCount = 0,
27 bool autostart =
false )
28 :
WatchdogThread( timeout, autostart ),
log( msgSvc, name ), m_maxCount( maxCount ), m_stackTrace( stackTrace )
40 bool m_stackTrace =
false;
46 << IncidentType::BeginEvent <<
endmsg;
50 log <<
MSG::INFO <<
"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;
70 log <<
MSG::INFO <<
"Starting a new event after ~" << m_counter *
getTimeout().total_seconds() <<
"s" 89 if ( m_eventTimeout ) {
91 m_watchdog = std::make_unique<EventWatchdog>(
92 msgSvc(),
"EventWatchdog", boost::posix_time::seconds( m_eventTimeout ), m_stackTrace, m_maxTimeoutCount );
95 static const std::string serviceName =
"IncidentSvc";
96 m_incidentSvc = serviceLocator()->service( serviceName );
97 if ( !m_incidentSvc ) {
98 error() <<
"Cannot retrieve " << serviceName <<
endmsg;
101 debug() <<
"Register to the IncidentSvc" <<
endmsg;
102 m_incidentSvc->addListener(
this, IncidentType::BeginEvent );
104 warning() <<
"StalledEventMonitor/" <<
name() <<
" instantiated with 0 time-out: no monitoring performed" <<
endmsg;
113 if ( m_watchdog ) m_watchdog->start();
120 if ( m_watchdog ) m_watchdog->ping();
126 if ( m_watchdog ) m_watchdog->stop();
136 m_incidentSvc->removeListener(
this, IncidentType::BeginEvent );
137 m_incidentSvc.reset();
138 return base_class::finalize();
constexpr static const auto FAILURE
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.
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.
constexpr static const auto SUCCESS
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).
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.