CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes

cond::DbConnectionConfiguration Class Reference

#include <DbConnectionConfiguration.h>

List of all members.

Public Member Functions

const std::string & authenticationPath () const
void configure (coral::IConnectionServiceConfiguration &coralConfig) const
int connectionRetrialPeriod () const
int connectionRetrialTimeOut () const
int connectionTimeOut () const
 DbConnectionConfiguration (bool connectionSharing, int connectionTimeOut, bool readOnlySessionOnUpdateConnections, int connectionRetrialPeriod, int connectionRetrialTimeOut, bool poolAutomaticCleanUp, const std::string &authenticationPath, const std::string &transactionId, coral::MsgLevel msgLev, coral::monitor::Level monitorLev, bool SQLMonitoring)
 DbConnectionConfiguration ()
 DbConnectionConfiguration (const DbConnectionConfiguration &rhs)
bool isConnectionSharingEnabled () const
bool isPoolAutomaticCleanUpEnabled () const
bool isReadOnlySessionOnUpdateConnectionEnabled () const
bool isSQLMonitoringEnabled () const
coral::MsgLevel messageLevel () const
DbConnectionConfigurationoperator= (const DbConnectionConfiguration &rhs)
void setAuthenticationPath (const std::string &p)
void setAuthenticationSystem (int authSysCode)
void setConnectionRetrialPeriod (int period)
void setConnectionRetrialTimeOut (int timeout)
void setConnectionSharing (bool flag)
void setConnectionTimeOut (int timeOut)
void setMessageLevel (coral::MsgLevel l)
void setMonitoringLevel (coral::monitor::Level l)
void setParameters (const edm::ParameterSet &connectionPset)
void setPoolAutomaticCleanUp (bool flag)
void setReadOnlySessionOnUpdateConnections (bool flag)
void setSQLMonitoring (bool flag)
void setTransactionId (std::string const &tid)
const std::string & transactionId () const
 ~DbConnectionConfiguration ()

Static Public Member Functions

static std::vector
< DbConnectionConfiguration > & 
defaultConfigurations ()

Private Attributes

std::string m_authPath
int m_authSys
std::pair< bool, int > m_connectionRetrialPeriod
std::pair< bool, int > m_connectionRetrialTimeOut
std::pair< bool, bool > m_connectionSharing
std::pair< bool, int > m_connectionTimeOut
coral::MsgLevel m_messageLevel
coral::monitor::Level m_monitoringLevel
CoralServiceManagerm_pluginManager
std::pair< bool, bool > m_poolAutomaticCleanUp
std::pair< bool, bool > m_readOnlySessionOnUpdateConnections
bool m_SQLMonitoring
std::string m_transactionId

Detailed Description

Definition at line 32 of file DbConnectionConfiguration.h.


Constructor & Destructor Documentation

cond::DbConnectionConfiguration::DbConnectionConfiguration ( )
cond::DbConnectionConfiguration::DbConnectionConfiguration ( bool  connectionSharing,
int  connectionTimeOut,
bool  readOnlySessionOnUpdateConnections,
int  connectionRetrialPeriod,
int  connectionRetrialTimeOut,
bool  poolAutomaticCleanUp,
const std::string &  authenticationPath,
const std::string &  transactionId,
coral::MsgLevel  msgLev,
coral::monitor::Level  monitorLev,
bool  SQLMonitoring 
)
cond::DbConnectionConfiguration::DbConnectionConfiguration ( const DbConnectionConfiguration rhs)

Definition at line 74 of file DbConnectionConfiguration.cc.

                                                                                                 :
  m_connectionSharing(rhs.m_connectionSharing),
  m_connectionTimeOut(rhs.m_connectionTimeOut),
  m_readOnlySessionOnUpdateConnections(rhs.m_readOnlySessionOnUpdateConnections),
  m_connectionRetrialPeriod(rhs.m_connectionRetrialPeriod),
  m_connectionRetrialTimeOut(rhs.m_connectionRetrialTimeOut),
  m_poolAutomaticCleanUp(rhs.m_poolAutomaticCleanUp),
  m_authPath(rhs.m_authPath),
  m_authSys(rhs.m_authSys),
  m_transactionId(rhs.m_transactionId),
  m_messageLevel(rhs.m_messageLevel),
  m_monitoringLevel(rhs.m_monitoringLevel),
  m_SQLMonitoring(rhs.m_SQLMonitoring),
  m_pluginManager(new CoralServiceManager){
}
cond::DbConnectionConfiguration::~DbConnectionConfiguration ( )

Definition at line 90 of file DbConnectionConfiguration.cc.

                                                         {
  delete m_pluginManager;
}

