CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
Session createReadOnlySession (const std::string &connectionString, const std::string &transactionId)
 
Session createSession (const std::string &connectionString, bool writeCapable=false, BackendType backType=DEFAULT_DB)
 
bool isLoggingEnabled () const
 
void setAuthenticationPath (const std::string &p)
 
void setAuthenticationSystem (int authSysCode)
 
void setLogging (bool flag)
 
void setMessageVerbosity (coral::MsgLevel level)
 
void setParameters (const edm::ParameterSet &connectionPset)
 
 ~ConnectionPool ()
 

Private Member Functions

void configure (coral::IConnectionServiceConfiguration &coralConfig)
 
Session createSession (const std::string &connectionString, const std::string &transactionId, bool writeCapable=false, BackendType backType=DEFAULT_DB)
 

Private Attributes

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

Detailed Description

Definition at line 30 of file ConnectionPool.h.

Constructor & Destructor Documentation

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

Definition at line 30 of file ConnectionPool.cc.

References configure(), and m_pluginManager.

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

Definition at line 35 of file ConnectionPool.cc.

References m_pluginManager.

35  {
36  delete m_pluginManager;
37  }
cond::CoralServiceManager * m_pluginManager

Member Function Documentation

void cond::persistency::ConnectionPool::configure ( )

Definition at line 132 of file ConnectionPool.cc.

Referenced by CondDBESSource::CondDBESSource(), ConnectionPool(), DTKeyedConfigHandler::getNewObjects(), and DTUserKeyedConfigHandler::getNewObjects().

132  {
133  coral::ConnectionService connServ;
134  configure( connServ.configuration() );
135  }
void cond::persistency::ConnectionPool::configure ( coral::IConnectionServiceConfiguration &  coralConfig)
private

Definition at line 80 of file ConnectionPool.cc.

References builder_last_value_cfg::authPath, cond::Auth::COND_AUTH_PATH, cond::Auth::COND_AUTH_PATH_PROPERTY, cond::Auth::COND_AUTH_SYS, cond::persistency::CondDbKey, cond::persistency::CoralXMLFile, gather_cfg::cout, instance, m_authPath, m_authSys, m_messageLevel, m_pluginManager, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 176 of file ConnectionPool.cc.

References createSession().

Referenced by CondDBESSource::CondDBESSource(), and CondDBESSource::setIntervalFor().

176  {
177  return createSession( connectionString, transactionId );
178  }
Session createSession(const std::string &connectionString, bool writeCapable=false, BackendType backType=DEFAULT_DB)
Session cond::persistency::ConnectionPool::createSession ( const std::string &  connectionString,
bool  writeCapable = false,
BackendType  backType = DEFAULT_DB 
)

Definition at line 172 of file ConnectionPool.cc.

Referenced by createReadOnlySession(), cond::persistency::exportTagToFile(), CondDBESSource::fillTagCollectionFromGT(), DTUserKeyedConfigHandler::getNewObjects(), and DTKeyedConfigHandler::getNewObjects().

172  {
173  return createSession( connectionString, "", writeCapable, backType );
174  }
Session createSession(const std::string &connectionString, bool writeCapable=false, BackendType backType=DEFAULT_DB)
Session cond::persistency::ConnectionPool::createSession ( const std::string &  connectionString,
const std::string &  transactionId,
bool  writeCapable = false,
BackendType  backType = DEFAULT_DB 
)
private

Definition at line 137 of file ConnectionPool.cc.

References cond::persistency::checkBackendType(), cond::Auth::COND_READER_ROLE, cond::Auth::COND_WRITER_ROLE, cond::persistency::getConnectionParams(), m_dbTypes, cond::persistency::ORA_IOV_TABLE_1(), cond::persistency::ORA_IOV_TABLE_2(), cond::persistency::ORA_IOV_TABLE_3(), cond::persistency::POOL_IOV_TABLE_DATA(), cond::persistency::TAG::tname, cond::persistency::PAYLOAD::tname, cond::persistency::IOV::tname, and cond::UNKNOWN_DB.

