CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
cond::DbConnectionConfiguration Class Reference

#include <DbConnectionConfiguration.h>

Public Member Functions

const std::string & authenticationPath () const
 
void configure (coral::IConnectionServiceConfiguration &coralConfig) const
 
int connectionRetrialPeriod () const
 
int connectionRetrialTimeOut () const
 
int connectionTimeOut () const
 
 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)
 
 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 ( )

Definition at line 32 of file DbConnectionConfiguration.cc.

32  :
33  m_connectionSharing(false,false),
34  m_connectionTimeOut(false,0),
38  m_poolAutomaticCleanUp(false,false),
39  m_authPath(""),
40  m_authSys(0),
42  m_messageLevel(coral::Error),
43  m_monitoringLevel(coral::monitor::Off),
44  m_SQLMonitoring(false),
46 }
std::pair< bool, bool > m_poolAutomaticCleanUp
std::pair< bool, int > m_connectionRetrialTimeOut
std::pair< bool, int > m_connectionRetrialPeriod
std::pair< bool, bool > m_readOnlySessionOnUpdateConnections
std::pair< bool, bool > m_connectionSharing
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.

74  :
75  m_connectionSharing(rhs.m_connectionSharing),
76  m_connectionTimeOut(rhs.m_connectionTimeOut),
77  m_readOnlySessionOnUpdateConnections(rhs.m_readOnlySessionOnUpdateConnections),
78  m_connectionRetrialPeriod(rhs.m_connectionRetrialPeriod),
79  m_connectionRetrialTimeOut(rhs.m_connectionRetrialTimeOut),
80  m_poolAutomaticCleanUp(rhs.m_poolAutomaticCleanUp),
81  m_authPath(rhs.m_authPath),
82  m_authSys(rhs.m_authSys),
83  m_transactionId(rhs.m_transactionId),
84  m_messageLevel(rhs.m_messageLevel),
85  m_monitoringLevel(rhs.m_monitoringLevel),
86  m_SQLMonitoring(rhs.m_SQLMonitoring),
88 }
std::pair< bool, bool > m_poolAutomaticCleanUp
std::pair< bool, int > m_connectionRetrialTimeOut
std::pair< bool, int > m_connectionRetrialPeriod
std::pair< bool, bool > m_readOnlySessionOnUpdateConnections
std::pair< bool, bool > m_connectionSharing
cond::DbConnectionConfiguration::~DbConnectionConfiguration ( )

Definition at line 90 of file DbConnectionConfiguration.cc.

90  {
91  delete m_pluginManager;
92 }

Member Function Documentation

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

Definition at line 326 of file DbConnectionConfiguration.cc.

327 {
328  return m_authPath;
329 }
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.

