7 #include "RelationalAccess/IConnectionServiceConfiguration.h"
8 #include "CoralKernel/Context.h"
9 #include "CoralKernel/IProperty.h"
10 #include "CoralKernel/IPropertyManager.h"
12 #include <boost/filesystem/operations.hpp>
15 std::vector<cond::DbConnectionConfiguration>&
17 static std::vector<DbConnectionConfiguration> s_defaultConfigurations;
21 s_defaultConfigurations.push_back(
cond::DbConnectionConfiguration(
false, 0,
false, 10, 60,
false,
"",
"", coral::Error, coral::monitor::Off,
false ) );
23 s_defaultConfigurations.push_back(
cond::DbConnectionConfiguration(
false, 0,
false, 10, 60,
false,
"",
"", coral::Error, coral::monitor::Off,
false ) );
25 s_defaultConfigurations.push_back(
cond::DbConnectionConfiguration(
false, 0,
false, 10, 60,
false,
"",
"",coral::Error, coral::monitor::Off,
false ) );
27 s_defaultConfigurations.push_back(
cond::DbConnectionConfiguration(
false, 0,
false, 10, 60,
false,
"",
"",coral::Error, coral::monitor::Off,
false ) );
28 return s_defaultConfigurations;
33 m_connectionTimeOut(
false,0),
34 m_readOnlySessionOnUpdateConnections(
false,
false),
35 m_connectionRetrialPeriod(
false,0),
36 m_connectionRetrialTimeOut(
false,0),
40 m_messageLevel(coral::Error),
41 m_monitoringLevel(coral::monitor::Off),
42 m_SQLMonitoring(
false),
47 int connectionTimeOut,
48 bool readOnlySessionOnUpdateConnections,
49 int connectionRetrialPeriod,
50 int connectionRetrialTimeOut,
51 bool poolAutomaticCleanUp,
52 const::std::string& authenticationPath,
53 const::std::string& transactionId,
54 coral::MsgLevel msgLev,
55 coral::monitor::Level monitorLev,
57 m_connectionSharing(
true,connectionSharing),
58 m_connectionTimeOut(
true,connectionTimeOut),
59 m_readOnlySessionOnUpdateConnections(
true,readOnlySessionOnUpdateConnections),
60 m_connectionRetrialPeriod(
true,connectionRetrialPeriod),
61 m_connectionRetrialTimeOut(
true,connectionRetrialTimeOut),
62 m_poolAutomaticCleanUp(
true,poolAutomaticCleanUp),
63 m_authPath(authenticationPath),
64 m_transactionId(transactionId),
65 m_messageLevel(msgLev),
66 m_monitoringLevel(monitorLev),
67 m_SQLMonitoring(SQLMonitoring),
72 m_connectionSharing(rhs.m_connectionSharing),
73 m_connectionTimeOut(rhs.m_connectionTimeOut),
74 m_readOnlySessionOnUpdateConnections(rhs.m_readOnlySessionOnUpdateConnections),
75 m_connectionRetrialPeriod(rhs.m_connectionRetrialPeriod),
76 m_connectionRetrialTimeOut(rhs.m_connectionRetrialTimeOut),
77 m_poolAutomaticCleanUp(rhs.m_poolAutomaticCleanUp),
78 m_authPath(rhs.m_authPath),
79 m_transactionId(rhs.m_transactionId),
80 m_messageLevel(rhs.m_messageLevel),
81 m_monitoringLevel(rhs.m_monitoringLevel),
82 m_SQLMonitoring(rhs.m_SQLMonitoring),
87 delete m_pluginManager;
108 setAuthenticationPath(authPath);
111 coral::MsgLevel
level = coral::Error;
112 switch (messageLevel) {
114 level = coral::Error;
117 level = coral::Warning;
126 level = coral::Error;
128 setMessageLevel(level);
129 bool enableConnectionSharing = connectionPset.
getUntrackedParameter<
bool>(
"enableConnectionSharing",
true);
130 setConnectionSharing( enableConnectionSharing );
132 setConnectionTimeOut( connectionTimeOut );
133 bool enableReadOnlySessionOnUpdateConnection = connectionPset.
getUntrackedParameter<
bool>(
"enableReadOnlySessionOnUpdateConnection",
true);
134 setReadOnlySessionOnUpdateConnections( enableReadOnlySessionOnUpdateConnection );
135 int connectionRetrialPeriod = connectionPset.
getUntrackedParameter<
int>(
"connectionRetrialPeriod",30);
136 setConnectionRetrialPeriod( connectionRetrialPeriod );
137 int connectionRetrialTimeOut = connectionPset.
getUntrackedParameter<
int>(
"connectionRetrialTimeOut",180);
138 setConnectionRetrialTimeOut( connectionRetrialTimeOut );
139 bool enablePoolAutomaticCleanUp = connectionPset.
getUntrackedParameter<
bool>(
"enablePoolAutomaticCleanUp",
false);
140 setPoolAutomaticCleanUp( enablePoolAutomaticCleanUp );
145 m_connectionSharing.first =
true;
146 m_connectionSharing.second =
flag;
150 m_connectionTimeOut.first =
true;
151 m_connectionTimeOut.second = timeOut;
155 m_readOnlySessionOnUpdateConnections.first =
true;
156 m_readOnlySessionOnUpdateConnections.second =
flag;
160 m_connectionRetrialPeriod.first =
true;
161 m_connectionRetrialPeriod.second =
period;
165 m_connectionRetrialTimeOut.first =
true;
166 m_connectionRetrialTimeOut.second = timeout;
170 m_poolAutomaticCleanUp.first =
true;
171 m_poolAutomaticCleanUp.second =
flag;
189 m_monitoringLevel =
l;
194 m_SQLMonitoring =
flag;
200 coral::MessageStream::setMsgVerbosity( m_messageLevel );
202 std::string authServiceName(
"CORAL/Services/EnvironmentAuthenticationService");
203 if( !m_authPath.empty() )
205 authServiceName =
"COND/Services/XMLAuthenticationService";
207 if(boost::filesystem::is_directory(boostAuthPath))
211 std::string authFileName = boostAuthPath.string();
212 coral::Context::instance().PropertyManager().property(
"AuthenticationFile")->set(authFileName);
213 coral::Context::instance().loadComponent( authServiceName, m_pluginManager );
215 coralConfig.setAuthenticationService( authServiceName );
217 if(m_connectionSharing.first)
219 if(m_connectionSharing.second) coralConfig.enableConnectionSharing();
220 else coralConfig.disableConnectionSharing();
223 if(m_connectionTimeOut.first)
225 coralConfig.setConnectionTimeOut(m_connectionTimeOut.second);
228 if(m_readOnlySessionOnUpdateConnections.first)
230 if(m_readOnlySessionOnUpdateConnections.second) coralConfig.enableReadOnlySessionOnUpdateConnections();
231 else coralConfig.disableReadOnlySessionOnUpdateConnections();
234 if(m_poolAutomaticCleanUp.first)
236 if(m_poolAutomaticCleanUp.second) coralConfig.enablePoolAutomaticCleanUp();
237 else coralConfig.disablePoolAutomaticCleanUp();
240 if(m_connectionRetrialPeriod.first)
242 coralConfig.setConnectionRetrialPeriod( m_connectionRetrialPeriod.second );
245 if( m_connectionRetrialTimeOut.first)
247 coralConfig.setConnectionRetrialTimeOut(m_connectionRetrialTimeOut.second );
250 coralConfig.setMonitoringLevel( m_monitoringLevel );
252 if( m_SQLMonitoring )
254 std::string pluginName(
"COND/Services/SQLMonitoringService");
255 coral::Context::instance().loadComponent( pluginName, m_pluginManager );
256 coralConfig.setMonitoringLevel(coral::monitor::Trace);
263 return m_connectionSharing.second;
267 return m_connectionTimeOut.second;
271 return m_readOnlySessionOnUpdateConnections.second;
275 return m_connectionRetrialPeriod.second;
279 return m_connectionRetrialTimeOut.second;
283 return m_poolAutomaticCleanUp.second;
292 return m_transactionId;
298 return m_messageLevel;
303 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
std::pair< bool, bool > m_poolAutomaticCleanUp
void setConnectionRetrialPeriod(int period)
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
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)
std::pair< bool, int > m_connectionTimeOut
void setConnectionTimeOut(int timeOut)
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