ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConf::SessionMgr Class Reference

Manager of the database session. More...

#include <SessionMgr.h>

Inheritance diagram for TrigConf::SessionMgr:
Collaboration diagram for TrigConf::SessionMgr:

Public Member Functions

 SessionMgr ()
 constructor
virtual ~SessionMgr () override
 destructor
void closeSession ()
 close open sessions
coral::ISessionProxy & createSession ()
 instantiates the session
void setTypeConversionRules ()
 SQL -> C++ type conversion mapping for Oracle database to match MySQL.
void setConnectionString (const std::string &connStr)
void setUseFrontier (bool useFrontier)
void setRetrialPeriod (int retrialPeriod)
void setRetrialTimeout (int retrialTimeout)
void setConnectionTimeout (int connectionTimeout)
void setDbType (const std::string &s)
void setDbServer (const std::string &s)
void setDbName (const std::string &s)
void setDbUser (const std::string &s)
void setDbPassword (const std::string &s)
const std::string & connection () const
bool useFrontier () const
int retrialPeriod () const
int retrialTimeout () const
int connectionTimeout () const
const std::string & dbType () const
const std::string & dbServer () const
const std::string & dbName () const
const std::string & dbUser () const
const std::string & dbPassword () const
bool msgLvl (const MSGTC::Level lvl) const
 Test the output level.
MsgStreamTCmsg () const
 The standard message stream.
MsgStreamTCmsg (const MSGTC::Level lvl) const
 The standard message stream.
const std::string & getName () const
 name accessor

Private Member Functions

void buildConnectionString ()
void setCppTypeForSqlType (const std::string &cpp_type, const std::string &sql_type)
 SQL -> C++ type conversion interface to CORAL.

Private Attributes

coral::ISessionProxy * m_sessionproxy { nullptr }
 the coral database session
std::string m_connectionString { "" }
 connection string
std::string m_dbtype { "" }
 db type
std::string m_dbserver { "" }
 db server
std::string m_dbname { "" }
 db name
std::string m_user { "" }
 user name
std::string m_password { "" }
 password
bool m_useFrontier { false }
 uses frontier instead of oracle
int m_retrialPeriod {0}
int m_retrialTimeout {0}
int m_connectionTimeout {0}
ReplicaSorterm_replicaSorter { nullptr }
boost::thread_specific_ptr< MsgStreamTCm_msg_tls
 MsgStreamTC instance (a std::cout like with print-out levels)
std::string m_name

Detailed Description

Manager of the database session.

it uses CORAL to connect to the different DB technologies

Definition at line 29 of file SessionMgr.h.

Constructor & Destructor Documentation

◆ SessionMgr()

SessionMgr::SessionMgr ( )

constructor

Definition at line 37 of file SessionMgr.cxx.

37 :
38 TrigConfMessaging("SessionMgr")
39{}

◆ ~SessionMgr()

SessionMgr::~SessionMgr ( )
overridevirtual

destructor

Definition at line 41 of file SessionMgr.cxx.

41 {
42 // Dtors are noexcept by default, so if closeSession() throws,
43 // std::terminate will be called. However, cppcheck warns here
44 // about the uncaught exception, so do the std::terminate call
45 // explicitly.
46 try {
48 } catch (...) {
49 std::terminate();
50 }
51 // never delete the m_replicaSorter, we will have to live with that
52 // one-time memory leak. The problem is the CORAL interface that
53 // does keeps a reference to the replicaSorter and keeps using it
54 // but doesn't clean it up. And if we delete it too early, then
55 // later access leads to a crash
56}
void closeSession()
close open sessions

Member Function Documentation

◆ buildConnectionString()

void TrigConf::SessionMgr::buildConnectionString ( )
private

Definition at line 76 of file SessionMgr.cxx.

76 {
77
78 if(m_connectionString!="")
79 return;
80
81 if(m_dbserver=="") {
83 } else if(m_dbtype == "dblookup") {
85 } else {
87 }
88}
std::string m_dbtype
db type
Definition SessionMgr.h:84
std::string m_dbname
db name
Definition SessionMgr.h:86
std::string m_dbserver
db server
Definition SessionMgr.h:85
std::string m_connectionString
connection string
Definition SessionMgr.h:83

◆ closeSession()

void SessionMgr::closeSession ( )

close open sessions

Definition at line 59 of file SessionMgr.cxx.

59 {
60
61 if(m_sessionproxy) {
62 try{
63 delete m_sessionproxy;
64 m_sessionproxy = nullptr;
65 TRG_MSG_INFO("Closing session " << m_connectionString);
66 }
67 catch ( coral::Exception& e ) {
68 TRG_MSG_WARNING("CORAL exception " << e.what());
69 throw;
70 }
71 }
72
73}
coral::ISessionProxy * m_sessionproxy
the coral database session
Definition SessionMgr.h:81

