CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/CondCore/DBCommon/plugins/SQLMonitoringService.h

Go to the documentation of this file.
00001 #ifndef COND_SQLMONITORINGSERVICE_H
00002 #define COND_SQLMONITORINGSERVICE_H
00003 
00004 #include "RelationalAccess/IMonitoringService.h"
00005 #include "RelationalAccess/IMonitoringReporter.h"
00006 
00007 #include "CoralCommon/MonitoringReportTypes.h"
00008 #include "CoralCommon/MonitoringEvent.h"
00009 
00010 #include "CoralKernel/Service.h"
00011 
00012 #include <string>
00013 #include <map>
00014 #include <vector>
00015 
00016 namespace coral
00017 {
00018   class MessageStream;
00019 }
00020 
00021 namespace cond
00022 {
00024   typedef std::vector<coral::monitor::Event::Record> EventStream;
00025 
00027   struct SessionMonitor{
00028       SessionMonitor();
00029       SessionMonitor( bool, coral::monitor::Level );
00030 
00031       bool                  active;
00032       coral::monitor::Level level;
00033       EventStream           stream;
00034   };
00035 
00038   typedef std::map< std::string, SessionMonitor > Repository;
00039 
00040   class SQLMonitoringService : public coral::Service, virtual public coral::monitor::IMonitoringService, virtual public coral::IMonitoringReporter
00041     {
00042 
00043       public:
00044         explicit SQLMonitoringService( const std::string& );        
00045         virtual ~SQLMonitoringService();
00046 
00047       public:
00054         virtual void setLevel( const std::string& contextKey, coral::monitor::Level level );
00055 
00059         virtual coral::monitor::Level level( const std::string& contextKey ) const;
00060 
00064         virtual bool active( const std::string& contextKey ) const;
00065 
00066         virtual void enable( const std::string& contextKey );
00067         virtual void disable( const std::string& contextKey );
00068         
00072         virtual void record( const std::string& contextKey,
00073                              coral::monitor::Source source,
00074                              coral::monitor::Type type,
00075                              const std::string& description );
00076 
00080         virtual void record( const std::string& contextKey,
00081                              coral::monitor::Source source,
00082                              coral::monitor::Type type,
00083                              const std::string& description,
00084                              int data );
00085 
00089         virtual void record( const std::string& contextKey,
00090                              coral::monitor::Source source,
00091                              coral::monitor::Type type,
00092                              const std::string& description,
00093                              long long data );
00094         
00098         virtual void record( const std::string& contextKey,
00099                              coral::monitor::Source source,
00100                              coral::monitor::Type type,
00101                              const std::string& description,
00102                              double data );
00103 
00107         virtual void record( const std::string& contextKey,
00108                              coral::monitor::Source source,
00109                              coral::monitor::Type type,
00110                              const std::string& description,
00111                              const std::string& data );
00112 
00116         virtual const coral::IMonitoringReporter& reporter() const;
00117 
00118         //
00119         // The coral::IMonitoringReporter interface implementation
00120         //
00121         
00125         virtual std::set< std::string > monitoredDataSources() const;
00126         
00131         virtual void report( unsigned int level ) const;
00132 
00137         virtual void report( const std::string& contextKey, unsigned int level ) const;
00138 
00143         virtual void reportToOutputStream( const std::string& contextKey, std::ostream& os, unsigned int level ) const;
00144 
00145         void reportOnEvent( EventStream::const_iterator& it, std::ostream&        os ) const;
00146         void reportOnEvent( EventStream::const_iterator& it, coral::MessageStream& os ) const;
00147 
00148         void reportForSession( Repository::const_iterator& it, std::ostream&        os ) const;
00149         void reportForSession( Repository::const_iterator& it, coral::MessageStream& os ) const;
00150       private:
00151 
00153         Repository            m_events;
00154         std::set<std::string> m_monitoredDS;
00155     };
00156 } // namespace cond
00157 
00158 #endif // COND_SQLMONITORINGSERVICE_H