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 ()
 
boost::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, 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)
 
boost::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, 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 31 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 ( )
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, 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  coralConfig.setAuthenticationService( authServiceName );
128  }
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
cond::CoralServiceManager * m_pluginManager
boost::shared_ptr< coral::ISessionProxy > cond::persistency::ConnectionPool::createCoralSession ( const std::string &  connectionString,
bool  writeCapable = false 
)

Definition at line 199 of file ConnectionPool.cc.

Referenced by createSession(), DTUserKeyedConfigHandler::getNewObjects(), and DTKeyedConfigHandler::getNewObjects().

200  {
201  return createCoralSession( connectionString, "", writeCapable );
202  }
boost::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
boost::shared_ptr< coral::ISessionProxy > cond::persistency::ConnectionPool::createCoralSession ( const std::string &  connectionString,
const std::string &  transactionId,
bool  writeCapable = false 
)
private

Definition at line 135 of file ConnectionPool.cc.

References cond::Auth::COND_READER_ROLE, cond::Auth::COND_WRITER_ROLE, cond::persistency::getConnectionParams(), 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, and cond::persistency::IOV::tname.

137  {
138  coral::ConnectionService connServ;
139  std::pair<std::string,std::string> fullConnectionPars = getConnectionParams( connectionString, transactionId );
140  if( !fullConnectionPars.second.empty() ) {
141  // the olds formats
142  connServ.webCacheControl().refreshTable( fullConnectionPars.second, POOL_IOV_TABLE_DATA );
143  connServ.webCacheControl().refreshTable( fullConnectionPars.second, ORA_IOV_TABLE_1 );
144  connServ.webCacheControl().refreshTable( fullConnectionPars.second, ORA_IOV_TABLE_2 );
145  connServ.webCacheControl().refreshTable( fullConnectionPars.second, ORA_IOV_TABLE_3 );
146  // the new schema...
147  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, TAG::tname, 1 );
148  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, IOV::tname, 1 );
149  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, PAYLOAD::tname, 3 );
150  }
151 
152  return boost::shared_ptr<coral::ISessionProxy>( connServ.connect( fullConnectionPars.first,
154  writeCapable?coral::Update:coral::ReadOnly ) );
155  }
static const std::string ORA_IOV_TABLE_1("ORA_C_COND_IOVSEQUENCE")
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
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
Session cond::persistency::ConnectionPool::createReadOnlySession ( const std::string &  connectionString,
const std::string &  transactionId 
)

Definition at line 195 of file ConnectionPool.cc.

References createSession().

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

195  {
196  return createSession( connectionString, transactionId );
197  }
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 191 of file ConnectionPool.cc.

Referenced by createReadOnlySession(), cond::persistency::exportTagToFile(), CondDBESSource::fillTagCollectionFromGT(), popcon::PopCon::initialize(), and L1ConfigOnlineProdBase< TRcd, TData >::L1ConfigOnlineProdBase().

191  {
192  return createSession( connectionString, "", writeCapable, backType );
193  }
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 157 of file ConnectionPool.cc.

References cond::persistency::checkBackendType(), createCoralSession(), 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.

160  {
161  coral::ConnectionService connServ;
162  std::pair<std::string,std::string> fullConnectionPars = getConnectionParams( connectionString, transactionId );
163  if( !fullConnectionPars.second.empty() ) {
164  // the olds formats
165  connServ.webCacheControl().refreshTable( fullConnectionPars.second, POOL_IOV_TABLE_DATA );
166  connServ.webCacheControl().refreshTable( fullConnectionPars.second, ORA_IOV_TABLE_1 );
167  connServ.webCacheControl().refreshTable( fullConnectionPars.second, ORA_IOV_TABLE_2 );
168  connServ.webCacheControl().refreshTable( fullConnectionPars.second, ORA_IOV_TABLE_3 );
169  // the new schema...
170  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, TAG::tname, 1 );
171  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, IOV::tname, 1 );
172  connServ.webCacheControl().setTableTimeToLive( fullConnectionPars.second, PAYLOAD::tname, 3 );
173  }
174 
175  boost::shared_ptr<coral::ISessionProxy> coralSession = createCoralSession( connectionString, transactionId, writeCapable );
176 
177  BackendType bt;
178  auto it = m_dbTypes.find( connectionString);
179  if( it == m_dbTypes.end() ){
180  bt = checkBackendType( coralSession, connectionString );
181  if( bt == UNKNOWN_DB && writeCapable) bt = backType;
182  m_dbTypes.insert( std::make_pair( connectionString, bt ) );
183  } else {
184  bt = (BackendType) it->second;
185  }
186 
187  std::shared_ptr<SessionImpl> impl( new SessionImpl( coralSession, connectionString, bt ) );
188  return Session( impl );
189  }
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:63
boost::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)
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
BackendType
Definition: Types.h:23
std::map< std::string, int > m_dbTypes
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)
void cond::persistency::ConnectionPool::setLogging ( bool  flag)

Definition at line 47 of file ConnectionPool.cc.

References m_loggingEnabled.

Referenced by setParameters().

47  {
48  m_loggingEnabled = flag;
49  }
void cond::persistency::ConnectionPool::setMessageVerbosity ( coral::MsgLevel  level)

Definition at line 204 of file ConnectionPool.cc.

References testEve_cfg::level, and m_messageLevel.

Referenced by setParameters().

204  {
206  }
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 57 of file ConnectionPool.h.

Referenced by configure(), and setAuthenticationPath().

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

Definition at line 58 of file ConnectionPool.h.

Referenced by configure(), and setAuthenticationSystem().

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

Definition at line 63 of file ConnectionPool.h.

Referenced by createSession().

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

Definition at line 60 of file ConnectionPool.h.

Referenced by isLoggingEnabled(), and setLogging().

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

Definition at line 59 of file ConnectionPool.h.

Referenced by configure(), and setMessageVerbosity().

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

Definition at line 62 of file ConnectionPool.h.

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