CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cond::persistency::ConnectionPool Class Reference

#include <ConnectionPool.h>

Public Member Functions

void configure ()
 
 ConnectionPool ()
 
std::shared_ptr< coral::ISessionProxy > createCoralSession (const std::string &connectionString, bool writeCapable=false)
 
Session createReadOnlySession (const std::string &connectionString, const std::string &transactionId)
 
Session createSession (const std::string &connectionString, bool writeCapable=false)
 
bool isLoggingEnabled () const
 
void setAuthenticationPath (const std::string &p)
 
void setAuthenticationSystem (int authSysCode)
 
void setFrontierSecurity (const std::string &signature)
 
void setLogging (bool flag)
 
void setMessageVerbosity (coral::MsgLevel level)
 
void setParameters (const edm::ParameterSet &connectionPset)
 
 ~ConnectionPool ()
 

Private Member Functions

void configure (coral::IConnectionServiceConfiguration &coralConfig)
 
std::shared_ptr< coral::ISessionProxy > createCoralSession (const std::string &connectionString, const std::string &transactionId, bool writeCapable=false)
 
Session createSession (const std::string &connectionString, const std::string &transactionId, bool writeCapable=false)
 

Private Attributes

std::string m_authPath = std::string( "" )
 
int m_authSys = 0
 
std::map< std::string, int > m_dbTypes
 
std::string m_frontierSecurity = std::string( "" )
 
bool m_loggingEnabled = false
 
coral::MsgLevel m_messageLevel = coral::Error
 
cond::CoralServiceManagerm_pluginManager = 0
 

Detailed Description

Definition at line 31 of file ConnectionPool.h.

Constructor & Destructor Documentation

cond::persistency::ConnectionPool::ConnectionPool ( )
cond::persistency::ConnectionPool::~ConnectionPool ( )

Definition at line 30 of file ConnectionPool.cc.

References m_pluginManager.

30  {
31  delete m_pluginManager;
32  }
cond::CoralServiceManager * m_pluginManager

Member Function Documentation

void cond::persistency::ConnectionPool::configure ( )
void cond::persistency::ConnectionPool::configure ( coral::IConnectionServiceConfiguration &  coralConfig)
private

Definition at line 83 of file ConnectionPool.cc.

References expressLumiProducer_cff::authPath, cond::auth::COND_AUTH_PATH, cond::auth::COND_AUTH_PATH_PROPERTY, cond::auth::COND_AUTH_SYS, cond::persistency::CondDbKey, cond::persistency::CoralXMLFile, instance, m_authPath, m_authSys, m_messageLevel, m_pluginManager, and AlCaHLTBitMon_QueryRunRegistry::string.

83  {
84  coralConfig.disablePoolAutomaticCleanUp();
85  coralConfig.disableConnectionSharing();
86  // message streaming
87  coral::MessageStream::setMsgVerbosity( m_messageLevel );
88  std::string authServiceName( "CORAL/Services/EnvironmentAuthenticationService" );
90  // authentication
91  if( authPath.empty() ){
92  // first try to check the env...
93  const char* authEnv = ::getenv( cond::auth::COND_AUTH_PATH );
94  if(authEnv){
95  authPath += authEnv;
96  }
97  }
98  int authSys = m_authSys;
99  // first attempt, look at the env...
100  const char* authSysEnv = ::getenv( cond::auth::COND_AUTH_SYS );
101  if( authSysEnv ){
102  authSys = ::atoi( authSysEnv );
103  }
104  if( authSys !=CondDbKey && authSys != CoralXMLFile ){
105  // take the default
106  authSys = CondDbKey;
107  }
108  std::string servName( "" );
109  if( authSys == CondDbKey ){
110  if( authPath.empty() ){
111  const char* authEnv = ::getenv( "HOME" );
112  if(authEnv) {
113  authPath += authEnv;
114  }
115  }
116  servName = "COND/Services/RelationalAuthenticationService";
117  } else if( authSys == CoralXMLFile ){
118  if( authPath.empty() ){
119  authPath = ".";
120  }
121  servName = "COND/Services/XMLAuthenticationService";
122  }
123  if( !authPath.empty() ){
124  authServiceName = servName;
125  coral::Context::instance().PropertyManager().property(cond::auth::COND_AUTH_PATH_PROPERTY)->set(authPath);
126  coral::Context::instance().loadComponent( authServiceName, m_pluginManager );
127  }
128 
129  coralConfig.setAuthenticationService( authServiceName );
130  }
static PFTauRenderPlugin instance
static constexpr const char *const COND_AUTH_PATH
Definition: Auth.h:10
static constexpr const char *const COND_AUTH_PATH_PROPERTY
Definition: Auth.h:27
static constexpr const char *const COND_AUTH_SYS
Definition: Auth.h:11
cond::CoralServiceManager * m_pluginManager
std::shared_ptr< coral::ISessionProxy > cond::persistency::ConnectionPool::createCoralSession ( const std::string &  connectionString,
bool  writeCapable = false 
)
std::shared_ptr< coral::ISessionProxy > cond::persistency::ConnectionPool::createCoralSession ( const std::string &  connectionString,
const std::string &  transactionId,
bool  writeCapable = false 
)
private