208 {
209  // message streaming
210  coral::MessageStream::setMsgVerbosity( m_messageLevel );
211  std::string authServiceName("CORAL/Services/EnvironmentAuthenticationService");
212  std::string authPath = m_authPath;
213  // authentication
214  if( authPath.empty() ){
215  // first try to check the env...
216  const char* authEnv = ::getenv( Auth::COND_AUTH_PATH );
217  if(authEnv){
218  authPath += authEnv;
219  }
220  }
221  int authSys = m_authSys;
222  if( authSys != CondDbKey && authSys != CoralXMLFile ){
223  // first attempt, look at the env...
224  const char* authSysEnv = ::getenv( Auth::COND_AUTH_SYS );
225  if( authSysEnv ){
226  authSys = ::atoi( authSysEnv );
227  }
228  }
229  if( authSys != CondDbKey && authSys != CoralXMLFile ){
230  // take the default
231  authSys = CoralXMLFile;
232  }
233  std::string servName("");
234  if( authSys == CondDbKey ){
235  if( authPath.empty() ){
236  const char* authEnv = ::getenv("HOME");
237  if(authEnv){
238  authPath += authEnv;
239  }
240  }
241  servName = "COND/Services/RelationalAuthenticationService";
242  //edm::LogInfo("DbSessionInfo") << "Authentication using Keys";
243  } else if( authSys == CoralXMLFile ){
244  if( authPath.empty() ){
245  authPath = ".";
246  }
247  servName = "COND/Services/XMLAuthenticationService";
248  //edm::LogInfo("DbSessionInfo") << "Authentication using XML File";
249  }
250  if( !authPath.empty() ){
251  authServiceName = servName;
252  coral::Context::instance().PropertyManager().property(Auth::COND_AUTH_PATH_PROPERTY)->set(authPath);
253  coral::Context::instance().loadComponent( authServiceName, m_pluginManager );
254  }
255  coralConfig.setAuthenticationService( authServiceName );
256  // connection sharing
257  if(m_connectionSharing.first)
258  {
259  if(m_connectionSharing.second) coralConfig.enableConnectionSharing();
260  else coralConfig.disableConnectionSharing();
261  }
262  // connection timeout
263  if(m_connectionTimeOut.first)
264  {
265  coralConfig.setConnectionTimeOut(m_connectionTimeOut.second);
266  }
267  // read only session on update connection
269  {
270  if(m_readOnlySessionOnUpdateConnections.second) coralConfig.enableReadOnlySessionOnUpdateConnections();
271  else coralConfig.disableReadOnlySessionOnUpdateConnections();
272  }
273  // pool automatic clean up
274  if(m_poolAutomaticCleanUp.first)
275  {
276  if(m_poolAutomaticCleanUp.second) coralConfig.enablePoolAutomaticCleanUp();
277  else coralConfig.disablePoolAutomaticCleanUp();
278  }
279  // connection retrial period
280  if(m_connectionRetrialPeriod.first)
281  {
282  coralConfig.setConnectionRetrialPeriod( m_connectionRetrialPeriod.second );
283  }
284  // connection retrial timeout
285  if( m_connectionRetrialTimeOut.first)
286  {
287  coralConfig.setConnectionRetrialTimeOut(m_connectionRetrialTimeOut.second );
288  }
289  // monitoring level
290  coralConfig.setMonitoringLevel( m_monitoringLevel );
291  // SQL monitoring
292  if( m_SQLMonitoring )
293  {
294  std::string pluginName("COND/Services/SQLMonitoringService");
295  coral::Context::instance().loadComponent( pluginName, m_pluginManager );
296  coralConfig.setMonitoringLevel(coral::monitor::Trace);
297  }
298 
299 }
static PFTauRenderPlugin instance
std::pair< bool, bool > m_poolAutomaticCleanUp
static const std::string COND_AUTH_PATH_PROPERTY
Definition: Auth.h:27
std::pair< bool, int > m_connectionRetrialTimeOut
static const char * COND_AUTH_SYS
Definition: Auth.h:13
std::pair< bool, int > m_connectionRetrialPeriod
std::pair< bool, bool > m_readOnlySessionOnUpdateConnections
std::pair< bool, bool > m_connectionSharing
static const char * COND_AUTH_PATH
Definition: Auth.h:12
int cond::DbConnectionConfiguration::connectionRetrialPeriod ( ) const

Definition at line 314 of file DbConnectionConfiguration.cc.

314  {
315  return m_connectionRetrialPeriod.second;
316 }
std::pair< bool, int > m_connectionRetrialPeriod
int cond::DbConnectionConfiguration::connectionRetrialTimeOut ( ) const

Definition at line 318 of file DbConnectionConfiguration.cc.

318  {
319  return m_connectionRetrialTimeOut.second;
320 }
std::pair< bool, int > m_connectionRetrialTimeOut
int cond::DbConnectionConfiguration::connectionTimeOut ( ) const

Definition at line 306 of file DbConnectionConfiguration.cc.

306  {
307  return m_connectionTimeOut.second;
308 }
std::vector< cond::DbConnectionConfiguration > & cond::DbConnectionConfiguration::defaultConfigurations ( )
static

Definition at line 17 of file DbConnectionConfiguration.cc.

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

17  {
18  static std::vector<DbConnectionConfiguration> s_defaultConfigurations;
19  // coral default
20  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration() );
21  // cms default
22  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "", coral::Error, coral::monitor::Off, false ) );
23  // prod default
24  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "", coral::Error, coral::monitor::Off, false ) );
25  // tool default
26  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "",coral::Error, coral::monitor::Off, false ) );
27  // web default
28  s_defaultConfigurations.push_back( cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "",coral::Error, coral::monitor::Off, false ) );
29  return s_defaultConfigurations;
30 }
bool cond::DbConnectionConfiguration::isConnectionSharingEnabled ( ) const

Definition at line 301 of file DbConnectionConfiguration.cc.

302 {
303  return m_connectionSharing.second;
304 }
std::pair< bool, bool > m_connectionSharing
bool cond::DbConnectionConfiguration::isPoolAutomaticCleanUpEnabled ( ) const

Definition at line 322 of file DbConnectionConfiguration.cc.

322  {
323  return m_poolAutomaticCleanUp.second;
324 }
std::pair< bool, bool > m_poolAutomaticCleanUp
bool cond::DbConnectionConfiguration::isReadOnlySessionOnUpdateConnectionEnabled ( ) const

Definition at line 310 of file DbConnectionConfiguration.cc.

310  {
312 }
std::pair< bool, bool > m_readOnlySessionOnUpdateConnections
bool cond::DbConnectionConfiguration::isSQLMonitoringEnabled ( ) const

