CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

ora::Monitoring Class Reference

#include <Monitoring.h>

List of all members.

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 std::string & outFileName ()

Private Member Functions

 Monitoring ()

Private Attributes

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

Static Private Attributes

static bool s_enabled = false

Detailed Description

Definition at line 38 of file Monitoring.h.


Constructor & Destructor Documentation

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

Definition at line 106 of file Monitoring.cc.

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

                                  {
  if( isEnabled() ){
    try {
      if( !outFileName().empty() ){
        std::ofstream outFile;
        outFile.open(  outFileName().c_str() );
        if(outFile.good()){
          report( outFile );
          outFile.flush();
        }
        outFile.close();
        
      } else {
        report( std::cout );
      }
    } catch ( const std::exception& e ){
      std::cout <<"ORA_MONITORING Error: "<<e.what()<<std::endl;
    }
  }
  // clean up memory
  for(std::map<std::string,SessionMonitoringData*>::const_iterator iS = m_sessions.begin();
      iS != m_sessions.end();iS++ ){
    delete iS->second;
  }
}
ora::Monitoring::Monitoring ( ) [private]

Definition at line 158 of file Monitoring.cc.

                         :
  m_sessions(){
}

Member Function Documentation

void ora::Monitoring::enable ( ) [static]

Definition at line 91 of file Monitoring.cc.

                          {
  s_enabled = true;
}
ora::Monitoring & ora::Monitoring::get ( void  ) [static]

Definition at line 78 of file Monitoring.cc.

                                 {
  static ora::Monitoring s_mon;
  return s_mon;
}
bool ora::Monitoring::isEnabled ( ) [static]

Definition at line 83 of file Monitoring.cc.

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

                             {
  if(! s_enabled ){
    const char* envVar = ::getenv( "ORA_MONITORING_LEVEL" );
    if( envVar && ::strcmp(envVar,"SESSION")==0 ) s_enabled = true;
  }
  return s_enabled;
}
std::string & ora::Monitoring::outFileName ( ) [static]

Definition at line 95 of file Monitoring.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

                                     {
  static std::string s_outFileName("");
  if( s_outFileName.empty() ){
    const char* fileEnvVar = ::getenv( "ORA_MONITORING_FILE" );
    if( fileEnvVar ){
      s_outFileName = fileEnvVar;
    }
  }
  return s_outFileName;
}
void ora::Monitoring::report ( std::ostream &  out)

Definition at line 138 of file Monitoring.cc.

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

                                           {
  out << "### ---------------------------------------------------------------------- "<<std::endl;
  out << "### ORA Monitoring Summary "<<std::endl;
  out << "### "<<m_sessions.size()<<" session(s) registered."<<std::endl;
  size_t j = 1;
  for( std::map<std::string,SessionMonitoringData*>::const_iterator iS = m_sessions.begin();
       iS != m_sessions.end(); ++iS ){
    SessionMonitoringData& data = *iS->second;
    boost::posix_time::time_duration duration;
    if( !data.m_stop.is_neg_infinity() ){
      duration = data.m_stop-data.m_start;
    }
    out <<" -> Session #"<<j<<": connection=\""<<data.m_connectionString<<"\" duration="<<boost::posix_time::to_simple_string(duration)<<" transactions="<<(iS->second)->numberOfTransactions()<<std::endl;
    (iS->second)->report(out);
    j++;
  }
  out << "### ---------------------------------------------------------------------- "<<std::endl;

}
ora::SessionMonitoringData * ora::Monitoring::startSession ( const std::string &  connectionString)

Definition at line 132 of file Monitoring.cc.

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

                                                                                        {
  ora::SessionMonitoringData* ret = new SessionMonitoringData( boost::posix_time::microsec_clock::universal_time(), connectionString );
  m_sessions.insert(std::make_pair(guidFromTime(),ret));
  return ret;
}

Member Data Documentation

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

Definition at line 60 of file Monitoring.h.

bool ora::Monitoring::s_enabled = false [static, private]

Definition at line 53 of file Monitoring.h.