Definition at line 137 of file ConnectionPool.cc.

References cond::auth::COND_READER_ROLE, cond::auth::COND_WRITER_ROLE, cond::persistency::getConnectionParams(), m_frontierSecurity, cond::persistency::TAG::tname, cond::persistency::PAYLOAD::tname, and cond::persistency::IOV::tname.

139  {
140  coral::ConnectionService connServ;
141  //all sessions opened with this connection service will share the same frontier security option.
142  std::pair<std::string,std::string> fullConnectionPars = getConnectionParams( connectionString, transactionId, m_frontierSecurity );
143  if( !fullConnectionPars.second.empty() ) {
144  //all sessions opened with this connection service will share the same TTL settings for TAG, IOV, and PAYLOAD tables.
145  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, TAG::tname, 1 );
146  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, IOV::tname, 1 );
147  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, PAYLOAD::tname, 3 );
148  }
149 
150  return std::shared_ptr<coral::ISessionProxy>( connServ.connect( fullConnectionPars.first,
152  writeCapable ? coral::Update : coral::ReadOnly ) );
153  }
static char const * tname
Definition: IOVSchema.h:48
static char const * tname
Definition: IOVSchema.h:13
static constexpr const char *const COND_READER_ROLE
Definition: Auth.h:17
std::pair< std::string, std::string > getConnectionParams(const std::string &connectionString, const std::string &transactionId, const std::string &signature)
static constexpr const char *const COND_WRITER_ROLE
Definition: Auth.h:16
static char const * tname
Definition: IOVSchema.h:79
Session cond::persistency::ConnectionPool::createReadOnlySession ( const std::string &  connectionString,
const std::string &  transactionId 
)

Definition at line 166 of file ConnectionPool.cc.

References createSession().

Referenced by popcon::PopConBTransitionSourceHandler< T >::checkBOn(), CondDBESSource::CondDBESSource(), and CondDBESSource::setIntervalFor().

166  {
167  return createSession( connectionString, transactionId );
168  }
Session createSession(const std::string &connectionString, bool writeCapable=false)
Session cond::persistency::ConnectionPool::createSession ( const std::string &  connectionString,
bool  writeCapable = false 
)
Session cond::persistency::ConnectionPool::createSession ( const std::string &  connectionString,
const std::string &  transactionId,
bool  writeCapable = false 
)
private

Definition at line 155 of file ConnectionPool.cc.

References createCoralSession().

157  {
158  std::shared_ptr<coral::ISessionProxy> coralSession = createCoralSession( connectionString, transactionId, writeCapable );
159  return Session( std::make_shared<SessionImpl>( coralSession, connectionString ));
160  }
std::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
bool cond::persistency::ConnectionPool::isLoggingEnabled ( ) const

Definition at line 79 of file ConnectionPool.cc.

References m_loggingEnabled.

79  {
80  return m_loggingEnabled;
81  }
void cond::persistency::ConnectionPool::setAuthenticationPath ( const std::string &  p)
void cond::persistency::ConnectionPool::setAuthenticationSystem ( int  authSysCode)
void cond::persistency::ConnectionPool::setFrontierSecurity ( const std::string &  signature)

Definition at line 42 of file ConnectionPool.cc.

References m_frontierSecurity, and signature.

Referenced by setParameters().

42  {
44  }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined signature
Definition: Activities.doc:4
void cond::persistency::ConnectionPool::setLogging ( bool  flag)

Definition at line 46 of file ConnectionPool.cc.