Member Function Documentation

const std::string & cond::DbConnectionConfiguration::authenticationPath ( ) const

Definition at line 326 of file DbConnectionConfiguration.cc.

{
  return m_authPath;
}
void cond::DbConnectionConfiguration::configure ( coral::IConnectionServiceConfiguration &  coralConfig) const

Definition at line 207 of file DbConnectionConfiguration.cc.

References builder_last_value_cfg::authPath, cond::Auth::COND_AUTH_PATH, cond::Auth::COND_AUTH_PATH_PROPERTY, cond::Auth::COND_AUTH_SYS, cond::CondDbKey, cond::CoralXMLFile, and instance.

{
  // message streaming
  coral::MessageStream::setMsgVerbosity( m_messageLevel );
  std::string authServiceName("CORAL/Services/EnvironmentAuthenticationService");
  std::string authPath = m_authPath;
  // authentication
  if( authPath.empty() ){
    // first try to check the env...
    const char* authEnv = ::getenv( Auth::COND_AUTH_PATH );
    if(authEnv){
      authPath += authEnv;
    } 
  }
  int authSys = m_authSys;
  if( authSys != CondDbKey && authSys != CoralXMLFile ){
    // first attempt, look at the env...
    const char* authSysEnv = ::getenv( Auth::COND_AUTH_SYS );
    if( authSysEnv ){
      authSys = ::atoi( authSysEnv );
    }
  }
  if( authSys != CondDbKey && authSys != CoralXMLFile ){
    // take the default
    authSys = CoralXMLFile;
  }  
  std::string servName("");
  if( authSys == CondDbKey ){
    if( authPath.empty() ){
      const char* authEnv = ::getenv("HOME");
      if(authEnv){
        authPath += authEnv;
      } 
    }
    servName = "COND/Services/RelationalAuthenticationService";     
    //edm::LogInfo("DbSessionInfo") << "Authentication using Keys";  
  } else if( authSys == CoralXMLFile ){
    if( authPath.empty() ){
      authPath = ".";
    }
    servName = "COND/Services/XMLAuthenticationService";  
    //edm::LogInfo("DbSessionInfo") << "Authentication using XML File";  
  }
  if( !authPath.empty() ){
    authServiceName = servName;    
    coral::Context::instance().PropertyManager().property(Auth::COND_AUTH_PATH_PROPERTY)->set(authPath);  
    coral::Context::instance().loadComponent( authServiceName, m_pluginManager );
  }
  coralConfig.setAuthenticationService( authServiceName );
  // connection sharing
  if(m_connectionSharing.first)
  {
    if(m_connectionSharing.second) coralConfig.enableConnectionSharing();
    else coralConfig.disableConnectionSharing();   
  }
  // connection timeout
  if(m_connectionTimeOut.first)
  {
    coralConfig.setConnectionTimeOut(m_connectionTimeOut.second);    
  }
  // read only session on update connection
  if(m_readOnlySessionOnUpdateConnections.first)
  {
    if(m_readOnlySessionOnUpdateConnections.second) coralConfig.enableReadOnlySessionOnUpdateConnections();
    else coralConfig.disableReadOnlySessionOnUpdateConnections();    
  }
  // pool automatic clean up
  if(m_poolAutomaticCleanUp.first)
  {
    if(m_poolAutomaticCleanUp.second) coralConfig.enablePoolAutomaticCleanUp();
    else coralConfig.disablePoolAutomaticCleanUp();
  }
  // connection retrial period
  if(m_connectionRetrialPeriod.first) 
  {
    coralConfig.setConnectionRetrialPeriod( m_connectionRetrialPeriod.second );    
  }
  // connection retrial timeout
  if( m_connectionRetrialTimeOut.first)
  {
    coralConfig.setConnectionRetrialTimeOut(m_connectionRetrialTimeOut.second );    
  }
  // monitoring level
  coralConfig.setMonitoringLevel( m_monitoringLevel );
  // SQL monitoring
  if( m_SQLMonitoring )
  {
    std::string pluginName("COND/Services/SQLMonitoringService");
    coral::Context::instance().loadComponent( pluginName, m_pluginManager );
    coralConfig.setMonitoringLevel(coral::monitor::Trace);   
  }
  
}
int cond::DbConnectionConfiguration::connectionRetrialPeriod ( ) const

Definition at line 314 of file DbConnectionConfiguration.cc.

                                                                 {
  return m_connectionRetrialPeriod.second;  
}
int cond::DbConnectionConfiguration::connectionRetrialTimeOut ( ) const

Definition at line 318 of file DbConnectionConfiguration.cc.

                                                                  {
  return m_connectionRetrialTimeOut.second;
}
int cond::DbConnectionConfiguration::connectionTimeOut ( ) const

