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
std::set< std::string > lockedTags
Definition: SessionImpl.h:73
std::shared_ptr< coral::ISessionProxy > coralSession
Definition: SessionImpl.h:69
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:105
void openGTDb(FailureOnOpeningPolicy policy=THROW)
Definition: SessionImpl.cc:149
void openIovDb(FailureOnOpeningPolicy policy=THROW)
Definition: SessionImpl.cc:131
std::unique_ptr< IIOVSchema > iovSchemaHandle
Definition: SessionImpl.h:75
std::unique_ptr< IRunInfoSchema > runInfoSchemaHandle
Definition: SessionImpl.h:77
std::recursive_mutex transactionMutex
Definition: SessionImpl.h:81
std::unique_lock< std::recursive_mutex > transactionLock
Definition: SessionImpl.h:82
std::unique_ptr< IGTSchema > gtSchemaHandle
Definition: SessionImpl.h:76
Definition: Binary.h:9
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:62
Definition: plugin.cc:23
IRunInfoSchema & runInfoSchema()
Definition: SessionImpl.cc:204
std::unique_ptr< ITransaction > transaction
Definition: SessionImpl.h:74