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 const 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 28 of file DbConnectionConfiguration.cc.

28  :
29  m_connectionSharing(false,false),
30  m_connectionTimeOut(false,0),
34  m_poolAutomaticCleanUp(false,false),
35  m_authPath(""),
36  m_authSys(0),
38  m_messageLevel(coral::Error),
39  m_monitoringLevel(coral::monitor::Off),
40  m_SQLMonitoring(false),
42 }
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 70 of file DbConnectionConfiguration.cc.

70  :
71  m_connectionSharing(rhs.m_connectionSharing),
72  m_connectionTimeOut(rhs.m_connectionTimeOut),
73  m_readOnlySessionOnUpdateConnections(rhs.m_readOnlySessionOnUpdateConnections),
74  m_connectionRetrialPeriod(rhs.m_connectionRetrialPeriod),
75  m_connectionRetrialTimeOut(rhs.m_connectionRetrialTimeOut),
76  m_poolAutomaticCleanUp(rhs.m_poolAutomaticCleanUp),
77  m_authPath(rhs.m_authPath),
78  m_authSys(rhs.m_authSys),
79  m_transactionId(rhs.m_transactionId),
80  m_messageLevel(rhs.m_messageLevel),
81  m_monitoringLevel(rhs.m_monitoringLevel),
82  m_SQLMonitoring(rhs.m_SQLMonitoring),
84 }
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 86 of file DbConnectionConfiguration.cc.

86  {
87  delete m_pluginManager;
88 }

Member Function Documentation

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

Definition at line 320 of file DbConnectionConfiguration.cc.

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

Definition at line 203 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, instance, and AlCaHLTBitMon_QueryRunRegistry::string.

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

308  {
309  return m_connectionRetrialPeriod.second;
310 }
std::pair< bool, int > m_connectionRetrialPeriod
int cond::DbConnectionConfiguration::connectionRetrialTimeOut ( ) const

Definition at line 312 of file DbConnectionConfiguration.cc.

312  {
313  return m_connectionRetrialTimeOut.second;
314 }
std::pair< bool, int > m_connectionRetrialTimeOut
int cond::DbConnectionConfiguration::connectionTimeOut ( ) const

Definition at line 300 of file DbConnectionConfiguration.cc.

300  {
301  return m_connectionTimeOut.second;
302 }
const std::vector< cond::DbConnectionConfiguration > & cond::DbConnectionConfiguration::defaultConfigurations ( )
static

Definition at line 17 of file DbConnectionConfiguration.cc.

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

17  {
18  static const std::vector<DbConnectionConfiguration> s_defaultConfigurations =
20  cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "", coral::Error, coral::monitor::Off, false ),
21  cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "", coral::Error, coral::monitor::Off, false ),
22  cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "",coral::Error, coral::monitor::Off, false ),
23  cond::DbConnectionConfiguration( false, 0, false, 10, 60, false, "", "",coral::Error, coral::monitor::Off, false )
24  };
25  return s_defaultConfigurations;
26 }
bool cond::DbConnectionConfiguration::isConnectionSharingEnabled ( ) const

Definition at line 295 of file DbConnectionConfiguration.cc.

296 {
297  return m_connectionSharing.second;
298 }
std::pair< bool, bool > m_connectionSharing
bool cond::DbConnectionConfiguration::isPoolAutomaticCleanUpEnabled ( ) const

Definition at line 316 of file DbConnectionConfiguration.cc.

316  {
317  return m_poolAutomaticCleanUp.second;
318 }
std::pair< bool, bool > m_poolAutomaticCleanUp
bool cond::DbConnectionConfiguration::isReadOnlySessionOnUpdateConnectionEnabled ( ) const

Definition at line 304 of file DbConnectionConfiguration.cc.

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

Definition at line 335 of file DbConnectionConfiguration.cc.

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

Definition at line 330 of file DbConnectionConfiguration.cc.

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

Definition at line 91 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.

91  {
92  m_connectionSharing = rhs.m_connectionSharing;
93  m_connectionTimeOut = rhs.m_connectionTimeOut;
94  m_readOnlySessionOnUpdateConnections = rhs.m_readOnlySessionOnUpdateConnections;
95  m_connectionRetrialPeriod = rhs.m_connectionRetrialPeriod;
96  m_connectionRetrialTimeOut = rhs.m_connectionRetrialTimeOut;
97  m_poolAutomaticCleanUp = rhs.m_poolAutomaticCleanUp;
98  m_authPath = rhs.m_authPath;
99  m_authSys = rhs.m_authSys;
100  m_transactionId=rhs.m_transactionId;
101  m_messageLevel = rhs.m_messageLevel;
102  m_monitoringLevel = rhs.m_monitoringLevel;
103  m_SQLMonitoring = rhs.m_SQLMonitoring;
104  return *this;
105 }
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 181 of file DbConnectionConfiguration.cc.

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

Definition at line 162 of file DbConnectionConfiguration.cc.