Definition at line 306 of file DbConnectionConfiguration.cc.

                                                           {
  return m_connectionTimeOut.second;  
}
std::vector< cond::DbConnectionConfiguration > & cond::DbConnectionConfiguration::defaultConfigurations ( ) [static]

Definition at line 17 of file DbConnectionConfiguration.cc.

Referenced by cond::DbConnection::configure().

                                                    {
  static std::vector<DbConnectionConfiguration> s_defaultConfigurations;
  // coral default
  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration() );
  // cms default
  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "", coral::Error, coral::monitor::Off, false ) );
  // prod default
  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "", coral::Error, coral::monitor::Off, false ) );
  // tool default
  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "",coral::Error, coral::monitor::Off, false ) );
  // web default
  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "",coral::Error, coral::monitor::Off, false ) );
  return s_defaultConfigurations;
}
bool cond::DbConnectionConfiguration::isConnectionSharingEnabled ( ) const

Definition at line 301 of file DbConnectionConfiguration.cc.

{
  return m_connectionSharing.second;  
}
bool cond::DbConnectionConfiguration::isPoolAutomaticCleanUpEnabled ( ) const

Definition at line 322 of file DbConnectionConfiguration.cc.

                                                                        {
  return m_poolAutomaticCleanUp.second;  
}
bool cond::DbConnectionConfiguration::isReadOnlySessionOnUpdateConnectionEnabled ( ) const

Definition at line 310 of file DbConnectionConfiguration.cc.

bool cond::DbConnectionConfiguration::isSQLMonitoringEnabled ( ) const

Definition at line 341 of file DbConnectionConfiguration.cc.

{
  return m_SQLMonitoring;  
}
coral::MsgLevel cond::DbConnectionConfiguration::messageLevel ( ) const

Definition at line 336 of file DbConnectionConfiguration.cc.

{
  return m_messageLevel;
}
cond::DbConnectionConfiguration & cond::DbConnectionConfiguration::operator= ( const DbConnectionConfiguration rhs)

Definition at line 95 of file DbConnectionConfiguration.cc.

References m_authPath, m_authSys, m_connectionRetrialPeriod, m_connectionRetrialTimeOut, m_connectionSharing, m_connectionTimeOut, m_messageLevel, m_monitoringLevel, m_poolAutomaticCleanUp, m_readOnlySessionOnUpdateConnections, m_SQLMonitoring, and m_transactionId.

                                                                                 {
  m_connectionSharing = rhs.m_connectionSharing;
  m_connectionTimeOut = rhs.m_connectionTimeOut;
  m_readOnlySessionOnUpdateConnections = rhs.m_readOnlySessionOnUpdateConnections;
  m_connectionRetrialPeriod = rhs.m_connectionRetrialPeriod;
  m_connectionRetrialTimeOut = rhs.m_connectionRetrialTimeOut;
  m_poolAutomaticCleanUp = rhs.m_poolAutomaticCleanUp;
  m_authPath = rhs.m_authPath;
  m_authSys = rhs.m_authSys;
  m_transactionId=rhs.m_transactionId;
  m_messageLevel = rhs.m_messageLevel;
  m_monitoringLevel = rhs.m_monitoringLevel;
  m_SQLMonitoring = rhs.m_SQLMonitoring;
  return *this;
}
void cond::DbConnectionConfiguration::setAuthenticationPath ( const std::string &  p)
void cond::DbConnectionConfiguration::setAuthenticationSystem ( int  authSysCode)

Definition at line 185 of file DbConnectionConfiguration.cc.

                                                                            {
  m_authSys = authSysCode;
}
void cond::DbConnectionConfiguration::setConnectionRetrialPeriod ( int  period)

Definition at line 166 of file DbConnectionConfiguration.cc.

                                                                          {
  m_connectionRetrialPeriod.first = true;
  m_connectionRetrialPeriod.second = period;
}
void cond::DbConnectionConfiguration::setConnectionRetrialTimeOut ( int  timeout)

Definition at line 171 of file DbConnectionConfiguration.cc.

                                                                            {
  m_connectionRetrialTimeOut.first = true;
  m_connectionRetrialTimeOut.second = timeout;
}
void cond::DbConnectionConfiguration::setConnectionSharing ( bool  flag)

Definition at line 151 of file DbConnectionConfiguration.cc.

                                                                   {
  m_connectionSharing.first = true;
  m_connectionSharing.second = flag;
}
void cond::DbConnectionConfiguration::setConnectionTimeOut ( int  timeOut)

