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 const std::vector<cond::DbConnectionConfiguration>&
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 )
25 return s_defaultConfigurations;
30 m_connectionTimeOut(
false,0),
31 m_readOnlySessionOnUpdateConnections(
false,
false),
32 m_connectionRetrialPeriod(
false,0),
33 m_connectionRetrialTimeOut(
false,0),
38 m_messageLevel(coral::Error),
39 m_monitoringLevel(coral::monitor::Off),
40 m_SQLMonitoring(
false),
45 int connectionTimeOut,
46 bool readOnlySessionOnUpdateConnections,
47 int connectionRetrialPeriod,
48 int connectionRetrialTimeOut,
49 bool poolAutomaticCleanUp,
52 coral::MsgLevel msgLev,
55 m_connectionSharing(
true,connectionSharing),
56 m_connectionTimeOut(
true,connectionTimeOut),
57 m_readOnlySessionOnUpdateConnections(
true,readOnlySessionOnUpdateConnections),
58 m_connectionRetrialPeriod(
true,connectionRetrialPeriod),
59 m_connectionRetrialTimeOut(
true,connectionRetrialTimeOut),
60 m_poolAutomaticCleanUp(
true,poolAutomaticCleanUp),
61 m_authPath(authenticationPath),
63 m_transactionId(transactionId),
64 m_messageLevel(msgLev),
65 m_monitoringLevel(monitorLev),
66 m_SQLMonitoring(SQLMonitoring),
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),
87 delete m_pluginManager;
109 setAuthenticationPath(authPath);
111 setAuthenticationSystem( authSysPar );
114 coral::MsgLevel
level = coral::Error;
115 switch (messageLevel) {
117 level = coral::Error;
120 level = coral::Warning;
129 level = coral::Error;
131 setMessageLevel(level);
132 bool enableConnectionSharing = connectionPset.
getUntrackedParameter<
bool>(
"enableConnectionSharing",
true);
133 setConnectionSharing( enableConnectionSharing );
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 );
148 m_connectionSharing.first =
true;
149 m_connectionSharing.second = flag;
153 m_connectionTimeOut.first =
true;
154 m_connectionTimeOut.second = timeOut;
158 m_readOnlySessionOnUpdateConnections.first =
true;
159 m_readOnlySessionOnUpdateConnections.second = flag;
163 m_connectionRetrialPeriod.first =
true;
164 m_connectionRetrialPeriod.second =
period;
168 m_connectionRetrialTimeOut.first =
true;
169 m_connectionRetrialTimeOut.second = timeout;
173 m_poolAutomaticCleanUp.first =
true;
174 m_poolAutomaticCleanUp.second = flag;
182 m_authSys = authSysCode;
195 m_monitoringLevel =
l;
200 m_SQLMonitoring = flag;
206 coral::MessageStream::setMsgVerbosity( m_messageLevel );
207 std::string authServiceName(
"CORAL/Services/EnvironmentAuthenticationService");
210 if( authPath.empty() ){
217 int authSys = m_authSys;
221 authSys = ::atoi( authSysEnv );
229 if( authPath.empty() ){
230 const char* authEnv = ::getenv(
"HOME");
235 servName =
"COND/Services/RelationalAuthenticationService";
238 if( authPath.empty() ){
241 servName =
"COND/Services/XMLAuthenticationService";
244 if( !authPath.empty() ){
245 authServiceName = servName;
249 coralConfig.setAuthenticationService( authServiceName );
251 if(m_connectionSharing.first)
253 if(m_connectionSharing.second) coralConfig.enableConnectionSharing();
254 else coralConfig.disableConnectionSharing();
257 if(m_connectionTimeOut.first)
259 coralConfig.setConnectionTimeOut(m_connectionTimeOut.second);
262 if(m_readOnlySessionOnUpdateConnections.first)
264 if(m_readOnlySessionOnUpdateConnections.second) coralConfig.enableReadOnlySessionOnUpdateConnections();
265 else coralConfig.disableReadOnlySessionOnUpdateConnections();
268 if(m_poolAutomaticCleanUp.first)
270 if(m_poolAutomaticCleanUp.second) coralConfig.enablePoolAutomaticCleanUp();
271 else coralConfig.disablePoolAutomaticCleanUp();
274 if(m_connectionRetrialPeriod.first)
276 coralConfig.setConnectionRetrialPeriod( m_connectionRetrialPeriod.second );
279 if( m_connectionRetrialTimeOut.first)
281 coralConfig.setConnectionRetrialTimeOut(m_connectionRetrialTimeOut.second );
284 coralConfig.setMonitoringLevel( m_monitoringLevel );
286 if( m_SQLMonitoring )
288 std::string pluginName(
"COND/Services/SQLMonitoringService");
290 coralConfig.setMonitoringLevel(coral::monitor::Trace);
297 return m_connectionSharing.second;
301 return m_connectionTimeOut.second;
305 return m_readOnlySessionOnUpdateConnections.second;
309 return m_connectionRetrialPeriod.second;
313 return m_connectionRetrialTimeOut.second;
317 return m_poolAutomaticCleanUp.second;
326 return m_transactionId;
332 return m_messageLevel;
337 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
void setMonitoringLevel(coral::monitor::Level l)
volatile std::atomic< bool > shutdown_flag false
coral::MsgLevel messageLevel() const
static const std::vector< DbConnectionConfiguration > & defaultConfigurations()