◆ connection()

const std::string & TrigConf::SessionMgr::connection ( ) const
inline

Definition at line 62 of file SessionMgr.h.

62{ return m_connectionString; }

◆ connectionTimeout()

int TrigConf::SessionMgr::connectionTimeout ( ) const
inline

Definition at line 66 of file SessionMgr.h.

66{ return m_connectionTimeout; }

◆ createSession()

coral::ISessionProxy & TrigConf::SessionMgr::createSession ( )

instantiates the session

Definition at line 92 of file SessionMgr.cxx.

92 {
93
94 if( m_sessionproxy ) return *m_sessionproxy;
95
96 coral::ConnectionService connSvc;
97 coral::IConnectionServiceConfiguration& csc = connSvc.configuration();
98 csc.setConnectionRetrialPeriod( m_retrialPeriod );
99 csc.setConnectionRetrialTimeOut( m_retrialTimeout );
100 csc.setConnectionTimeOut( m_connectionTimeout );
101
102
103 if(csc.replicaSortingAlgorithm() == nullptr) { // likely to be standalone, create our own
104 TRG_MSG_INFO("Create own ReplicaSortingAlgorithm");
105 m_replicaSorter = new TrigConf::ReplicaSorter();
106 csc.setReplicaSortingAlgorithm(*m_replicaSorter);
107 }
108
110 TRG_MSG_INFO("Connecting to " << m_connectionString);
111 m_sessionproxy = connSvc.connect(m_connectionString, coral::AccessMode::ReadOnly);
112 TRG_MSG_INFO("Opening session " << m_connectionString << " with " << m_retrialPeriod << "/" << m_retrialTimeout << "/" << m_connectionTimeout);
113
114 return *m_sessionproxy;
115}
ReplicaSorter * m_replicaSorter
Definition SessionMgr.h:94

◆ dbName()

const std::string & TrigConf::SessionMgr::dbName ( ) const
inline

Definition at line 69 of file SessionMgr.h.

69{ return m_dbname; }

◆ dbPassword()

const std::string & TrigConf::SessionMgr::dbPassword ( ) const
inline

Definition at line 71 of file SessionMgr.h.

71{ return m_password; }
std::string m_password
password
Definition SessionMgr.h:88

◆ dbServer()

const std::string & TrigConf::SessionMgr::dbServer ( ) const
inline

Definition at line 68 of file SessionMgr.h.

68{ return m_dbserver; }

◆ dbType()

const std::string & TrigConf::SessionMgr::dbType ( ) const
inline

Definition at line 67 of file SessionMgr.h.

67{ return m_dbtype; }

◆ dbUser()

const std::string & TrigConf::SessionMgr::dbUser ( ) const
inline

Definition at line 70 of file SessionMgr.h.

70{ return m_user; }
std::string m_user
user name
Definition SessionMgr.h:87

◆ getName()

const std::string & TrigConf::TrigConfMessaging::getName ( ) const
inlineinherited

name accessor

Returns
the name

Definition at line 101 of file TrigConfMessaging.h.

101 {
102 return m_name;
103 }

◆ msg() [1/2]

MsgStreamTC & TrigConf::TrigConfMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 86 of file TrigConfMessaging.h.

87 {
88 MsgStreamTC* ms = m_msg_tls.get();
89 if (!ms) {
90 ms = new MsgStreamTC(m_name);
91 m_msg_tls.reset(ms);
92 }
93 return *ms;
94 }
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
MsgStreamTC instance (a std::cout like with print-out levels)

◆ msg() [2/2]