References RemoveAddSevLevel::flag, and m_loggingEnabled.

Referenced by setParameters().

void cond::persistency::ConnectionPool::setMessageVerbosity ( coral::MsgLevel  level)
void cond::persistency::ConnectionPool::setParameters ( const edm::ParameterSet connectionPset)

Definition at line 50 of file ConnectionPool.cc.

References Debug, edm::ParameterSet::getUntrackedParameter(), hcalDigis_cfi::level, m_authPath, m_authSys, m_frontierSecurity, m_loggingEnabled, m_messageLevel, patTestJEC_local_cfi::messageLevel, setAuthenticationPath(), setAuthenticationSystem(), setFrontierSecurity(), setLogging(), setMessageVerbosity(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by CondDBESSource::CondDBESSource(), cond::service::PoolDBOutputService::PoolDBOutputService(), popcon::PopConBTransitionSourceHandler< T >::PopConBTransitionSourceHandler(), RunInfoRead::readData(), RPCDCCLinkMapHandler::RPCDCCLinkMapHandler(), RPCLBLinkMapHandler::RPCLBLinkMapHandler(), SiStripDetVOffHandler::SiStripDetVOffHandler(), SiStripDetVOffTkMapPlotter::SiStripDetVOffTkMapPlotter(), SiStripDetVOffTrendPlotter::SiStripDetVOffTrendPlotter(), SiStripPayloadHandler< SiStripPayload >::SiStripPayloadHandler(), and SiStripPayloadMapTableCreator::SiStripPayloadMapTableCreator().

50  {
51  //set the connection parameters from a ParameterSet
52  //if a parameter is not defined, keep the values already set in the data members
53  //(i.e. default if no other setters called, or the ones currently available)
54  setAuthenticationPath( connectionPset.getUntrackedParameter<std::string>( "authenticationPath", m_authPath ) );
55  setAuthenticationSystem( connectionPset.getUntrackedParameter<int>( "authenticationSystem", m_authSys ) );
57  int messageLevel = connectionPset.getUntrackedParameter<int>( "messageLevel", 0 ); //0 corresponds to Error level, current default
58  coral::MsgLevel level = m_messageLevel;
59  switch (messageLevel) {
60  case 0:
61  level = coral::Error;
62  break;
63  case 1:
64  level = coral::Warning;
65  break;
66  case 2:
67  level = coral::Info;
68  break;
69  case 3:
70  level = coral::Debug;
71  break;
72  default:
73  level = coral::Error;
74  }
75  setMessageVerbosity( level );
76  setLogging( connectionPset.getUntrackedParameter<bool>( "logging", m_loggingEnabled ) );
77  }
T getUntrackedParameter(std::string const &, T const &) const
void setAuthenticationSystem(int authSysCode)
void setMessageVerbosity(coral::MsgLevel level)
void setAuthenticationPath(const std::string &p)
const bool Debug
void setFrontierSecurity(const std::string &signature)

Member Data Documentation

std::string cond::persistency::ConnectionPool::m_authPath = std::string( "" )
private

Definition at line 57 of file ConnectionPool.h.

Referenced by configure(), setAuthenticationPath(), and setParameters().

int cond::persistency::ConnectionPool::m_authSys = 0
private

Definition at line 58 of file ConnectionPool.h.

Referenced by configure(), setAuthenticationSystem(), and setParameters().

std::map<std::string,int> cond::persistency::ConnectionPool::m_dbTypes
private

Definition at line 66 of file ConnectionPool.h.

std::string cond::persistency::ConnectionPool::m_frontierSecurity = std::string( "" )
private

Definition at line 63 of file ConnectionPool.h.

Referenced by createCoralSession(), setFrontierSecurity(), and setParameters().

bool cond::persistency::ConnectionPool::m_loggingEnabled = false
private

Definition at line 60 of file ConnectionPool.h.

Referenced by isLoggingEnabled(), setLogging(), and setParameters().

coral::MsgLevel cond::persistency::ConnectionPool::m_messageLevel = coral::Error
private

Definition at line 59 of file ConnectionPool.h.

Referenced by configure(), setMessageVerbosity(), and setParameters().

cond::CoralServiceManager* cond::persistency::ConnectionPool::m_pluginManager = 0
private

Definition at line 65 of file ConnectionPool.h.

Referenced by configure(), ConnectionPool(), and ~ConnectionPool().