ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 More...
 
virtual ~SessionMgr () override
 destructor More...
 
void closeSession ()
 close open sessions More...
 
coral::ISessionProxy & createSession ()
 instantiates the session More...
 
void setTypeConversionRules ()
 SQL -> C++ type conversion mapping for Oracle database to match MySQL. More...
 
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. More...
 
MsgStreamTCmsg () const
 The standard message stream. More...
 
MsgStreamTCmsg (const MSGTC::Level lvl) const
 The standard message stream. More...
 

Private Member Functions

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

Private Attributes

coral::ISessionProxy * m_sessionproxy { nullptr }
 the coral database session More...
 
std::string m_connectionString { "" }
 connection string More...
 
std::string m_dbtype { "" }
 db type More...
 
std::string m_dbserver { "" }
 db server More...
 
std::string m_dbname { "" }
 db name More...
 
std::string m_user { "" }
 user name More...
 
std::string m_password { "" }
 password More...
 
bool m_useFrontier { false }
 uses frontier instead of oracle More...
 
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) More...
 
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  closeSession();
43  // never delete the m_replicaSorter, we will have to live with that
44  // one-time memory leak. The problem is the CORAL interface that
45  // does keeps a reference to the replicaSorter and keeps using it
46  // but doesn't clean it up. And if we delete it too early, then
47  // later access leads to a crash
48 }

Member Function Documentation

◆ buildConnectionString()

void TrigConf::SessionMgr::buildConnectionString ( )
private

Definition at line 68 of file SessionMgr.cxx.

68  {
69 
70  if(m_connectionString!="")
71  return;
72 
73  if(m_dbserver=="") {
75  } else if(m_dbtype == "dblookup") {
77  } else {
78  m_connectionString = m_dbtype + "://" + m_dbserver + "/" + m_dbname;
79  }
80 }

◆ closeSession()

void SessionMgr::closeSession ( )

close open sessions

Definition at line 51 of file SessionMgr.cxx.

51  {
52 
53  if(m_sessionproxy) {
54  try{
55  delete m_sessionproxy;
56  m_sessionproxy = nullptr;
57  TRG_MSG_INFO("Closing session " << m_connectionString);
58  }
59  catch ( coral::Exception& e ) {
60  TRG_MSG_WARNING("CORAL exception " << e.what());
61  throw;
62  }
63  }
64 
65 }

◆ 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 84 of file SessionMgr.cxx.

84  {
85 
86  if( m_sessionproxy ) return *m_sessionproxy;
87 
88  coral::ConnectionService connSvc;
89  coral::IConnectionServiceConfiguration& csc = connSvc.configuration();
90  csc.setConnectionRetrialPeriod( m_retrialPeriod );
91  csc.setConnectionRetrialTimeOut( m_retrialTimeout );
92  csc.setConnectionTimeOut( m_connectionTimeout );
93 
94 
95  if(csc.replicaSortingAlgorithm() == nullptr) { // likely to be standalone, create our own
96  TRG_MSG_INFO("Create own ReplicaSortingAlgorithm");
98  csc.setReplicaSortingAlgorithm(*m_replicaSorter);
99  }
100 
102  TRG_MSG_INFO("Connecting to " << m_connectionString);
103  m_sessionproxy = connSvc.connect(m_connectionString, coral::AccessMode::ReadOnly);
104  TRG_MSG_INFO("Opening session " << m_connectionString << " with " << m_retrialPeriod << "/" << m_retrialTimeout << "/" << m_connectionTimeout);
105 
106  return *m_sessionproxy;
107 }

◆ 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; }

◆ 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; }

◆ 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 81 of file TrigConfMessaging.h.

82  {
83  MsgStreamTC* ms = m_msg_tls.get();
84  if (!ms) {
85  ms = new MsgStreamTC(m_name);
86  m_msg_tls.reset(ms);
87  }
88  return *ms;
89  }

◆ 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 91 of file TrigConfMessaging.h.

92  {
93  return msg() << lvl;
94  }

◆ 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 70 of file TrigConfMessaging.h.

71  {
72  if (msg().level() <= lvl) {
73  msg() << lvl;
74  return true;
75  }
76  else {
77  return false;
78  }
79  }

◆ 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 123 of file SessionMgr.cxx.

123  {
124  m_dbname = s;
125  m_connectionString = "";
126 }

◆ setDbPassword()

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

Definition at line 135 of file SessionMgr.cxx.

135  {
136  m_password = s;
137  m_connectionString = "";
138 }

◆ setDbServer()

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

Definition at line 117 of file SessionMgr.cxx.

117  {
118  m_dbserver = s;
119  m_connectionString = "";
120 }