MsgStreamTC & TrigConf::TrigConfMessaging::msg ( const MSGTC::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 96 of file TrigConfMessaging.h.

97 {
98 return msg() << lvl;
99 }
MsgStreamTC & msg() const
The standard message stream.

◆ msgLvl()

bool TrigConf::TrigConfMessaging::msgLvl ( const MSGTC::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 75 of file TrigConfMessaging.h.

76 {
77 if (msg().level() <= lvl) {
78 msg() << lvl;
79 return true;
80 }
81 else {
82 return false;
83 }
84 }

◆ retrialPeriod()

int TrigConf::SessionMgr::retrialPeriod ( ) const
inline

Definition at line 64 of file SessionMgr.h.

64{ return m_retrialPeriod; }

◆ retrialTimeout()

int TrigConf::SessionMgr::retrialTimeout ( ) const
inline

Definition at line 65 of file SessionMgr.h.

65{ return m_retrialTimeout; }

◆ setConnectionString()

void TrigConf::SessionMgr::setConnectionString ( const std::string & connStr)
inline

Definition at line 49 of file SessionMgr.h.

◆ setConnectionTimeout()

void TrigConf::SessionMgr::setConnectionTimeout ( int connectionTimeout)
inline

Definition at line 53 of file SessionMgr.h.

◆ setCppTypeForSqlType()

void TrigConf::SessionMgr::setCppTypeForSqlType ( const std::string & cpp_type,
const std::string & sql_type )
private

SQL -> C++ type conversion interface to CORAL.

◆ setDbName()

void TrigConf::SessionMgr::setDbName ( const std::string & s)

Definition at line 131 of file SessionMgr.cxx.

131 {
132 m_dbname = s;
134}

◆ setDbPassword()

void TrigConf::SessionMgr::setDbPassword ( const std::string & s)

Definition at line 143 of file SessionMgr.cxx.

143 {
144 m_password = s;
146}

◆ setDbServer()

void TrigConf::SessionMgr::setDbServer ( const std::string & s)

Definition at line 125 of file SessionMgr.cxx.

125 {
126 m_dbserver = s;
128}

◆ setDbType()

void TrigConf::SessionMgr::setDbType ( const std::string & s)

Definition at line 119 of file SessionMgr.cxx.

119 {
120 m_dbtype = boost::to_lower_copy(s);
122}

◆ setDbUser()

void TrigConf::SessionMgr::setDbUser ( const std::string & s)

Definition at line 137 of file SessionMgr.cxx.

137 {
138 m_user = s;
140}

◆ setRetrialPeriod()

void TrigConf::SessionMgr::setRetrialPeriod ( int retrialPeriod)
inline

Definition at line 51 of file SessionMgr.h.

◆ setRetrialTimeout()

void TrigConf::SessionMgr::setRetrialTimeout ( int retrialTimeout)
inline

Definition at line 52 of file SessionMgr.h.

◆ setTypeConversionRules()

void TrigConf::SessionMgr::setTypeConversionRules ( )

SQL -> C++ type conversion mapping for Oracle database to match MySQL.

◆ setUseFrontier()

void TrigConf::SessionMgr::setUseFrontier ( bool useFrontier)
inline

Definition at line 50 of file SessionMgr.h.

bool useFrontier() const
Definition SessionMgr.h:63
bool m_useFrontier
uses frontier instead of oracle
Definition SessionMgr.h:89

◆ useFrontier()

bool TrigConf::SessionMgr::useFrontier ( ) const
inline

Definition at line 63 of file SessionMgr.h.

63{ return m_useFrontier; }

Member Data Documentation

◆ m_connectionString

std::string TrigConf::SessionMgr::m_connectionString { "" }
private

connection string

Definition at line 83 of file SessionMgr.h.

83{ "" };

◆ m_connectionTimeout

int TrigConf::SessionMgr::m_connectionTimeout {0}
private

Definition at line 92 of file SessionMgr.h.

92{0};

◆ m_dbname

std::string TrigConf::SessionMgr::m_dbname { "" }
private

db name

Definition at line 86 of file SessionMgr.h.

86{ "" };

◆ m_dbserver

std::string TrigConf::SessionMgr::m_dbserver { "" }
private

db server

Definition at line 85 of file SessionMgr.h.

85{ "" };

◆ m_dbtype

std::string TrigConf::SessionMgr::m_dbtype { "" }
private

db type

Definition at line 84 of file SessionMgr.h.

84{ "" };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStreamTC> TrigConf::TrigConfMessaging::m_msg_tls
mutableprivateinherited

MsgStreamTC instance (a std::cout like with print-out levels)

Definition at line 71 of file TrigConfMessaging.h.

◆ m_name

std::string TrigConf::TrigConfMessaging::m_name
privateinherited

Definition at line 72 of file TrigConfMessaging.h.

◆ m_password

std::string TrigConf::SessionMgr::m_password { "" }
private

password

Definition at line 88 of file SessionMgr.h.

88{ "" };

◆ m_replicaSorter

ReplicaSorter* TrigConf::SessionMgr::m_replicaSorter { nullptr }
private

Definition at line 94 of file SessionMgr.h.

94{ nullptr }; // private replica sorter in case of standalone usage of SessionMgr

◆ m_retrialPeriod

int TrigConf::SessionMgr::m_retrialPeriod {0}
private

Definition at line 90 of file SessionMgr.h.

90{0};

◆ m_retrialTimeout

int TrigConf::SessionMgr::m_retrialTimeout {0}
private

Definition at line 91 of file SessionMgr.h.

91{0};

◆ m_sessionproxy

coral::ISessionProxy* TrigConf::SessionMgr::m_sessionproxy { nullptr }
private

the coral database session

Definition at line 81 of file SessionMgr.h.

81{ nullptr };

◆ m_useFrontier

bool TrigConf::SessionMgr::m_useFrontier { false }
private

uses frontier instead of oracle

Definition at line 89 of file SessionMgr.h.

89{ false };

◆ m_user

std::string TrigConf::SessionMgr::m_user { "" }
private

user name

Definition at line 87 of file SessionMgr.h.

87{ "" };

The documentation for this class was generated from the following files: