CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
cond::SQLMonitoringService Class Reference

#include <SQLMonitoringService.h>

Inheritance diagram for cond::SQLMonitoringService:

Public Member Functions

virtual bool active (const std::string &contextKey) const
 
virtual void disable (const std::string &contextKey)
 
virtual void enable (const std::string &contextKey)
 
virtual coral::monitor::Level level (const std::string &contextKey) const
 
virtual std::set< std::string > monitoredDataSources () const
 
virtual void record (const std::string &contextKey, coral::monitor::Source source, coral::monitor::Type type, const std::string &description)
 
virtual void record (const std::string &contextKey, coral::monitor::Source source, coral::monitor::Type type, const std::string &description, int data)
 
virtual void record (const std::string &contextKey, coral::monitor::Source source, coral::monitor::Type type, const std::string &description, long long data)
 
virtual void record (const std::string &contextKey, coral::monitor::Source source, coral::monitor::Type type, const std::string &description, double data)
 
virtual void record (const std::string &contextKey, coral::monitor::Source source, coral::monitor::Type type, const std::string &description, const std::string &data)
 
virtual void report (unsigned int level) const
 
virtual void report (const std::string &contextKey, unsigned int level) const
 
virtual const
coral::IMonitoringReporter & 
reporter () const
 
void reportForSession (Repository::const_iterator &it, std::ostream &os) const
 
void reportForSession (Repository::const_iterator &it, coral::MessageStream &os) const
 
void reportOnEvent (EventStream::const_iterator &it, std::ostream &os) const
 
void reportOnEvent (EventStream::const_iterator &it, coral::MessageStream &os) const
 
virtual void reportToOutputStream (const std::string &contextKey, std::ostream &os, unsigned int level) const
 
virtual void setLevel (const std::string &contextKey, coral::monitor::Level level)
 
 SQLMonitoringService (const std::string &)
 
virtual ~SQLMonitoringService ()
 

Private Attributes

Repository m_events
 The all events repository classified by the sessions' keys. More...
 
std::set< std::string > m_monitoredDS
 

Detailed Description

Definition at line 40 of file SQLMonitoringService.h.

Constructor & Destructor Documentation

cond::SQLMonitoringService::SQLMonitoringService ( const std::string &  key)
explicit

Definition at line 21 of file SQLMonitoringService.cc.

22  : coral::Service( key ),
23  m_events()
24  {
25  }
Repository m_events
The all events repository classified by the sessions&#39; keys.
list key
Definition: combine.py:13
cond::SQLMonitoringService::~SQLMonitoringService ( )
virtual

Definition at line 27 of file SQLMonitoringService.cc.

28  {
29  }

Member Function Documentation

bool cond::SQLMonitoringService::active ( const std::string &  contextKey) const
virtual

Return monitoring activity status

Definition at line 63 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::name.

Referenced by record().

64  {
65  Repository::const_iterator rit;
66 
67  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
68  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::active", this->name() );
69 
70  return (*rit).second.active;
71  }
Repository m_events
The all events repository classified by the sessions&#39; keys.
void cond::SQLMonitoringService::disable ( const std::string &  contextKey)
virtual

Definition at line 83 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::name.

84  {
85  Repository::iterator rit;
86 
87  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
88  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::disable", this->name() );
89 
90  (*rit).second.active = false;
91  }
Repository m_events
The all events repository classified by the sessions&#39; keys.
void cond::SQLMonitoringService::enable ( const std::string &  contextKey)
virtual

Definition at line 73 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::name.

74  {
75  Repository::iterator rit;
76 
77  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
78  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::enable", this->name() );
79 
80  (*rit).second.active = true;
81  }
Repository m_events
The all events repository classified by the sessions&#39; keys.
coral::monitor::Level cond::SQLMonitoringService::level ( const std::string &  contextKey) const
virtual

Return current monitoring level

Definition at line 53 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::name.

Referenced by setLevel().

54  {
55  Repository::const_iterator rit;
56 
57  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
58  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::level", this->name() );
59 
60  return (*rit).second.level;
61  }
Repository m_events
The all events repository classified by the sessions&#39; keys.
std::set< std::string > cond::SQLMonitoringService::monitoredDataSources ( ) const
virtual

Return the set of currently monitored data sources

Definition at line 180 of file SQLMonitoringService.cc.

References m_monitoredDS.

181  {
182  return m_monitoredDS;
183  }
std::set< std::string > m_monitoredDS
void cond::SQLMonitoringService::record ( const std::string &  contextKey,
coral::monitor::Source  source,
coral::monitor::Type  type,
const std::string &  description 
)
virtual

Records an event without a payload ( time event for example )

Definition at line 94 of file SQLMonitoringService.cc.

