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 "SealKernel/Service.h"
00011
00012 #include <string>
00013 #include <map>
00014 #include <vector>
00015
00016 namespace seal
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 seal::Service, virtual public coral::monitor::IMonitoringService, virtual public coral::IMonitoringReporter
00041 {
00042 DECLARE_SEAL_COMPONENT;
00043
00044 public:
00045 explicit SQLMonitoringService( seal::Context* );
00046 explicit SQLMonitoringService( seal::Context*, const std::string& );
00047 virtual ~SQLMonitoringService();
00048
00049 public:
00056 virtual void setLevel( const std::string& contextKey, coral::monitor::Level level );
00057
00061 virtual coral::monitor::Level level( const std::string& contextKey ) const;
00062
00066 virtual bool active( const std::string& contextKey ) const;
00067
00068 virtual void enable( const std::string& contextKey );
00069 virtual void disable( const std::string& contextKey );
00070
00074 virtual void record( const std::string& contextKey,
00075 coral::monitor::Source source,
00076 coral::monitor::Type type,
00077 const std::string& description );
00078
00082 virtual void record( const std::string& contextKey,
00083 coral::monitor::Source source,
00084 coral::monitor::Type type,
00085 const std::string& description,
00086 int data );
00087
00091 virtual void record( const std::string& contextKey,
00092 coral::monitor::Source source,
00093 coral::monitor::Type type,
00094 const std::string& description,
00095 double data );
00096
00100 virtual void record( const std::string& contextKey,
00101 coral::monitor::Source source,
00102 coral::monitor::Type type,
00103 const std::string& description,
00104 const std::string& data );
00105
00109 virtual const coral::IMonitoringReporter& reporter() const;
00110
00111
00112
00113
00114
00118 virtual std::set< std::string > monitoredDataSources() const;
00119
00124 virtual void report( unsigned int level ) const;
00125
00130 virtual void report( const std::string& contextKey, unsigned int level ) const;
00131
00136 virtual void reportToOutputStream( const std::string& contextKey, std::ostream& os, unsigned int level ) const;
00137
00138 void reportOnEvent( EventStream::const_iterator& it, std::ostream& os ) const;
00139 void reportOnEvent( EventStream::const_iterator& it, seal::MessageStream& os ) const;
00140
00141 void reportForSession( Repository::const_iterator& it, std::ostream& os ) const;
00142 void reportForSession( Repository::const_iterator& it, seal::MessageStream& os ) const;
00143 private:
00144
00146 Repository m_events;
00147 std::set<std::string> m_monitoredDS;
00148 };
00149 }
00150
00151 #endif // COND_SQLMONITORINGSERVICE_H