Definition at line 341 of file DbConnectionConfiguration.cc.

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

Definition at line 336 of file DbConnectionConfiguration.cc.

337 {
338  return m_messageLevel;
339 }
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.

95  {
96  m_connectionSharing = rhs.m_connectionSharing;
97  m_connectionTimeOut = rhs.m_connectionTimeOut;
98  m_readOnlySessionOnUpdateConnections = rhs.m_readOnlySessionOnUpdateConnections;
99  m_connectionRetrialPeriod = rhs.m_connectionRetrialPeriod;
100  m_connectionRetrialTimeOut = rhs.m_connectionRetrialTimeOut;
101  m_poolAutomaticCleanUp = rhs.m_poolAutomaticCleanUp;
102  m_authPath = rhs.m_authPath;
103  m_authSys = rhs.m_authSys;
104  m_transactionId=rhs.m_transactionId;
105  m_messageLevel = rhs.m_messageLevel;
106  m_monitoringLevel = rhs.m_monitoringLevel;
107  m_SQLMonitoring = rhs.m_SQLMonitoring;
108  return *this;
109 }
std::pair< bool, bool > m_poolAutomaticCleanUp
std::pair< bool, int > m_connectionRetrialTimeOut
std::pair< bool, int > m_connectionRetrialPeriod
std::pair< bool, bool > m_readOnlySessionOnUpdateConnections
std::pair< bool, bool > m_connectionSharing
void cond::DbConnectionConfiguration::setAuthenticationPath ( const std::string &  p)
void cond::DbConnectionConfiguration::setAuthenticationSystem ( int  authSysCode)

Definition at line 185 of file DbConnectionConfiguration.cc.

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

Definition at line 166 of file DbConnectionConfiguration.cc.

166  {
167  m_connectionRetrialPeriod.first = true;
168  m_connectionRetrialPeriod.second = period;
169 }
std::pair< bool, int > m_connectionRetrialPeriod
void cond::DbConnectionConfiguration::setConnectionRetrialTimeOut ( int  timeout)

Definition at line 171 of file DbConnectionConfiguration.cc.

171  {
172  m_connectionRetrialTimeOut.first = true;
173  m_connectionRetrialTimeOut.second = timeout;
174 }
std::pair< bool, int > m_connectionRetrialTimeOut
void cond::DbConnectionConfiguration::setConnectionSharing ( bool  flag)

Definition at line 151 of file DbConnectionConfiguration.cc.

Referenced by l1t::DataManager::connect().

151  {
152  m_connectionSharing.first = true;
153  m_connectionSharing.second = flag;
154 }
long int flag
Definition: mlp_lapack.h:47
std::pair< bool, bool > m_connectionSharing
void cond::DbConnectionConfiguration::setConnectionTimeOut ( int  timeOut)

Definition at line 156 of file DbConnectionConfiguration.cc.

Referenced by FillInfoPopConSourceHandler::getNewObjects().

156  {
157  m_connectionTimeOut.first = true;
158  m_connectionTimeOut.second = timeOut;
159 }
void cond::DbConnectionConfiguration::setMessageLevel ( coral::MsgLevel  l)
void cond::DbConnectionConfiguration::setMonitoringLevel ( coral::monitor::Level  l)

Definition at line 197 of file DbConnectionConfiguration.cc.

References prof2calltree::l.

198 {
199  m_monitoringLevel = l;
200 }
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 CondDBESSource::CondDBESSource(), and cond::service::PoolDBOutputService::PoolDBOutputService().

