9 #include "RelationalAccess/IConnectionServiceConfiguration.h"
10 #include "CoralKernel/Context.h"
11 #include "CoralKernel/IProperty.h"
12 #include "CoralKernel/IPropertyManager.h"
14 #include <boost/filesystem/operations.hpp>
16 std::vector<cond::DbConnectionConfiguration>&
18 static std::vector<DbConnectionConfiguration> s_defaultConfigurations;
22 s_defaultConfigurations.push_back(
cond::DbConnectionConfiguration(
false, 0,
false, 10, 60,
false,
"",
"", coral::Error, coral::monitor::Off,
false ) );
24 s_defaultConfigurations.push_back(
cond::DbConnectionConfiguration(
false, 0,
false, 10, 60,
false,
"",
"", coral::Error, coral::monitor::Off,
false ) );
26 s_defaultConfigurations.push_back(
cond::DbConnectionConfiguration(
false, 0,
false, 10, 60,
false,
"",
"",coral::Error, coral::monitor::Off,
false ) );
28 s_defaultConfigurations.push_back(
cond::DbConnectionConfiguration(
false, 0,
false, 10, 60,
false,
"",
"",coral::Error, coral::monitor::Off,
false ) );
29 return s_defaultConfigurations;
34 m_connectionTimeOut(
false,0),
35 m_readOnlySessionOnUpdateConnections(
false,
false),
36 m_connectionRetrialPeriod(
false,0),
37 m_connectionRetrialTimeOut(
false,0),
42 m_messageLevel(coral::Error),
43 m_monitoringLevel(coral::monitor::Off),
44 m_SQLMonitoring(
false),
49 int connectionTimeOut,
50 bool readOnlySessionOnUpdateConnections,
51 int connectionRetrialPeriod,
52 int connectionRetrialTimeOut,
53 bool poolAutomaticCleanUp,
54 const::std::string& authenticationPath,
55 const::std::string& transactionId,
56 coral::MsgLevel msgLev,
57 coral::monitor::Level monitorLev,
59 m_connectionSharing(
true,connectionSharing),
60 m_connectionTimeOut(
true,connectionTimeOut),
61 m_readOnlySessionOnUpdateConnections(
true,readOnlySessionOnUpdateConnections),
62 m_connectionRetrialPeriod(
true,connectionRetrialPeriod),
63 m_connectionRetrialTimeOut(
true,connectionRetrialTimeOut),
64 m_poolAutomaticCleanUp(
true,poolAutomaticCleanUp),
65 m_authPath(authenticationPath),
67 m_transactionId(transactionId),
68 m_messageLevel(msgLev),
69 m_monitoringLevel(monitorLev),
70 m_SQLMonitoring(SQLMonitoring),
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),
91 delete m_pluginManager;
113 setAuthenticationPath(authPath);
115 setAuthenticationSystem( authSysPar );
118 coral::MsgLevel
level = coral::Error;
119 switch (messageLevel) {
121 level = coral::Error;
124 level = coral::Warning;
133 level = coral::Error;
135 setMessageLevel(level);
136 bool enableConnectionSharing = connectionPset.
getUntrackedParameter<
bool>(
"enableConnectionSharing",
true);
137 setConnectionSharing( enableConnectionSharing );
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 );
152 m_connectionSharing.first =
true;
153 m_connectionSharing.second =
flag;
157 m_connectionTimeOut.first =
true;
158 m_connectionTimeOut.second = timeOut;
162 m_readOnlySessionOnUpdateConnections.first =
true;
163 m_readOnlySessionOnUpdateConnections.second =
flag;
167 m_connectionRetrialPeriod.first =
true;
168 m_connectionRetrialPeriod.second = period;
172 m_connectionRetrialTimeOut.first =
true;
173 m_connectionRetrialTimeOut.second = timeout;
177 m_poolAutomaticCleanUp.first =
true;
178 m_poolAutomaticCleanUp.second =
flag;
186 m_authSys = authSysCode;
199 m_monitoringLevel =
l;
204 m_SQLMonitoring =
flag;
210 coral::MessageStream::setMsgVerbosity( m_messageLevel );
211 std::string authServiceName(
"CORAL/Services/EnvironmentAuthenticationService");
214 if( authPath.empty() ){
221 int authSys = m_authSys;
226 authSys = ::atoi( authSysEnv );
233 std::string servName(
"");
235 if( authPath.empty() ){
236 const char* authEnv = ::getenv(
"HOME");
241 servName =
"COND/Services/RelationalAuthenticationService";
244 if( authPath.empty() ){
247 servName =
"COND/Services/XMLAuthenticationService";
250 if( !authPath.empty() ){
251 authServiceName = servName;
255 coralConfig.setAuthenticationService( authServiceName );
257 if(m_connectionSharing.first)
259 if(m_connectionSharing.second) coralConfig.enableConnectionSharing();
260 else coralConfig.disableConnectionSharing();
263 if(m_connectionTimeOut.first)
265 coralConfig.setConnectionTimeOut(m_connectionTimeOut.second);
268 if(m_readOnlySessionOnUpdateConnections.first)
270 if(m_readOnlySessionOnUpdateConnections.second) coralConfig.enableReadOnlySessionOnUpdateConnections();
271 else coralConfig.disableReadOnlySessionOnUpdateConnections();
274 if(m_poolAutomaticCleanUp.first)
276 if(m_poolAutomaticCleanUp.second) coralConfig.enablePoolAutomaticCleanUp();
277 else coralConfig.disablePoolAutomaticCleanUp();
280 if(m_connectionRetrialPeriod.first)
282 coralConfig.setConnectionRetrialPeriod( m_connectionRetrialPeriod.second );
285 if( m_connectionRetrialTimeOut.first)
287 coralConfig.setConnectionRetrialTimeOut(m_connectionRetrialTimeOut.second );
290 coralConfig.setMonitoringLevel( m_monitoringLevel );
292 if( m_SQLMonitoring )
294 std::string pluginName(
"COND/Services/SQLMonitoringService");
296 coralConfig.setMonitoringLevel(coral::monitor::Trace);
303 return m_connectionSharing.second;
307 return m_connectionTimeOut.second;
311 return m_readOnlySessionOnUpdateConnections.second;
315 return m_connectionRetrialPeriod.second;
319 return m_connectionRetrialTimeOut.second;
323 return m_poolAutomaticCleanUp.second;
332 return m_transactionId;
338 return m_messageLevel;
343 return m_SQLMonitoring;
DbConnectionConfiguration & operator=(const DbConnectionConfiguration &rhs)
T getUntrackedParameter(std::string const &, T const &) const
~DbConnectionConfiguration()
bool isSQLMonitoringEnabled() const
void setReadOnlySessionOnUpdateConnections(bool flag)
const std::string & transactionId() const
void setTransactionId(std::string const &tid)
coral::MsgLevel m_messageLevel
static PFTauRenderPlugin instance
std::pair< bool, bool > m_poolAutomaticCleanUp
void setConnectionRetrialPeriod(int period)
static const std::string COND_AUTH_PATH_PROPERTY
int connectionTimeOut() const
void setParameters(const edm::ParameterSet &connectionPset)
std::pair< bool, int > m_connectionRetrialTimeOut
void setPoolAutomaticCleanUp(bool flag)
void setMessageLevel(coral::MsgLevel l)
bool isReadOnlySessionOnUpdateConnectionEnabled() const
static const char * COND_AUTH_SYS
std::string m_transactionId
void configure(coral::IConnectionServiceConfiguration &coralConfig) const
DbConnectionConfiguration()
std::pair< bool, int > m_connectionRetrialPeriod
bool isPoolAutomaticCleanUpEnabled() const
int connectionRetrialPeriod() const
std::pair< bool, bool > m_readOnlySessionOnUpdateConnections
bool isConnectionSharingEnabled() const
std::pair< bool, bool > m_connectionSharing
int connectionRetrialTimeOut() const
void setSQLMonitoring(bool flag)
void setAuthenticationSystem(int authSysCode)
std::pair< bool, int > m_connectionTimeOut
void setConnectionTimeOut(int timeOut)
static const char * COND_AUTH_PATH
void setAuthenticationPath(const std::string &p)
coral::monitor::Level m_monitoringLevel
void setConnectionRetrialTimeOut(int timeout)
void setConnectionSharing(bool flag)
const std::string & authenticationPath() const
static std::vector< DbConnectionConfiguration > & defaultConfigurations()
void setMonitoringLevel(coral::monitor::Level l)
coral::MsgLevel messageLevel() const