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

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

Definition at line 28 of file SQLMonitoringService.cc.

  {
  }
  

Member Function Documentation

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

Return monitoring activity status

Definition at line 64 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::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 84 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::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 74 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::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 54 of file SQLMonitoringService.cc.

References m_events, and mergeVDriftHistosByStation::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 181 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 127 of file SQLMonitoringService.cc.

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

  {
    Repository::iterator rit;

    if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
      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() );
    
    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 143 of file SQLMonitoringService.cc.

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

    {
      Repository::iterator rit;

      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        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() );

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

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

    {
      Repository::iterator rit;

      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        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() );

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

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

    {
      Repository::iterator rit;
      
      if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
        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() );
      
      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 111 of file SQLMonitoringService.cc.

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

  {
    Repository::iterator rit;

    if( ( rit = m_events.find( contextKey ) ) == m_events.end() )
      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() );
    
    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 196 of file SQLMonitoringService.cc.

References create_public_lumi_plots::log, m_events, mergeVDriftHistosByStation::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 186 of file SQLMonitoringService.cc.

References create_public_lumi_plots::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 175 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 323 of file SQLMonitoringService.cc.

References Debug, Default, and reportOnEvent().

Referenced by report(), and reportToOutputStream().

    {
      os << "Session: " << (*it).first << std::endl;
      std::string lvl;
      switch( (*it).second.level ) {
      case (coral::monitor::Off)     : lvl = "Off"; break;
      case (coral::monitor::Minimal) : lvl = "Minimal"; break;
      case (coral::monitor::Default) : lvl = "Default"; break;
      case (coral::monitor::Debug)   : lvl = "Debug"; break;
      case (coral::monitor::Trace)   : lvl = "Trace"; break;
      default: lvl = "";
      };
      os << "Monitoring Level: " << lvl << std::endl;
      
      const EventStream& evsref = (*it).second.stream;
      os << " Recorded " << evsref.size() << " events" << std::endl;
      
      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 346 of file SQLMonitoringService.cc.

References Debug, Default, edm::endmsg(), and reportOnEvent().

    {
      os << "Session: " << (*it).first;
      std::string lvl;
      switch( (*it).second.level ) {
      case (coral::monitor::Off)     : lvl = "Off"; break;
      case (coral::monitor::Minimal) : lvl = "Minimal"; break;
      case (coral::monitor::Default) : lvl = "Default"; break;
      case (coral::monitor::Debug)   : lvl = "Debug"; break;
      case (coral::monitor::Trace)   : lvl = "Trace"; break;
      default: lvl = "";
      };
      os << " monitored at level: " << lvl;
      
      const EventStream& evsref = (*it).second.stream;
      os << lvl << " has recorded " << evsref.size() << " events" << coral::MessageStream::endmsg;
      
      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 222 of file SQLMonitoringService.cc.

References LaserTracksInput_cfi::source.

Referenced by reportForSession().

  {
    std::string source("");
    switch( it->m_source ) {
    case coral::monitor::Application:
      source = "Application";
      break;
    case coral::monitor::Session:
      source = "Session";
      break;
    case coral::monitor::Transaction:
      source = "Transaction";
      break;
    case coral::monitor::Statement:
      source = "Statement";
      break;
    default:
      source = "";
    };
    
    std::string type("");
    switch( it->m_type ) {
    case coral::monitor::Info:
      type = "Info";
      break;
    case coral::monitor::Time:
      type = "Time";
      break;
    case coral::monitor::Warning:
      type = "Warning";
      break;
    case coral::monitor::Error:
      type = "Error";
      break;
    case coral::monitor::Config:
      type = "Config";
      break;
    default:
      type = "";
    };
    
    if(it->m_source == coral::monitor::Statement || it->m_source == coral::monitor::Transaction)
      {
        os << boost::posix_time::to_iso_extended_string((*it).m_time.time()) << ": " 
           << source << "; "
           << type << "; " 
           <<(*it).m_description << ";"<< std::endl;
      }
  }
  
void cond::SQLMonitoringService::reportOnEvent ( EventStream::const_iterator &  it,
coral::MessageStream &  os 
) const

Definition at line 273 of file SQLMonitoringService.cc.

References LaserTracksInput_cfi::source.

    {
      std::string source("");
      switch( it->m_source ) {
      case coral::monitor::Application:
        source = "Application";
        break;
      case coral::monitor::Session:
        source = "Session";
        break;
      case coral::monitor::Transaction:
        source = "Transaction";
        break;
      case coral::monitor::Statement:
        source = "Statement";
        break;
      default:
        source = "";
      };
      
      std::string type("");
      switch( it->m_type ) {
      case coral::monitor::Info:
        type = "Info";
        break;
      case coral::monitor::Time:
        type = "Time";
        break;
      case coral::monitor::Warning:
        type = "Warning";
        break;
      case coral::monitor::Error:
        type = "Error";
        break;
      case coral::monitor::Config:
        type = "Config";
        break;
      default:
        type = "";
      };
      
      if(it->m_source == coral::monitor::Statement || it->m_source == coral::monitor::Transaction)
        {
          os << boost::posix_time::to_iso_extended_string((*it).m_time.time()) << ": " 
             << source << "; "
             << type << "; " 
             << (*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 209 of file SQLMonitoringService.cc.

References create_public_lumi_plots::log, m_events, mergeVDriftHistosByStation::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 32 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().