162  {
163  m_connectionRetrialPeriod.first = true;
164  m_connectionRetrialPeriod.second = period;
165 }
std::pair< bool, int > m_connectionRetrialPeriod
void cond::DbConnectionConfiguration::setConnectionRetrialTimeOut ( int  timeout)

Definition at line 167 of file DbConnectionConfiguration.cc.

167  {
168  m_connectionRetrialTimeOut.first = true;
169  m_connectionRetrialTimeOut.second = timeout;
170 }
std::pair< bool, int > m_connectionRetrialTimeOut
void cond::DbConnectionConfiguration::setConnectionSharing ( bool  flag)

Definition at line 147 of file DbConnectionConfiguration.cc.

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

147  {
148  m_connectionSharing.first = true;
149  m_connectionSharing.second = flag;
150 }
std::pair< bool, bool > m_connectionSharing
void cond::DbConnectionConfiguration::setConnectionTimeOut ( int  timeOut)

Definition at line 152 of file DbConnectionConfiguration.cc.

Referenced by FillInfoPopConSourceHandler::getNewObjects().

152  {
153  m_connectionTimeOut.first = true;
154  m_connectionTimeOut.second = timeOut;
155 }
void cond::DbConnectionConfiguration::setMessageLevel ( coral::MsgLevel  l)
void cond::DbConnectionConfiguration::setMonitoringLevel ( coral::monitor::Level  l)

Definition at line 193 of file DbConnectionConfiguration.cc.

References ConfigFiles::l.

194 {
195  m_monitoringLevel = l;
196 }
void cond::DbConnectionConfiguration::setParameters ( const edm::ParameterSet connectionPset)

Definition at line 107 of file DbConnectionConfiguration.cc.

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

107  {
108  std::string authPath = connectionPset.getUntrackedParameter<std::string>("authenticationPath","");
109  setAuthenticationPath(authPath);
110  int authSysPar = connectionPset.getUntrackedParameter<int>("authenticationSystem",0);
111  setAuthenticationSystem( authSysPar );
112  setTransactionId(connectionPset.getUntrackedParameter<std::string>("transactionId",""));
113  int messageLevel = connectionPset.getUntrackedParameter<int>("messageLevel",0);
114  coral::MsgLevel level = coral::Error;
115  switch (messageLevel) {
116  case 0 :
117  level = coral::Error;
118  break;
119  case 1:
120  level = coral::Warning;
121  break;
122  case 2:
123  level = coral::Info;
124  break;
125  case 3:
126  level = coral::Debug;
127  break;
128  default:
129  level = coral::Error;
130  }
131  setMessageLevel(level);
132  bool enableConnectionSharing = connectionPset.getUntrackedParameter<bool>("enableConnectionSharing",true);
133  setConnectionSharing( enableConnectionSharing );
134  int connectionTimeOut = connectionPset.getUntrackedParameter<int>("connectionTimeOut",600);
135  setConnectionTimeOut( connectionTimeOut );
136  bool enableReadOnlySessionOnUpdateConnection = connectionPset.getUntrackedParameter<bool>("enableReadOnlySessionOnUpdateConnection",true);
137  setReadOnlySessionOnUpdateConnections( enableReadOnlySessionOnUpdateConnection );
138  int connectionRetrialPeriod = connectionPset.getUntrackedParameter<int>("connectionRetrialPeriod",30);
139  setConnectionRetrialPeriod( connectionRetrialPeriod );
140  int connectionRetrialTimeOut = connectionPset.getUntrackedParameter<int>("connectionRetrialTimeOut",180);
141  setConnectionRetrialTimeOut( connectionRetrialTimeOut );
142  bool enablePoolAutomaticCleanUp = connectionPset.getUntrackedParameter<bool>("enablePoolAutomaticCleanUp",false);
143  setPoolAutomaticCleanUp( enablePoolAutomaticCleanUp );
144  //int idleConnectionCleanupPeriod = connectionPset.getUntrackedParameter<int>("idleConnectionCleanupPeriod",300);
145 }
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 172 of file DbConnectionConfiguration.cc.

Referenced by FillInfoPopConSourceHandler::getNewObjects().

172  {
173  m_poolAutomaticCleanUp.first = true;
174  m_poolAutomaticCleanUp.second = flag;
175 }
std::pair< bool, bool > m_poolAutomaticCleanUp
void cond::DbConnectionConfiguration::setReadOnlySessionOnUpdateConnections ( bool  flag)

Definition at line 157 of file DbConnectionConfiguration.cc.

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

157  {
160 }
std::pair< bool, bool > m_readOnlySessionOnUpdateConnections
void cond::DbConnectionConfiguration::setSQLMonitoring ( bool  flag)

Definition at line 199 of file DbConnectionConfiguration.cc.

199  {
200  m_SQLMonitoring = flag;
201 }
void cond::DbConnectionConfiguration::setTransactionId ( std::string const &  tid)

Definition at line 185 of file DbConnectionConfiguration.cc.

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

Definition at line 325 of file DbConnectionConfiguration.cc.

325  {
326  return m_transactionId;
327 }

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