◆ setDbType()

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

Definition at line 111 of file SessionMgr.cxx.

111  {
112  m_dbtype = boost::to_lower_copy(s);
113  m_connectionString = "";
114 }

◆ setDbUser()

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

Definition at line 129 of file SessionMgr.cxx.

129  {
130  m_user = s;
131  m_connectionString = "";
132 }

◆ 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.

◆ 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.

◆ m_connectionTimeout

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

Definition at line 92 of file SessionMgr.h.

◆ m_dbname

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

db name

Definition at line 86 of file SessionMgr.h.

◆ m_dbserver

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

db server

Definition at line 85 of file SessionMgr.h.

◆ m_dbtype

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

db type

Definition at line 84 of file SessionMgr.h.

◆ 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 66 of file TrigConfMessaging.h.

◆ m_name

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

Definition at line 67 of file TrigConfMessaging.h.

◆ m_password

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

password

Definition at line 88 of file SessionMgr.h.

◆ m_replicaSorter

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

Definition at line 94 of file SessionMgr.h.

◆ m_retrialPeriod

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

Definition at line 90 of file SessionMgr.h.

◆ m_retrialTimeout

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

Definition at line 91 of file SessionMgr.h.

◆ m_sessionproxy

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

the coral database session

Definition at line 81 of file SessionMgr.h.

◆ m_useFrontier

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

uses frontier instead of oracle

Definition at line 89 of file SessionMgr.h.

◆ m_user

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

user name

Definition at line 87 of file SessionMgr.h.


The documentation for this class was generated from the following files:
TrigConf::SessionMgr::m_connectionString
std::string m_connectionString
connection string
Definition: SessionMgr.h:83
TrigConf::SessionMgr::m_connectionTimeout
int m_connectionTimeout
Definition: SessionMgr.h:92
TrigConf::SessionMgr::retrialTimeout
int retrialTimeout() const
Definition: SessionMgr.h:65
TrigConf::SessionMgr::m_password
std::string m_password
password
Definition: SessionMgr.h:88
TrigConf::SessionMgr::useFrontier
bool useFrontier() const
Definition: SessionMgr.h:63
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
TrigConf::SessionMgr::m_retrialTimeout
int m_retrialTimeout
Definition: SessionMgr.h:91
TrigConf::TrigConfMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
MsgStreamTC instance (a std::cout like with print-out levels)
Definition: TrigConfMessaging.h:66
TrigConf::SessionMgr::m_dbname
std::string m_dbname
db name
Definition: SessionMgr.h:86
TrigConf::SessionMgr::m_dbserver
std::string m_dbserver
db server
Definition: SessionMgr.h:85
TrigConf::ReplicaSorter
Definition: Trigger/TrigConfiguration/TrigConfStorage/src/ReplicaSorter.h:14
TrigConf::SessionMgr::m_sessionproxy
coral::ISessionProxy * m_sessionproxy
the coral database session
Definition: SessionMgr.h:81
CheckTagAssociation.connStr
connStr
Definition: CheckTagAssociation.py:85
TrigConf::SessionMgr::m_replicaSorter
ReplicaSorter * m_replicaSorter
Definition: SessionMgr.h:94
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TrigConf::SessionMgr::m_useFrontier
bool m_useFrontier
uses frontier instead of oracle
Definition: SessionMgr.h:89
TrigConf::TrigConfMessaging::m_name
std::string m_name
Definition: TrigConfMessaging.h:67
TrigConf::TrigConfMessaging::msg
MsgStreamTC & msg() const
The standard message stream.
Definition: TrigConfMessaging.h:81
TrigConf::TrigConfMessaging::TrigConfMessaging
TrigConfMessaging()=delete
TrigConf::SessionMgr::m_retrialPeriod
int m_retrialPeriod
Definition: SessionMgr.h:90
TrigConf::SessionMgr::m_user
std::string m_user
user name
Definition: SessionMgr.h:87
TrigConf::SessionMgr::retrialPeriod
int retrialPeriod() const
Definition: SessionMgr.h:64
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
TRG_MSG_WARNING
#define TRG_MSG_WARNING(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:28
TrigConf::SessionMgr::m_dbtype
std::string m_dbtype
db type
Definition: SessionMgr.h:84
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
TrigConf::SessionMgr::closeSession
void closeSession()
close open sessions
Definition: SessionMgr.cxx:51
TrigConf::SessionMgr::buildConnectionString
void buildConnectionString()
Definition: SessionMgr.cxx:68
TrigConf::SessionMgr::connectionTimeout
int connectionTimeout() const
Definition: SessionMgr.h:66