5 #include "sentinel/utils/version.h"
6 #include "sentinel/utils/Alarm.h"
8 #include "xcept/tools.h"
9 #include "xdata/InfoSpaceFactory.h"
22 xdaq::Application* app
28 alarmInfoSpace_ = xdata::getInfoSpaceFactory()->get(
"urn:xdaq-sentinel:alarms");
40 xdaq::Application* app,
48 alarmInfoSpace_ = xdata::getInfoSpaceFactory()->get(
"urn:xdaq-sentinel:alarms");
60 const std::string
name,
73 if ( raiseAlarm(name,
"warning", exception) )
74 LOG4CPLUS_WARN(app_->getApplicationLogger(),
75 "Raising warning alarm " << name <<
": " << exception.message());
79 if ( raiseAlarm(name,
"error", exception) )
80 LOG4CPLUS_ERROR(app_->getApplicationLogger(),
81 "Raising error alarm " << name <<
": " << exception.message());
85 if ( raiseAlarm(name,
"fatal", exception) )
86 LOG4CPLUS_FATAL(app_->getApplicationLogger(),
87 "Raising fatal alarm " << name <<
": " << exception.message());
91 LOG4CPLUS_WARN(app_->getApplicationLogger(),
92 "Unknown alarm level received for " << name <<
": " << exception.message());
107 LOG4CPLUS_INFO(app_->getApplicationLogger(),
108 xcept::stdformat_exception_history(exception));
112 LOG4CPLUS_WARN(app_->getApplicationLogger(),
113 xcept::stdformat_exception_history(exception));
114 app_->notifyQualified(
"warning", exception);
118 LOG4CPLUS_ERROR(app_->getApplicationLogger(),
119 xcept::stdformat_exception_history(exception));
120 app_->notifyQualified(
"error", exception);
124 LOG4CPLUS_FATAL(app_->getApplicationLogger(),
125 xcept::stdformat_exception_history(exception));
126 app_->notifyQualified(
"fatal", exception);
130 LOG4CPLUS_WARN(app_->getApplicationLogger(),
131 "Unknown alarm level received for exception: " <<
132 xcept::stdformat_exception_history(exception));
139 const std::string name,
140 const std::string level,
145 if (!alarmInfoSpace_)
return false;
147 boost::mutex::scoped_lock sl( mutex_ );
149 sentinel::utils::Alarm *alarm =
150 new sentinel::utils::Alarm(level, exception, app_);
153 alarmInfoSpace_->fireItemAvailable(name, alarm);
166 const std::string name
169 if (!alarmInfoSpace_)
return;
171 boost::mutex::scoped_lock sl( mutex_ );
173 sentinel::utils::Alarm *alarm;
176 alarm =
dynamic_cast<sentinel::utils::Alarm*
>( alarmInfoSpace_->find( name ) );
184 LOG4CPLUS_INFO(app_->getApplicationLogger(),
"Revoking alarm " <<
name);
186 alarmInfoSpace_->fireItemRevoked(name, app_);
195 boost::mutex::scoped_lock sl(
mutex_ );
197 typedef std::map<std::string, xdata::Serializable*, std::less<std::string> > alarmList;
199 for (alarmList::const_iterator it = alarms.begin(), itEnd = alarms.end();
202 sentinel::utils::Alarm* alarm =
dynamic_cast<sentinel::utils::Alarm*
>(it->second);
211 std::string errorMsg =
"Failed to process FAIL exception: "
212 + xcept::stdformat_exception_history(exception) +
" due to ";
217 sharedResources_->statisticsReporter_->getStateMachineMonitorCollection().setStatusMessage(
218 xcept::stdformat_exception_history(exception)
224 XCEPT_DECLARE_NESTED( stor::exception::StateTransition,
225 sentinelException,
"Failed to enqueue FAIL event", exception );
231 errorMsg += xcept::stdformat_exception_history(e);
236 errorMsg += e.what();
241 errorMsg +=
"an unknown exception.";
249 std::ostringstream fname_oss;
250 fname_oss <<
"/tmp/storage_manager_debug_" <<
251 sharedResources_->configuration_->getDiskWritingParams().smInstanceString_ <<
253 const std::string
fname = fname_oss.str();
254 std::ofstream
f( fname.c_str(), std::ios_base::ate |
std::ios_base::out | std::ios_base::app );
259 f << message << std::endl;
virtual void notifySentinel(const ALARM_LEVEL, xcept::Exception &)
xdata::InfoSpace * alarmInfoSpace_
virtual void raiseAlarm(const std::string name, const ALARM_LEVEL, xcept::Exception &)
virtual void revokeAlarm(const std::string name)
boost::shared_ptr< SharedResources > SharedResourcesPtr
void localDebug(const std::string &message) const
boost::shared_ptr< boost::statechart::event_base > EventPtr_t
boost::shared_ptr< SharedResources > sharedResources_
virtual void moveToFailedState(xcept::Exception &)