CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes
cond::persistency::SessionImpl Class Reference

#include <SessionImpl.h>

Public Types

enum  FailureOnOpeningPolicy { THROW, DO_NOT_THROW, CREATE }
 

Public Member Functions

void close ()
 
void commitTransaction ()
 
IGTSchemagtSchema ()
 
IIOVSchemaiovSchema ()
 
bool isActive () const
 
bool isTransactionActive (bool deep=true) const
 
void openDb ()
 
void openGTDb (FailureOnOpeningPolicy policy=THROW)
 
void openIovDb (FailureOnOpeningPolicy policy=THROW)
 
void openRunInfoDb ()
 
void rollbackTransaction ()
 
IRunInfoSchemarunInfoSchema ()
 
 SessionImpl ()
 
 SessionImpl (std::shared_ptr< coral::ISessionProxy > &session, const std::string &connectionString)
 
void startTransaction (bool readOnly=true)
 
 ~SessionImpl ()
 

Public Attributes

std::string connectionString
 
std::shared_ptr< coral::ISessionProxy > coralSession
 
std::unique_ptr< IGTSchemagtSchemaHandle
 
std::unique_ptr< IIOVSchemaiovSchemaHandle
 
std::unique_ptr< IRunInfoSchemarunInfoSchemaHandle
 
std::unique_ptr< ITransactiontransaction
 

Detailed Description

Definition at line 39 of file SessionImpl.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

cond::persistency::SessionImpl::SessionImpl ( )

Definition at line 35 of file SessionImpl.cc.

35  :
36  coralSession(){
37  }
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:66
cond::persistency::SessionImpl::SessionImpl ( std::shared_ptr< coral::ISessionProxy > &  session,
const std::string &  connectionString 
)

Definition at line 39 of file SessionImpl.cc.

40  :
42  connectionString( connectionStr ){
43  }
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:66
cond::persistency::SessionImpl::~SessionImpl ( )

Definition at line 45 of file SessionImpl.cc.

References close().

45  {
46  close();
47  }

Member Function Documentation

void cond::persistency::SessionImpl::close ( void  )

Definition at line 49 of file SessionImpl.cc.

References coralSession, and transaction.

Referenced by lumiQTWidget.ApplicationWindow::fileQuit(), esMonitoring.AsyncLineReaderMixin::handle_close(), esMonitoring.FDJsonServer::handle_close(), Vispa.Gui.BoxContentDialog.BoxContentDialog::keyPressEvent(), Vispa.Gui.FindDialog.FindDialog::keyPressEvent(), and ~SessionImpl().

49  {
50  if( coralSession.get() ){
51  if( coralSession->transaction().isActive() ){
52  coralSession->transaction().rollback();
53  }
54  coralSession.reset();
55  }
56  transaction.reset();
57  }
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:66
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69
void cond::persistency::SessionImpl::commitTransaction ( )

Definition at line 77 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, runInfoSchemaHandle, and transaction.

Referenced by cond::persistency::Transaction::commit().