References active(), m_events, and mergeVDriftHistosByStation::name.

95  {
96  Repository::iterator rit;
97 
98  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
99  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string& )", this->name() );
100 
101  bool active = (*rit).second.active;
102  //coral::monitor::Level level = (*rit).second.level;
103 
104  if( active/* && (type & level)*/ )
105  {
106  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description ) );
107  }
108  }
type
Definition: HCALResponse.h:21
tuple description
Definition: idDealer.py:66
Repository m_events
The all events repository classified by the sessions&#39; keys.
virtual bool active(const std::string &contextKey) const
static std::string const source
Definition: EdmProvDump.cc:43
void cond::SQLMonitoringService::record ( const std::string &  contextKey,
coral::monitor::Source  source,
coral::monitor::Type  type,
const std::string &  description,
int  data 
)
virtual

Records an event with a payload

Definition at line 110 of file SQLMonitoringService.cc.

References active(), m_events, and mergeVDriftHistosByStation::name.

111  {
112  Repository::iterator rit;
113 
114  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
115  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string&, int )", this->name() );
116 
117  bool active = (*rit).second.active;
118  //coral::monitor::Level level = (*rit).second.level;
119 
120  if( active/* && (type & level)*/ )
121  {
122  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
123  }
124  }
type
Definition: HCALResponse.h:21
tuple description
Definition: idDealer.py:66
Repository m_events
The all events repository classified by the sessions&#39; keys.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
virtual bool active(const std::string &contextKey) const
static std::string const source
Definition: EdmProvDump.cc:43
void cond::SQLMonitoringService::record ( const std::string &  contextKey,
coral::monitor::Source  source,
coral::monitor::Type  type,
const std::string &  description,
long long  data 
)
virtual

Records an event with a payload

Definition at line 126 of file SQLMonitoringService.cc.

References active(), m_events, and mergeVDriftHistosByStation::name.

127  {
128  Repository::iterator rit;
129 
130  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
131  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string&, long long )", this->name() );
132 
133  bool active = (*rit).second.active;
134  //coral::monitor::Level level = (*rit).second.level;
135 
136  if( active/* && (type & level)*/ )
137  {
138  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
139  }
140  }
type
Definition: HCALResponse.h:21
tuple description
Definition: idDealer.py:66
Repository m_events
The all events repository classified by the sessions&#39; keys.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
virtual bool active(const std::string &contextKey) const
static std::string const source
Definition: EdmProvDump.cc:43
void cond::SQLMonitoringService::record ( const std::string &  contextKey,
coral::monitor::Source  source,
coral::monitor::Type  type,
const std::string &  description,
double  data 
)
virtual

Records an event with a payload

Definition at line 142 of file SQLMonitoringService.cc.

References active(), m_events, and mergeVDriftHistosByStation::name.

143  {
144  Repository::iterator rit;
145 
146  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
147  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string&, double )", this->name() );
148 
149  bool active = (*rit).second.active;
150  //coral::monitor::Level level = (*rit).second.level;
151 
152  if( active/* && (type & level)*/ )
153  {
154  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
155  }
156  }
type
Definition: HCALResponse.h:21
tuple description
Definition: idDealer.py:66
Repository m_events
The all events repository classified by the sessions&#39; keys.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
virtual bool active(const std::string &contextKey) const
static std::string const source
Definition: EdmProvDump.cc:43
void cond::SQLMonitoringService::record ( const std::string &  contextKey,
coral::monitor::Source  source,
coral::monitor::Type  type,
const std::string &  description,
const std::string &  data 
)
virtual

Records an event with a payload

Definition at line 158 of file SQLMonitoringService.cc.

References active(), m_events, and mergeVDriftHistosByStation::name.

159  {
160  Repository::iterator rit;
161 
162  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
163  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string&, const std::string& )", this->name() );
164 
165  bool active = (*rit).second.active;
166  //coral::monitor::Level level = (*rit).second.level;
167 
168  if( active /*&& (type & level)*/ )
169  {
170  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
171  }
172  }
type
Definition: HCALResponse.h:21
tuple description
Definition: idDealer.py:66
Repository m_events
The all events repository classified by the sessions&#39; keys.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
virtual bool active(const std::string &contextKey) const
static std::string const source
Definition: EdmProvDump.cc:43
void cond::SQLMonitoringService::report ( unsigned int  level) const
virtual

Reports all the events

Parameters
contextKeyThe session ID for which to make the report

Definition at line 185 of file SQLMonitoringService.cc.

References create_public_lumi_plots::log, m_events, and reportForSession().

186  {
187  Repository::const_iterator rit;
188  coral::MessageStream log( "MonitoringService" );
189 
190  // Dummy reporting so far
191  for( rit = m_events.begin(); rit != m_events.end(); ++rit )
192  reportForSession( rit, log );
193  }
Repository m_events
The all events repository classified by the sessions&#39; keys.
void reportForSession(Repository::const_iterator &it, std::ostream &os) const
void cond::SQLMonitoringService::report ( const std::string &  contextKey,
unsigned int  level 
) const
virtual

Reports the events to the default reporter

Parameters
contextKeyThe session ID for which to make the report

Definition at line 195 of file SQLMonitoringService.cc.

References create_public_lumi_plots::log, m_events, mergeVDriftHistosByStation::name, and reportForSession().

196  {
197  Repository::const_iterator rit;
198 
199  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
200  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
201 
202  // Dummy reporting so far
203  coral::MessageStream log( "MonitoringService" );
204 
205  reportForSession( rit, log );
206  }
Repository m_events
The all events repository classified by the sessions&#39; keys.
void reportForSession(Repository::const_iterator &it, std::ostream &os) const
const coral::IMonitoringReporter & cond::SQLMonitoringService::reporter ( ) const
virtual

Return the current reporter

Definition at line 174 of file SQLMonitoringService.cc.

175  {
176  return( static_cast<const coral::IMonitoringReporter&>(*this) );
177  }
void cond::SQLMonitoringService::reportForSession ( Repository::const_iterator &  it,
std::ostream &  os 
) const

Definition at line 322 of file SQLMonitoringService.cc.