140  {
141  coral::ConnectionService connServ;
142  std::pair<std::string,std::string> fullConnectionPars = getConnectionParams( connectionString, transactionId );
143  if( !fullConnectionPars.second.empty() ) {
144  // the olds formats
145  connServ.webCacheControl().refreshTable( fullConnectionPars.second, POOL_IOV_TABLE_DATA );
146  connServ.webCacheControl().refreshTable( fullConnectionPars.second, ORA_IOV_TABLE_1 );
147  connServ.webCacheControl().refreshTable( fullConnectionPars.second, ORA_IOV_TABLE_2 );
148  connServ.webCacheControl().refreshTable( fullConnectionPars.second, ORA_IOV_TABLE_3 );
149  // the new schema...
150  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, TAG::tname, 1 );
151  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, IOV::tname, 1 );
152  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, PAYLOAD::tname, 3 );
153  }
154 
155  boost::shared_ptr<coral::ISessionProxy> coralSession( connServ.connect( fullConnectionPars.first,
157  writeCapable?coral::Update:coral::ReadOnly ) );
158  BackendType bt;
159  auto it = m_dbTypes.find( connectionString);
160  if( it == m_dbTypes.end() ){
161  bt = checkBackendType( coralSession, connectionString );
162  if( bt == UNKNOWN_DB && writeCapable) bt = backType;
163  m_dbTypes.insert( std::make_pair( connectionString, bt ) );
164  } else {
165  bt = (BackendType) it->second;
166  }
167 
168  std::shared_ptr<SessionImpl> impl( new SessionImpl( coralSession, connectionString, bt ) );
169  return Session( impl );
170  }
static const std::string ORA_IOV_TABLE_1("ORA_C_COND_IOVSEQUENCE")
BackendType checkBackendType(boost::shared_ptr< coral::ISessionProxy > &coralSession, const std::string &connectionString)
Definition: SessionImpl.cc:60
static const std::string ORA_IOV_TABLE_3("ORA_C_COND_IOVSEQU_A1")
static char const * tname
Definition: IOVSchema.h:48
std::pair< std::string, std::string > getConnectionParams(const std::string &connectionString, const std::string &transactionId)
static char const * tname
Definition: IOVSchema.h:13
static const std::string COND_WRITER_ROLE
Definition: Auth.h:18
BackendType
Definition: Types.h:23
std::map< std::string, int > m_dbTypes
static const std::string COND_READER_ROLE
Definition: Auth.h:19
static const std::string POOL_IOV_TABLE_DATA("IOV_DATA")
static const std::string ORA_IOV_TABLE_2("ORA_C_COND_IOVSEQU_A0")
static char const * tname
Definition: IOVSchema.h:79
bool cond::persistency::ConnectionPool::isLoggingEnabled ( ) const

Definition at line 76 of file ConnectionPool.cc.

References m_loggingEnabled.

76  {
77  return m_loggingEnabled;
78  }
void cond::persistency::ConnectionPool::setAuthenticationPath ( const std::string &  p)
void cond::persistency::ConnectionPool::setAuthenticationSystem ( int  authSysCode)

Definition at line 43 of file ConnectionPool.cc.

References m_authSys.

Referenced by setParameters().

43  {
44  m_authSys = authSysCode;
45  }
void cond::persistency::ConnectionPool::setLogging ( bool  flag)

Definition at line 47 of file ConnectionPool.cc.

References archive::flag, and m_loggingEnabled.

Referenced by setParameters().

void cond::persistency::ConnectionPool::setMessageVerbosity ( coral::MsgLevel  level)

Definition at line 179 of file ConnectionPool.cc.

References testEve_cfg::level, and m_messageLevel.

Referenced by setParameters().

179  {
181  }
tuple level
Definition: testEve_cfg.py:34
void cond::persistency::ConnectionPool::setParameters ( const edm::ParameterSet connectionPset)

Definition at line 51 of file ConnectionPool.cc.

References Debug, edm::ParameterSet::getUntrackedParameter(), testEve_cfg::level, setAuthenticationPath(), setAuthenticationSystem(), setLogging(), setMessageVerbosity(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by CondDBESSource::CondDBESSource().

51  {
52  setAuthenticationPath( connectionPset.getUntrackedParameter<std::string>("authenticationPath","") );
53  setAuthenticationSystem( connectionPset.getUntrackedParameter<int>("authenticationSystem",0) );
54  int messageLevel = connectionPset.getUntrackedParameter<int>("messageLevel",0);
55  coral::MsgLevel level = coral::Error;
56  switch (messageLevel) {
57  case 0 :
58  level = coral::Error;
59  break;
60  case 1:
61  level = coral::Warning;
62  break;
63  case 2:
64  level = coral::Info;
65  break;
66  case 3:
67  level = coral::Debug;
68  break;
69  default:
70  level = coral::Error;
71  }
72  setMessageVerbosity(level);
73  setLogging( connectionPset.getUntrackedParameter<bool>("logging",false) );
74  }
T getUntrackedParameter(std::string const &, T const &) const
void setAuthenticationSystem(int authSysCode)
void setMessageVerbosity(coral::MsgLevel level)
tuple level
Definition: testEve_cfg.py:34
void setAuthenticationPath(const std::string &p)
const bool Debug

Member Data Documentation

std::string cond::persistency::ConnectionPool::m_authPath
private

Definition at line 52 of file ConnectionPool.h.

Referenced by configure(), and setAuthenticationPath().

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

Definition at line 53 of file ConnectionPool.h.

Referenced by configure(), and setAuthenticationSystem().

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

Definition at line 58 of file ConnectionPool.h.

Referenced by createSession().

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

Definition at line 55 of file ConnectionPool.h.

Referenced by isLoggingEnabled(), and setLogging().

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

Definition at line 54 of file ConnectionPool.h.

Referenced by configure(), and setMessageVerbosity().

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

Definition at line 57 of file ConnectionPool.h.

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