77  {
78  if( transaction ) {
79  transaction->clients--;
80  if( !transaction->clients ){
81  transaction->commit();
82  transaction.reset();
83  iovSchemaHandle.reset();
84  gtSchemaHandle.reset();
85  runInfoSchemaHandle.reset();
86  }
87  }
88  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:72
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:71
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69
IGTSchema & cond::persistency::SessionImpl::gtSchema ( )

Definition at line 173 of file SessionImpl.cc.

References gtSchemaHandle.

173  {
174  return *gtSchemaHandle;
175  }
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:71
IIOVSchema & cond::persistency::SessionImpl::iovSchema ( )

Definition at line 169 of file SessionImpl.cc.

References iovSchemaHandle.

169  {
170  return *iovSchemaHandle;
171  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:70
bool cond::persistency::SessionImpl::isActive ( ) const

Definition at line 59 of file SessionImpl.cc.

References coralSession.

59  {
60  return coralSession.get();
61  }
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:66
bool cond::persistency::SessionImpl::isTransactionActive ( bool  deep = true) const

Definition at line 100 of file SessionImpl.cc.

References transaction.

Referenced by cond::persistency::Transaction::isActive().

100  {
101  if( !transaction ) return false;
102  if( !deep ) return true;
103  return transaction->isActive();
104  }
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69
void cond::persistency::SessionImpl::openDb ( )

Definition at line 149 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, cond::persistency::throwException(), and transaction.

149  {
150  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::openIovDb" );
151  if( !transaction->iovDbOpen ){
152  transaction->iovDbExists = iovSchemaHandle->exists();
153  transaction->iovDbOpen = true;
154  }
155  if( !transaction->gtDbOpen ){
156  transaction->gtDbExists = gtSchemaHandle->exists();
157  transaction->gtDbOpen = true;
158  }
159  if( !transaction->iovDbExists ){
160  iovSchemaHandle->create();
161  transaction->iovDbExists = true;
162  if( !transaction->gtDbExists ){
163  gtSchemaHandle->create();
164  transaction->gtDbExists = true;
165  }
166  }
167  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:71
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void cond::persistency::SessionImpl::openGTDb ( SessionImpl::FailureOnOpeningPolicy  policy = THROW)

Definition at line 122 of file SessionImpl.cc.

References CREATE, gtSchemaHandle, THROW, cond::persistency::throwException(), and transaction.

122  {
123  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::openGTDb" );
124  if( !transaction->gtDbOpen ){
125  transaction->gtDbExists = gtSchemaHandle->exists();
126  transaction->gtDbOpen = true;
127  }
128  if( !transaction->gtDbExists ){
129  if( policy==CREATE ){
130  gtSchemaHandle->create();
131  transaction->gtDbExists = true;
132  } else {
133  if( policy==THROW) throwException( "GT Database does not exist.","SessionImpl::openGTDb");
134  }
135  }
136  }
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:71
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void cond::persistency::SessionImpl::openIovDb ( SessionImpl::FailureOnOpeningPolicy  policy = THROW)

Definition at line 106 of file SessionImpl.cc.

References CREATE, iovSchemaHandle, THROW, cond::persistency::throwException(), and transaction.

106  {
107  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::openIovDb" );
108  if( !transaction->iovDbOpen ){
109  transaction->iovDbExists = iovSchemaHandle->exists();
110  transaction->iovDbOpen = true;
111  }
112  if( !transaction->iovDbExists ){
113  if( policy==CREATE ){
114  iovSchemaHandle->create();
115  transaction->iovDbExists = true;
116  } else {
117  if( policy==THROW) throwException( "IOV Database does not exist.","SessionImpl::openIovDb");
118  }
119  }
120  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void cond::persistency::SessionImpl::openRunInfoDb ( )

Definition at line 138 of file SessionImpl.cc.

References runInfoSchemaHandle, cond::persistency::throwException(), and transaction.

138  {
139  if(!transaction.get()) throwException( "The transaction is not active.","SessionImpl::openRunInfoDb" );
140  if( !transaction->runInfoDbOpen ){
141  transaction->runInfoDbExists = runInfoSchemaHandle->exists();
142  transaction->runInfoDbOpen = true;
143  }
144  if( !transaction->runInfoDbExists ){
145  throwException( "RunInfo Database does not exist.","SessionImpl::openRunInfoDb");
146  }
147  }
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:72
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void cond::persistency::SessionImpl::rollbackTransaction ( )

Definition at line 90 of file SessionImpl.cc.

References gtSchemaHandle, iovSchemaHandle, runInfoSchemaHandle, and transaction.

Referenced by cond::persistency::Transaction::rollback().

90  {
91  if( transaction ) {
92  transaction->rollback();
93  transaction.reset();
94  iovSchemaHandle.reset();
95  gtSchemaHandle.reset();
96  runInfoSchemaHandle.reset();
97  }
98  }
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:72
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:71
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69
IRunInfoSchema & cond::persistency::SessionImpl::runInfoSchema ( )

Definition at line 177 of file SessionImpl.cc.

References runInfoSchemaHandle.

177  {
178  return *runInfoSchemaHandle;
179  }
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:72
void cond::persistency::SessionImpl::startTransaction ( bool  readOnly = true)

Definition at line 63 of file SessionImpl.cc.

References coralSession, gtSchemaHandle, iovSchemaHandle, runInfoSchemaHandle, cond::persistency::throwException(), and transaction.

Referenced by cond::persistency::Transaction::start().

63  {
64  if( !transaction.get() ){
65  coralSession->transaction().start( readOnly );
66  iovSchemaHandle.reset( new IOVSchema( coralSession->nominalSchema() ) );
67  gtSchemaHandle.reset( new GTSchema( coralSession->nominalSchema() ) );
68  runInfoSchemaHandle.reset( new RunInfoSchema( coralSession->nominalSchema() ) );
69  transaction.reset( new CondDBTransaction( coralSession ) );
70  } else {
71  if(!readOnly ) throwException( "An update transaction is already active.",
72  "SessionImpl::startTransaction" );
73  }
74  transaction->clients++;
75  }
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:66
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:70
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:72
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:71
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:69
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14

Member Data Documentation

std::string cond::persistency::SessionImpl::connectionString

Definition at line 68 of file SessionImpl.h.

std::shared_ptr<coral::ISessionProxy> cond::persistency::SessionImpl::coralSession

Definition at line 66 of file SessionImpl.h.

Referenced by close(), isActive(), and startTransaction().

std::unique_ptr<IGTSchema> cond::persistency::SessionImpl::gtSchemaHandle
std::unique_ptr<IIOVSchema> cond::persistency::SessionImpl::iovSchemaHandle
std::unique_ptr<IRunInfoSchema> cond::persistency::SessionImpl::runInfoSchemaHandle
std::unique_ptr<ITransaction> cond::persistency::SessionImpl::transaction