References Debug, Default, reportOnEvent(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by report(), and reportToOutputStream().

323  {
324  os << "Session: " << (*it).first << std::endl;
325  std::string lvl;
326  switch( (*it).second.level ) {
327  case (coral::monitor::Off) : lvl = "Off"; break;
328  case (coral::monitor::Minimal) : lvl = "Minimal"; break;
329  case (coral::monitor::Default) : lvl = "Default"; break;
330  case (coral::monitor::Debug) : lvl = "Debug"; break;
331  case (coral::monitor::Trace) : lvl = "Trace"; break;
332  default: lvl = "";
333  };
334  os << "Monitoring Level: " << lvl << std::endl;
335 
336  const EventStream& evsref = (*it).second.stream;
337  os << " Recorded " << evsref.size() << " events" << std::endl;
338 
339  for( EventStream::const_iterator evit = evsref.begin(); evit != evsref.end(); ++evit )
340  {
341  reportOnEvent( evit, os );
342  }
343  }
#define Default
Definition: vmac.h:108
void reportOnEvent(EventStream::const_iterator &it, std::ostream &os) const
std::vector< coral::monitor::Event::Record > EventStream
The raw stream of recorder monitoring events.
const bool Debug
void cond::SQLMonitoringService::reportForSession ( Repository::const_iterator &  it,
coral::MessageStream &  os 
) const

Definition at line 345 of file SQLMonitoringService.cc.

References Debug, Default, reportOnEvent(), and AlCaHLTBitMon_QueryRunRegistry::string.

346  {
347  os << "Session: " << (*it).first;
348  std::string lvl;
349  switch( (*it).second.level ) {
350  case (coral::monitor::Off) : lvl = "Off"; break;
351  case (coral::monitor::Minimal) : lvl = "Minimal"; break;
352  case (coral::monitor::Default) : lvl = "Default"; break;
353  case (coral::monitor::Debug) : lvl = "Debug"; break;
354  case (coral::monitor::Trace) : lvl = "Trace"; break;
355  default: lvl = "";
356  };
357  os << " monitored at level: " << lvl;
358 
359  const EventStream& evsref = (*it).second.stream;
360  os << lvl << " has recorded " << evsref.size() << " events" << coral::MessageStream::endmsg;
361 
362  for( EventStream::const_iterator evit = evsref.begin(); evit != evsref.end(); ++evit )
363  {
364  reportOnEvent( evit, os );
365  }
366 
367  }
#define Default
Definition: vmac.h:108
void reportOnEvent(EventStream::const_iterator &it, std::ostream &os) const
std::vector< coral::monitor::Event::Record > EventStream
The raw stream of recorder monitoring events.
const bool Debug
void cond::SQLMonitoringService::reportOnEvent ( EventStream::const_iterator &  it,
std::ostream &  os 
) const

Definition at line 221 of file SQLMonitoringService.cc.

References helper::Config, source, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by reportForSession().

222  {
223  std::string source("");
224  switch( it->m_source ) {
225  case coral::monitor::Application:
226  source = "Application";
227  break;
228  case coral::monitor::Session:
229  source = "Session";
230  break;
231  case coral::monitor::Transaction:
232  source = "Transaction";
233  break;
234  case coral::monitor::Statement:
235  source = "Statement";
236  break;
237  default:
238  source = "";
239  };
240 
241  std::string type("");
242  switch( it->m_type ) {
243  case coral::monitor::Info:
244  type = "Info";
245  break;
246  case coral::monitor::Time:
247  type = "Time";
248  break;
249  case coral::monitor::Warning:
250  type = "Warning";
251  break;
252  case coral::monitor::Error:
253  type = "Error";
254  break;
256  type = "Config";
257  break;
258  default:
259  type = "";
260  };
261 
262  if(it->m_source == coral::monitor::Statement || it->m_source == coral::monitor::Transaction)
263  {
264  os << boost::posix_time::to_iso_extended_string((*it).m_time.time()) << ": "
265  << source << "; "
266  << type << "; "
267  <<(*it).m_description << ";"<< std::endl;
268  }
269  }
type
Definition: HCALResponse.h:21
tuple Config
Definition: helper.py:9
static std::string const source
Definition: EdmProvDump.cc:43
void cond::SQLMonitoringService::reportOnEvent ( EventStream::const_iterator &  it,
coral::MessageStream &  os 
) const

Definition at line 272 of file SQLMonitoringService.cc.

References helper::Config, source, and AlCaHLTBitMon_QueryRunRegistry::string.

273  {
274  std::string source("");
275  switch( it->m_source ) {
276  case coral::monitor::Application:
277  source = "Application";
278  break;
279  case coral::monitor::Session:
280  source = "Session";
281  break;
282  case coral::monitor::Transaction:
283  source = "Transaction";
284  break;
285  case coral::monitor::Statement:
286  source = "Statement";
287  break;
288  default:
289  source = "";
290  };
291 
292  std::string type("");
293  switch( it->m_type ) {
294  case coral::monitor::Info:
295  type = "Info";
296  break;
297  case coral::monitor::Time:
298  type = "Time";
299  break;
300  case coral::monitor::Warning:
301  type = "Warning";
302  break;
303  case coral::monitor::Error:
304  type = "Error";
305  break;
307  type = "Config";
308  break;
309  default:
310  type = "";
311  };
312 
313  if(it->m_source == coral::monitor::Statement || it->m_source == coral::monitor::Transaction)
314  {
315  os << boost::posix_time::to_iso_extended_string((*it).m_time.time()) << ": "
316  << source << "; "
317  << type << "; "
318  << (*it).m_description <<coral::MessageStream::flush;
319  }
320  }
type
Definition: HCALResponse.h:21
tuple Config
Definition: helper.py:9
static std::string const source
Definition: EdmProvDump.cc:43
void cond::SQLMonitoringService::reportToOutputStream ( const std::string &  contextKey,
std::ostream &  os,
unsigned int  level 
) const
virtual

Reports the events to the specified output stream

Parameters
contextKeyThe session ID for which to make the report

Definition at line 208 of file SQLMonitoringService.cc.

References create_public_lumi_plots::log, m_events, mergeVDriftHistosByStation::name, and reportForSession().

209  {
210  Repository::const_iterator rit;
211 
212  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
213  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
214 
215  // Dummy reporting so far
216  coral::MessageStream log( "MonitoringService" );
217 
218  reportForSession( rit, os );
219  }
Repository m_events
The all events repository classified by the sessions&#39; keys.
void reportForSession(Repository::const_iterator &it, std::ostream &os) const
void cond::SQLMonitoringService::setLevel ( const std::string &  contextKey,
coral::monitor::Level  level 
)
virtual

The implementation coral::IMonitoringService interface Sets the level

Parameters
contextKeyThe session ID for which to make the report
levelThe monitoring level ( Default, Debug, Trace )

Definition at line 31 of file SQLMonitoringService.cc.

References level(), m_events, and m_monitoredDS.

32  {
33  Repository::const_iterator rit;
34 
35  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
36  {
37  m_events[contextKey] = SessionMonitor();
38  m_monitoredDS.insert( contextKey );
39  }
40 
41  m_events[contextKey].level = level;
42 
43  if( level == coral::monitor::Off )
44  {
45  m_events[contextKey].active = false;
46  }
47  else
48  {
49  m_events[contextKey].active = true;
50  }
51  }
Repository m_events
The all events repository classified by the sessions&#39; keys.
virtual coral::monitor::Level level(const std::string &contextKey) const
std::set< std::string > m_monitoredDS

Member Data Documentation

Repository cond::SQLMonitoringService::m_events
private

The all events repository classified by the sessions' keys.

Definition at line 153 of file SQLMonitoringService.h.

Referenced by active(), disable(), enable(), level(), record(), report(), reportToOutputStream(), and setLevel().

std::set<std::string> cond::SQLMonitoringService::m_monitoredDS
private

Definition at line 154 of file SQLMonitoringService.h.

Referenced by monitoredDataSources(), and setLevel().