111  {
112  std::string authPath = connectionPset.getUntrackedParameter<std::string>("authenticationPath","");
113  setAuthenticationPath(authPath);
114  int authSysPar = connectionPset.getUntrackedParameter<int>("authenticationSystem",0);
115  setAuthenticationSystem( authSysPar );
116  setTransactionId(connectionPset.getUntrackedParameter<std::string>("transactionId",""));
117  int messageLevel = connectionPset.getUntrackedParameter<int>("messageLevel",0);
118  coral::MsgLevel level = coral::Error;
119  switch (messageLevel) {
120  case 0 :
121  level = coral::Error;
122  break;
123  case 1:
124  level = coral::Warning;
125  break;
126  case 2:
127  level = coral::Info;
128  break;
129  case 3:
130  level = coral::Debug;
131  break;
132  default:
133  level = coral::Error;
134  }
135  setMessageLevel(level);
136  bool enableConnectionSharing = connectionPset.getUntrackedParameter<bool>("enableConnectionSharing",true);
137  setConnectionSharing( enableConnectionSharing );
138  int connectionTimeOut = connectionPset.getUntrackedParameter<int>("connectionTimeOut",600);
139  setConnectionTimeOut( connectionTimeOut );
140  bool enableReadOnlySessionOnUpdateConnection = connectionPset.getUntrackedParameter<bool>("enableReadOnlySessionOnUpdateConnection",true);
141  setReadOnlySessionOnUpdateConnections( enableReadOnlySessionOnUpdateConnection );
142  int connectionRetrialPeriod = connectionPset.getUntrackedParameter<int>("connectionRetrialPeriod",30);
143  setConnectionRetrialPeriod( connectionRetrialPeriod );
144  int connectionRetrialTimeOut = connectionPset.getUntrackedParameter<int>("connectionRetrialTimeOut",180);
145  setConnectionRetrialTimeOut( connectionRetrialTimeOut );
146  bool enablePoolAutomaticCleanUp = connectionPset.getUntrackedParameter<bool>("enablePoolAutomaticCleanUp",false);
147  setPoolAutomaticCleanUp( enablePoolAutomaticCleanUp );
148  //int idleConnectionCleanupPeriod = connectionPset.getUntrackedParameter<int>("idleConnectionCleanupPeriod",300);
149 }
T getUntrackedParameter(std::string const &, T const &) const
void setTransactionId(std::string const &tid)
void setAuthenticationPath(const std::string &p)
tuple level
Definition: testEve_cfg.py:34
const bool Debug
void cond::DbConnectionConfiguration::setPoolAutomaticCleanUp ( bool  flag)

Definition at line 176 of file DbConnectionConfiguration.cc.

Referenced by FillInfoPopConSourceHandler::getNewObjects().

176  {
177  m_poolAutomaticCleanUp.first = true;
178  m_poolAutomaticCleanUp.second = flag;
179 }
long int flag
Definition: mlp_lapack.h:47
std::pair< bool, bool > m_poolAutomaticCleanUp
void cond::DbConnectionConfiguration::setReadOnlySessionOnUpdateConnections ( bool  flag)

Definition at line 161 of file DbConnectionConfiguration.cc.

Referenced by l1t::DataManager::connect().

161  {
164 }
long int flag
Definition: mlp_lapack.h:47
std::pair< bool, bool > m_readOnlySessionOnUpdateConnections
void cond::DbConnectionConfiguration::setSQLMonitoring ( bool  flag)

Definition at line 203 of file DbConnectionConfiguration.cc.

203  {
205 }
long int flag
Definition: mlp_lapack.h:47
void cond::DbConnectionConfiguration::setTransactionId ( std::string const &  tid)

Definition at line 189 of file DbConnectionConfiguration.cc.

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

Definition at line 331 of file DbConnectionConfiguration.cc.

331  {
332  return m_transactionId;
333 }

Member Data Documentation

std::string cond::DbConnectionConfiguration::m_authPath
private

Definition at line 92 of file DbConnectionConfiguration.h.

Referenced by operator=().

int cond::DbConnectionConfiguration::m_authSys
private

Definition at line 93 of file DbConnectionConfiguration.h.

Referenced by operator=().

std::pair<bool,int> cond::DbConnectionConfiguration::m_connectionRetrialPeriod
private

Definition at line 89 of file DbConnectionConfiguration.h.

Referenced by operator=().

std::pair<bool,int> cond::DbConnectionConfiguration::m_connectionRetrialTimeOut
private

Definition at line 90 of file DbConnectionConfiguration.h.

Referenced by operator=().

std::pair<bool,bool> cond::DbConnectionConfiguration::m_connectionSharing
private

Definition at line 86 of file DbConnectionConfiguration.h.

Referenced by operator=().

std::pair<bool,int> cond::DbConnectionConfiguration::m_connectionTimeOut
private

Definition at line 87 of file DbConnectionConfiguration.h.

Referenced by operator=().

coral::MsgLevel cond::DbConnectionConfiguration::m_messageLevel
private

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=().

CoralServiceManager* cond::DbConnectionConfiguration::m_pluginManager
private

Definition at line 100 of file DbConnectionConfiguration.h.

std::pair<bool,bool> cond::DbConnectionConfiguration::m_poolAutomaticCleanUp
private

Definition at line 91 of file DbConnectionConfiguration.h.

Referenced by operator=().

std::pair<bool,bool> cond::DbConnectionConfiguration::m_readOnlySessionOnUpdateConnections
private

Definition at line 88 of file DbConnectionConfiguration.h.

Referenced by operator=().

bool cond::DbConnectionConfiguration::m_SQLMonitoring
private

Definition at line 99 of file DbConnectionConfiguration.h.

Referenced by operator=().

std::string cond::DbConnectionConfiguration::m_transactionId
private

Definition at line 94 of file DbConnectionConfiguration.h.

Referenced by operator=().