CMS 3D CMS Logo

Public Member Functions | Private Attributes

cond::SQLMonitoringService Class Reference

#include <SQLMonitoringService.h>

List of all members.

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 (const std::string &contextKey, unsigned int level) const
virtual void report (unsigned int level) const
virtual const
coral::IMonitoringReporter & 
reporter () const
void reportForSession (Repository::const_iterator &it, coral::MessageStream &os) const
void reportForSession (Repository::const_iterator &it, std::ostream &os) const
void reportOnEvent (EventStream::const_iterator &it, coral::MessageStream &os) const
void reportOnEvent (EventStream::const_iterator &it, std::ostream &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.
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.

    : coral::Service( key ),
      m_events()
  {
  }
  
cond::SQLMonitoringService::~SQLMonitoringService ( ) [virtual]

Definition at line 27 of file SQLMonitoringService.cc.

  {
  }
  

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 AlCaRecoCosmics_cfg::name.

Referenced by record().

  {
    Repository::const_iterator rit;
    
    if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
      throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::active", this->name() );
    
    return (*rit).second.active;
  }
  
void cond::SQLMonitoringService::disable ( const std::string &  contextKey) [virtual]

Definition at line 83 of file SQLMonitoringService.cc.

References m_events, and AlCaRecoCosmics_cfg::name.

    {
      Repository::iterator rit;
      
      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::disable", this->name() );
      
      (*rit).second.active = false;
    }
  
void cond::SQLMonitoringService::enable ( const std::string &  contextKey) [virtual]

Definition at line 73 of file SQLMonitoringService.cc.

References m_events, and AlCaRecoCosmics_cfg::name.

    {
      Repository::iterator rit;
      
      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::enable", this->name() );

      (*rit).second.active = true;
    }

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 AlCaRecoCosmics_cfg::name.

Referenced by setLevel().

  {
    Repository::const_iterator rit;
    
    if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
      throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::level", this->name() );
    
    return (*rit).second.level;
  }
  
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.

    {
      return m_monitoredDS;
    }

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 AlCaRecoCosmics_cfg::name.

  {
    Repository::iterator rit;

    if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
      throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
    
    bool                  active = (*rit).second.active;
    //coral::monitor::Level level  = (*rit).second.level;
    
    if( active/* && (type & level)*/ )
      {
        (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
      }
  }

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 AlCaRecoCosmics_cfg::name.

    {
      Repository::iterator rit;

      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );

      bool                  active = (*rit).second.active;
      //coral::monitor::Level level  = (*rit).second.level;
      
      if( active/* && (type & level)*/ )
      {
        (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
      }
    }

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 AlCaRecoCosmics_cfg::name.

    {
      Repository::iterator rit;

      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );

      bool                  active = (*rit).second.active;
      //coral::monitor::Level level  = (*rit).second.level;
      
      if( active /*&& (type & level)*/ )
      {
        (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
      }
    }

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 AlCaRecoCosmics_cfg::name.

    {
      Repository::iterator rit;
      
      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
      
      bool                  active = (*rit).second.active;
      //coral::monitor::Level level  = (*rit).second.level;
       
      if( active/* && (type & level)*/ )
      {
        (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description ) );
      }
    }

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 AlCaRecoCosmics_cfg::name.

  {
    Repository::iterator rit;

    if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
      throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );
    
    bool                  active = (*rit).second.active;
    //coral::monitor::Level level  = (*rit).second.level;
    
    if( active/* && (type & level)*/ )
      {
        (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
      }
  }

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 funct::log(), m_events, AlCaRecoCosmics_cfg::name, and reportForSession().

    {
      Repository::const_iterator rit;
      
      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );

      // Dummy reporting so far
      coral::MessageStream log( "MonitoringService" );

      reportForSession( rit, log );
    }

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 funct::log(), m_events, and reportForSession().

    {
      Repository::const_iterator rit;
      coral::MessageStream  log( "MonitoringService" );
      
      // Dummy reporting so far
      for( rit = m_events.begin(); rit != m_events.end(); ++rit )
        reportForSession( rit, log );
    }

const coral::IMonitoringReporter & cond::SQLMonitoringService::reporter ( ) const [virtual]

Return the current reporter

Definition at line 174 of file SQLMonitoringService.cc.

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

Definition at line 238 of file SQLMonitoringService.cc.

References reportOnEvent().

Referenced by report(), and reportToOutputStream().

    {
      const EventStream& evsref = (*it).second.stream;
      
      for( EventStream::const_iterator evit = evsref.begin(); evit != evsref.end(); ++evit )
      {
        reportOnEvent( evit, os );
      }
    }

void cond::SQLMonitoringService::reportForSession ( Repository::const_iterator &  it,
coral::MessageStream &  os 
) const

Definition at line 248 of file SQLMonitoringService.cc.

References reportOnEvent().

    {
      const EventStream& evsref = (*it).second.stream;
      
      for( EventStream::const_iterator evit = evsref.begin(); evit != evsref.end(); ++evit )
      {
        reportOnEvent( evit, os );
      }

    }
    
void cond::SQLMonitoringService::reportOnEvent ( EventStream::const_iterator &  it,
std::ostream &  os 
) const

Definition at line 221 of file SQLMonitoringService.cc.

Referenced by reportForSession().

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

Definition at line 230 of file SQLMonitoringService.cc.

    {
      if(it->m_source == coral::monitor::Statement)
        {
          os << (*it).m_description <<coral::MessageStream::flush;
        }
    }

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 funct::log(), m_events, AlCaRecoCosmics_cfg::name, and reportForSession().

    {
      Repository::const_iterator rit;
      
      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        throw coral::MonitoringException( "Monitoring for session " + contextKey + " not initialized...", "MonitoringService::record", this->name() );

      // Dummy reporting so far
      coral::MessageStream log( "MonitoringService" );

      reportForSession( rit, os );
    }

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.

  {
    Repository::const_iterator rit;
    
    if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
      {        
        m_events[contextKey] = SessionMonitor();
        m_monitoredDS.insert( contextKey );
      }
    
    m_events[contextKey].level = level;
    
    if( level == coral::monitor::Off )
      {
        m_events[contextKey].active = false;
      }
    else
      {
        m_events[contextKey].active = true;        
      }
    }
  

Member Data Documentation

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().