CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ora::Monitoring Class Reference

#include <Monitoring.h>

Public Member Functions

void report (std::ostream &out)
 
SessionMonitoringDatastartSession (const std::string &connectionString)
 
virtual ~Monitoring () throw ()
 

Static Public Member Functions

static void enable ()
 
static Monitoringget ()
 
static bool isEnabled ()
 
static const std::string & outFileName ()
 

Private Member Functions

 Monitoring ()
 

Private Attributes

std::map< std::string,
SessionMonitoringData * > 
m_sessions
 

Static Private Attributes

static std::atomic< bool > s_enabled {false}
 

Detailed Description

Definition at line 39 of file Monitoring.h.

Constructor & Destructor Documentation

ora::Monitoring::~Monitoring ( )
throw (
)
virtual

Definition at line 102 of file Monitoring.cc.

References gather_cfg::cout, alignCSCRings::e, relativeConstraints::empty, cppFunctionSkipper::exception, GetRecoTauVFromDQM_MC_cff::outFile, and zeeHLT_cff::report.

102  {
103  if( isEnabled() ){
104  try {
105  if( !outFileName().empty() ){
106  std::ofstream outFile;
107  outFile.open( outFileName().c_str() );
108  if(outFile.good()){
109  report( outFile );
110  outFile.flush();
111  }
112  outFile.close();
113 
114  } else {
115  report( std::cout );
116  }
117  } catch ( const std::exception& e ){
118  std::cout <<"ORA_MONITORING Error: "<<e.what()<<std::endl;
119  }
120  }
121  // clean up memory
122  for(std::map<std::string,SessionMonitoringData*>::const_iterator iS = m_sessions.begin();
123  iS != m_sessions.end();iS++ ){
124  delete iS->second;
125  }
126 }
std::map< std::string, SessionMonitoringData * > m_sessions
Definition: Monitoring.h:61
static const std::string & outFileName()
Definition: Monitoring.cc:96
void report(std::ostream &out)
Definition: Monitoring.cc:134
static bool isEnabled()
Definition: Monitoring.cc:84
tuple cout
Definition: gather_cfg.py:121
ora::Monitoring::Monitoring ( )
private

Definition at line 154 of file Monitoring.cc.

154  :
155  m_sessions(){
156 }
std::map< std::string, SessionMonitoringData * > m_sessions
Definition: Monitoring.h:61

Member Function Documentation

void ora::Monitoring::enable ( )
static

Definition at line 92 of file Monitoring.cc.

92  {
93  s_enabled.store(true,std::memory_order_release);
94 }
static std::atomic< bool > s_enabled
Definition: Monitoring.h:54
ora::Monitoring & ora::Monitoring::get ( void  )
static
bool ora::Monitoring::isEnabled ( )
static

Definition at line 84 of file Monitoring.cc.

Referenced by ora::DatabaseSession::connect().

84  {
85  if(! s_enabled.load(std::memory_order_acquire) ){
86  const char* envVar = ::getenv( "ORA_MONITORING_LEVEL" );
87  if( envVar && ::strcmp(envVar,"SESSION")==0 ) s_enabled.store(true,std::memory_order_release);
88  }
89  return s_enabled.load(std::memory_order_acquire);
90 }
static std::atomic< bool > s_enabled
Definition: Monitoring.h:54
const std::string & ora::Monitoring::outFileName ( )
static

Definition at line 96 of file Monitoring.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

96  {
97  const char* fileEnvVar = ::getenv( "ORA_MONITORING_FILE" );
98  static const std::string s_outFileName( fileEnvVar?fileEnvVar:"");
99  return s_outFileName;
100 }
void ora::Monitoring::report ( std::ostream &  out)

Definition at line 134 of file Monitoring.cc.

References data, j, ora::SessionMonitoringData::m_connectionString, ora::SessionMonitoringData::m_start, ora::SessionMonitoringData::m_stop, and zeeHLT_cff::report.

134  {
135  out << "### ---------------------------------------------------------------------- "<<std::endl;
136  out << "### ORA Monitoring Summary "<<std::endl;
137  out << "### "<<m_sessions.size()<<" session(s) registered."<<std::endl;
138  size_t j = 1;
139  for( std::map<std::string,SessionMonitoringData*>::const_iterator iS = m_sessions.begin();
140  iS != m_sessions.end(); ++iS ){
141  SessionMonitoringData& data = *iS->second;
142  boost::posix_time::time_duration duration;
143  if( !data.m_stop.is_neg_infinity() ){
144  duration = data.m_stop-data.m_start;
145  }
146  out <<" -> Session #"<<j<<": connection=\""<<data.m_connectionString<<"\" duration="<<boost::posix_time::to_simple_string(duration)<<" transactions="<<(iS->second)->numberOfTransactions()<<std::endl;
147  (iS->second)->report(out);
148  j++;
149  }
150  out << "### ---------------------------------------------------------------------- "<<std::endl;
151 
152 }
std::map< std::string, SessionMonitoringData * > m_sessions
Definition: Monitoring.h:61
int j
Definition: DBlmapReader.cc:9
void report(std::ostream &out)
Definition: Monitoring.cc:134
tuple out
Definition: dbtoconf.py:99
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
ora::SessionMonitoringData * ora::Monitoring::startSession ( const std::string &  connectionString)

Definition at line 128 of file Monitoring.cc.

References ora::guidFromTime(), and run_regression::ret.

Referenced by ora::DatabaseSession::connect().

128  {
129  ora::SessionMonitoringData* ret = new SessionMonitoringData( boost::posix_time::microsec_clock::universal_time(), connectionString );
130  m_sessions.insert(std::make_pair(guidFromTime(),ret));
131  return ret;
132 }
std::map< std::string, SessionMonitoringData * > m_sessions
Definition: Monitoring.h:61
std::string guidFromTime()
Definition: Guid.cc:37

Member Data Documentation

std::map<std::string,SessionMonitoringData*> ora::Monitoring::m_sessions
private

Definition at line 61 of file Monitoring.h.

std::atomic< bool > ora::Monitoring::s_enabled {false}
staticprivate

Definition at line 54 of file Monitoring.h.