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 20 of file SQLMonitoringService.cc.

21  : coral::Service( key ),
22  m_events()
23  {
24  }
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 26 of file SQLMonitoringService.cc.

27  {
28  }

Member Function Documentation

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

Return monitoring activity status

Definition at line 62 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::name.

Referenced by record().

63  {
64  Repository::const_iterator rit;
65 
66  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
67  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::active", this->name() );
68 
69  return (*rit).second.active;
70  }
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 82 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::name.

83  {
84  Repository::iterator rit;
85 
86  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
87  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::disable", this->name() );
88 
89  (*rit).second.active = false;
90  }
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 72 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::name.

73  {
74  Repository::iterator rit;
75 
76  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
77  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::enable", this->name() );
78 
79  (*rit).second.active = true;
80  }
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 52 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::name.

Referenced by setLevel().

53  {
54  Repository::const_iterator rit;
55 
56  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
57  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::level", this->name() );
58 
59  return (*rit).second.level;
60  }
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 179 of file SQLMonitoringService.cc.

References m_monitoredDS.

180  {
181  return m_monitoredDS;
182  }
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 93 of file SQLMonitoringService.cc.

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

94  {
95  Repository::iterator rit;
96 
97  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
98  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
99 
100  bool active = (*rit).second.active;
101  //coral::monitor::Level level = (*rit).second.level;
102 
103  if( active/* && (type & level)*/ )
104  {
105  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description ) );
106  }
107  }
type
Definition: HCALResponse.h:22
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
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 109 of file SQLMonitoringService.cc.

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

110  {
111  Repository::iterator rit;
112 
113  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
114  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
115 
116  bool active = (*rit).second.active;
117  //coral::monitor::Level level = (*rit).second.level;
118 
119  if( active/* && (type & level)*/ )
120  {
121  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
122  }
123  }
type
Definition: HCALResponse.h:22
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
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 125 of file SQLMonitoringService.cc.

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

126  {
127  Repository::iterator rit;
128 
129  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
130  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
131 
132  bool active = (*rit).second.active;
133  //coral::monitor::Level level = (*rit).second.level;
134 
135  if( active/* && (type & level)*/ )
136  {
137  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
138  }
139  }
type
Definition: HCALResponse.h:22
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
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 141 of file SQLMonitoringService.cc.

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

142  {
143  Repository::iterator rit;
144 
145  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
146  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
147 
148  bool active = (*rit).second.active;
149  //coral::monitor::Level level = (*rit).second.level;
150 
151  if( active/* && (type & level)*/ )
152  {
153  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
154  }
155  }
type
Definition: HCALResponse.h:22
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
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 157 of file SQLMonitoringService.cc.

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

158  {
159  Repository::iterator rit;
160 
161  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
162  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
163 
164  bool active = (*rit).second.active;
165  //coral::monitor::Level level = (*rit).second.level;
166 
167  if( active /*&& (type & level)*/ )
168  {
169  (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
170  }
171  }
type
Definition: HCALResponse.h:22
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
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 184 of file SQLMonitoringService.cc.

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

185  {
186  Repository::const_iterator rit;
187  coral::MessageStream log( "MonitoringService" );
188 
189  // Dummy reporting so far
190  for( rit = m_events.begin(); rit != m_events.end(); ++rit )
191  reportForSession( rit, log );
192  }
Log< T >::type log(const T &t)
Definition: Log.h:22
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 194 of file SQLMonitoringService.cc.

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

195  {
196  Repository::const_iterator rit;
197 
198  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
199  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
200 
201  // Dummy reporting so far
202  coral::MessageStream log( "MonitoringService" );
203 
204  reportForSession( rit, log );
205  }
Log< T >::type log(const T &t)
Definition: Log.h:22
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 173 of file SQLMonitoringService.cc.

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

Definition at line 237 of file SQLMonitoringService.cc.

References reportOnEvent().

Referenced by report(), and reportToOutputStream().

238  {
239  const EventStream& evsref = (*it).second.stream;
240 
241  for( EventStream::const_iterator evit = evsref.begin(); evit != evsref.end(); ++evit )
242  {
243  reportOnEvent( evit, os );
244  }
245  }
void reportOnEvent(EventStream::const_iterator &it, std::ostream &os) const
std::vector< coral::monitor::Event::Record > EventStream
The raw stream of recorder monitoring events.
void cond::SQLMonitoringService::reportForSession ( Repository::const_iterator &  it,
coral::MessageStream &  os 
) const

Definition at line 247 of file SQLMonitoringService.cc.

References reportOnEvent().

248  {
249  const EventStream& evsref = (*it).second.stream;
250 
251  for( EventStream::const_iterator evit = evsref.begin(); evit != evsref.end(); ++evit )
252  {
253  reportOnEvent( evit, os );
254  }
255 
256  }
void reportOnEvent(EventStream::const_iterator &it, std::ostream &os) const
std::vector< coral::monitor::Event::Record > EventStream
The raw stream of recorder monitoring events.
void cond::SQLMonitoringService::reportOnEvent ( EventStream::const_iterator &  it,
std::ostream &  os 
) const

Definition at line 220 of file SQLMonitoringService.cc.

Referenced by reportForSession().

221  {
222  if(it->m_source == coral::monitor::Statement)
223  {
224  os << (*it).m_description << ";"<< std::endl;
225  }
226  }
void cond::SQLMonitoringService::reportOnEvent ( EventStream::const_iterator &  it,
coral::MessageStream &  os 
) const

Definition at line 229 of file SQLMonitoringService.cc.

230  {
231  if(it->m_source == coral::monitor::Statement)
232  {
233  os << (*it).m_description <<coral::MessageStream::flush;
234  }
235  }
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 207 of file SQLMonitoringService.cc.

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

208  {
209  Repository::const_iterator rit;
210 
211  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
212  throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
213 
214  // Dummy reporting so far
215  coral::MessageStream log( "MonitoringService" );
216 
217  reportForSession( rit, os );
218  }
Log< T >::type log(const T &t)
Definition: Log.h:22
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 30 of file SQLMonitoringService.cc.

References level(), m_events, and m_monitoredDS.

31  {
32  Repository::const_iterator rit;
33 
34  if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
35  {
36  m_events[contextKey] = SessionMonitor();
37  m_monitoredDS.insert( contextKey );
38  }
39 
40  m_events[contextKey].level = level;
41 
42  if( level == coral::monitor::Off )
43  {
44  m_events[contextKey].active = false;
45  }
46  else
47  {
48  m_events[contextKey].active = true;
49  }
50  }
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().