Definition at line 156 of file DbConnectionConfiguration.cc.

                                                                     {
  m_connectionTimeOut.first = true;
  m_connectionTimeOut.second = timeOut;
}
void cond::DbConnectionConfiguration::setMessageLevel ( coral::MsgLevel  l)

Definition at line 193 of file DbConnectionConfiguration.cc.

References prof2calltree::l.

                                                                     {
  m_messageLevel = l; 
}
void cond::DbConnectionConfiguration::setMonitoringLevel ( coral::monitor::Level  l)

Definition at line 197 of file DbConnectionConfiguration.cc.

References prof2calltree::l.

void cond::DbConnectionConfiguration::setParameters ( const edm::ParameterSet connectionPset)

Definition at line 111 of file DbConnectionConfiguration.cc.

References builder_last_value_cfg::authPath, Debug, edm::ParameterSet::getUntrackedParameter(), and testEve_cfg::level.

Referenced by cond::service::PoolDBOutputService::PoolDBOutputService().

                                                                                        {
  std::string authPath = connectionPset.getUntrackedParameter<std::string>("authenticationPath","");
  setAuthenticationPath(authPath);
  int authSysPar = connectionPset.getUntrackedParameter<int>("authenticationSystem",0);
  setAuthenticationSystem( authSysPar );
  setTransactionId(connectionPset.getUntrackedParameter<std::string>("transactionId",""));
  int messageLevel = connectionPset.getUntrackedParameter<int>("messageLevel",0);
  coral::MsgLevel level = coral::Error;
  switch (messageLevel) {
    case 0 :
      level = coral::Error;
      break;    
    case 1:
      level = coral::Warning;
      break;
    case 2:
      level = coral::Info;
      break;
    case 3:
      level = coral::Debug;
      break;
    default:
      level = coral::Error;
  }
  setMessageLevel(level);
  bool enableConnectionSharing = connectionPset.getUntrackedParameter<bool>("enableConnectionSharing",true);
  setConnectionSharing( enableConnectionSharing );
  int connectionTimeOut = connectionPset.getUntrackedParameter<int>("connectionTimeOut",600);
  setConnectionTimeOut( connectionTimeOut );
  bool enableReadOnlySessionOnUpdateConnection = connectionPset.getUntrackedParameter<bool>("enableReadOnlySessionOnUpdateConnection",true);
  setReadOnlySessionOnUpdateConnections( enableReadOnlySessionOnUpdateConnection );
  int connectionRetrialPeriod = connectionPset.getUntrackedParameter<int>("connectionRetrialPeriod",30);
  setConnectionRetrialPeriod( connectionRetrialPeriod );
  int connectionRetrialTimeOut = connectionPset.getUntrackedParameter<int>("connectionRetrialTimeOut",180);
  setConnectionRetrialTimeOut( connectionRetrialTimeOut );
  bool enablePoolAutomaticCleanUp = connectionPset.getUntrackedParameter<bool>("enablePoolAutomaticCleanUp",false);
  setPoolAutomaticCleanUp( enablePoolAutomaticCleanUp );
  //int idleConnectionCleanupPeriod = connectionPset.getUntrackedParameter<int>("idleConnectionCleanupPeriod",300);
}
void cond::DbConnectionConfiguration::setPoolAutomaticCleanUp ( bool  flag)

Definition at line 176 of file DbConnectionConfiguration.cc.

                                                                      {
  m_poolAutomaticCleanUp.first = true;
  m_poolAutomaticCleanUp.second = flag;
}
void cond::DbConnectionConfiguration::setReadOnlySessionOnUpdateConnections ( bool  flag)
void cond::DbConnectionConfiguration::setSQLMonitoring ( bool  flag)

Definition at line 203 of file DbConnectionConfiguration.cc.

void cond::DbConnectionConfiguration::setTransactionId ( std::string const &  tid)

Definition at line 189 of file DbConnectionConfiguration.cc.

                                                                           {
  m_transactionId=tid;
}
const std::string & cond::DbConnectionConfiguration::transactionId ( ) const

Definition at line 331 of file DbConnectionConfiguration.cc.

Referenced by cond::FrontierProxy::initialize().

                                                                    {
  return m_transactionId;
}

Member Data Documentation

Definition at line 92 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 93 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 89 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 90 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 86 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 87 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 95 of file DbConnectionConfiguration.h.

Referenced by operator=().

coral::monitor::Level cond::DbConnectionConfiguration::m_monitoringLevel [private]

Definition at line 96 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 100 of file DbConnectionConfiguration.h.

Definition at line 91 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 88 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 99 of file DbConnectionConfiguration.h.

Referenced by operator=().

Definition at line 94 of file DbConnectionConfiguration.h.

Referenced by operator=().