CMS 3D CMS Logo

SessionImpl.h
Go to the documentation of this file.
1 #ifndef CondCore_CondDB_SessionImpl_h
2 #define CondCore_CondDB_SessionImpl_h
3 
5 #include "IOVSchema.h"
6 #include "GTSchema.h"
7 #include "RunInfoSchema.h"
8 //
9 #include "RelationalAccess/ConnectionService.h"
10 #include "RelationalAccess/ISessionProxy.h"
11 //
12 #include <memory>
13 #include <mutex>
14 // temporarely
15 
16 namespace coral {
17  class ISessionProxy;
18  class ISchema;
19 } // namespace coral
20 
21 namespace cond {
22 
23  namespace persistency {
24 
25  class ITransaction {
26  public:
27  virtual ~ITransaction() {}
28  virtual void commit() = 0;
29  virtual void rollback() = 0;
30  virtual bool isActive() = 0;
31  bool iovDbExists = false;
32  bool iovDbOpen = false;
33  bool gtDbExists = false;
34  bool gtDbOpen = false;
35  bool runInfoDbExists = false;
36  bool runInfoDbOpen = false;
37  size_t clients = 0;
38  };
39 
40  class SessionImpl {
41  public:
43 
44  public:
45  SessionImpl();
46  SessionImpl(std::shared_ptr<coral::ISessionProxy>& session,
48  const std::string& principalName);
49 
50  ~SessionImpl();
51 
52  void close();
53  bool isActive() const;
54  void startTransaction(bool readOnly = true);
55  void commitTransaction();
56  void rollbackTransaction();
57  bool isTransactionActive(bool deep = true) const;
58 
59  void openIovDb(FailureOnOpeningPolicy policy = THROW);
60  void openGTDb(FailureOnOpeningPolicy policy = THROW);
61  void openRunInfoDb();
62  void openDb();
66 
67  public:
68  // allows for session shared among more services. To be changed to unique_ptr when we stop needing this feature.
69  std::shared_ptr<coral::ISessionProxy> coralSession;
73  std::set<std::string> lockedTags;
74  std::unique_ptr<ITransaction> transaction;
75  std::unique_ptr<IIOVSchema> iovSchemaHandle;
76  std::unique_ptr<IGTSchema> gtSchemaHandle;
77  std::unique_ptr<IRunInfoSchema> runInfoSchemaHandle;
78 
79  private:
80  void releaseTagLocks();
81  std::recursive_mutex transactionMutex;
82  std::unique_lock<std::recursive_mutex> transactionLock;
83  };
84 
85  } // namespace persistency
86 
87 } // namespace cond
88 
89 #endif
cond::persistency::ITransaction::runInfoDbExists
bool runInfoDbExists
Definition: SessionImpl.h:35
cond::persistency::SessionImpl::openGTDb
void openGTDb(FailureOnOpeningPolicy policy=THROW)
Definition: SessionImpl.cc:149
cond::persistency::SessionImpl::isActive
bool isActive() const
Definition: SessionImpl.cc:60
cond::persistency::ITransaction::runInfoDbOpen
bool runInfoDbOpen
Definition: SessionImpl.h:36
IOVSchema.h
cond::persistency::SessionImpl::connectionString
std::string connectionString
Definition: SessionImpl.h:71
cond::persistency::SessionImpl::releaseTagLocks
void releaseTagLocks()
Definition: SessionImpl.cc:113
cond::persistency::SessionImpl::lockedTags
std::set< std::string > lockedTags
Definition: SessionImpl.h:73
cond::persistency::SessionImpl::transactionLock
std::unique_lock< std::recursive_mutex > transactionLock
Definition: SessionImpl.h:82
cond::persistency::IGTSchema
Definition: IDbSchema.h:194
cond::persistency::SessionImpl::close
void close()
Definition: SessionImpl.cc:45
cond::persistency::IIOVSchema
Definition: IDbSchema.h:141
cond::persistency::ITransaction::iovDbExists
bool iovDbExists
Definition: SessionImpl.h:31
cond::persistency::ITransaction::rollback
virtual void rollback()=0
cond::persistency::SessionImpl::rollbackTransaction
void rollbackTransaction()
Definition: SessionImpl.cc:93
cond::persistency::SessionImpl::sessionHash
std::string sessionHash
Definition: SessionImpl.h:70
cond::persistency::SessionImpl::~SessionImpl
~SessionImpl()
Definition: SessionImpl.cc:43
cond::persistency::ITransaction::isActive
virtual bool isActive()=0
cond::persistency::SessionImpl::openRunInfoDb
void openRunInfoDb()
Definition: SessionImpl.cc:167
cond::persistency::SessionImpl
Definition: SessionImpl.h:40
coral
Definition: Binary.h:9
cond::persistency::IRunInfoSchema
Definition: IDbSchema.h:226
cond::persistency::SessionImpl::openDb
void openDb()
Definition: SessionImpl.cc:179
cond::persistency::ITransaction::~ITransaction
virtual ~ITransaction()
Definition: SessionImpl.h:27
cond::persistency::SessionImpl::DO_NOT_THROW
Definition: SessionImpl.h:42
cond
Definition: plugin.cc:23
cond::persistency::SessionImpl::iovSchema
IIOVSchema & iovSchema()
Definition: SessionImpl.cc:200
cond::persistency::ITransaction
Definition: SessionImpl.h:25
cond::persistency::SessionImpl::startTransaction
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:62
RunInfoSchema.h
cond::persistency::ITransaction::iovDbOpen
bool iovDbOpen
Definition: SessionImpl.h:32
cond::persistency::SessionImpl::iovSchemaHandle
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:75
cond::persistency::ITransaction::commit
virtual void commit()=0
cond::persistency::ITransaction::gtDbOpen
bool gtDbOpen
Definition: SessionImpl.h:34
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::persistency::SessionImpl::SessionImpl
SessionImpl()
Definition: SessionImpl.cc:33
cond::persistency::SessionImpl::runInfoSchemaHandle
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:77
cond::persistency::SessionImpl::isTransactionActive
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:105
cond::persistency::SessionImpl::gtSchema
IGTSchema & gtSchema()
Definition: SessionImpl.cc:202
cond::persistency::SessionImpl::principalName
std::string principalName
Definition: SessionImpl.h:72
cond::persistency::SessionImpl::runInfoSchema
IRunInfoSchema & runInfoSchema()
Definition: SessionImpl.cc:204
cond::persistency::SessionImpl::transactionMutex
std::recursive_mutex transactionMutex
Definition: SessionImpl.h:81
cond::persistency::ITransaction::clients
size_t clients
Definition: SessionImpl.h:37
cond::persistency::SessionImpl::coralSession
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:69
cond::persistency::SessionImpl::gtSchemaHandle
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:76
cond::persistency::SessionImpl::CREATE
Definition: SessionImpl.h:42
cond::persistency::SessionImpl::THROW
Definition: SessionImpl.h:42
Types.h
cond::persistency::SessionImpl::openIovDb
void openIovDb(FailureOnOpeningPolicy policy=THROW)
Definition: SessionImpl.cc:131
cond::persistency::SessionImpl::commitTransaction
void commitTransaction()
Definition: SessionImpl.cc:78
cond::persistency::SessionImpl::FailureOnOpeningPolicy
FailureOnOpeningPolicy
Definition: SessionImpl.h:42
GTSchema.h
cond::persistency::ITransaction::gtDbExists
bool gtDbExists
Definition: SessionImpl.h:33
cond::persistency::SessionImpl::transaction
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74