CMS 3D CMS Logo

Session.cc
Go to the documentation of this file.
2 #include "SessionImpl.h"
3 //
4 
5 namespace cond {
6 
7  namespace persistency {
8 
9  Transaction::Transaction(SessionImpl& session) : m_session(&session) {}
10 
11  Transaction::Transaction(const Transaction& rhs) : m_session(rhs.m_session) {}
12 
14  m_session = rhs.m_session;
15  return *this;
16  }
17 
18  void Transaction::start(bool readOnly) {
19  if (m_session)
20  m_session->startTransaction(readOnly);
21  }
22 
24  if (m_session)
26  }
27 
29  if (m_session)
31  }
32 
34 
35  Session::Session() : m_session(new SessionImpl), m_transaction(*m_session) {}
36 
37  Session::Session(const std::shared_ptr<SessionImpl>& sessionImpl)
38  : m_session(sessionImpl), m_transaction(*m_session) {}
39 
40  Session::Session(const Session& rhs) : m_session(rhs.m_session), m_transaction(rhs.m_transaction) {}
41 
43 
45  m_session = rhs.m_session;
47  return *this;
48  }
49 
50  void Session::close() { m_session->close(); }
51 
53 
54  //
57  return m_session->transaction->iovDbExists;
58  }
59 
60  //
61  void Session::createDatabase() { m_session->openDb(); }
62 
64  m_session->openIovDb();
65  IOVProxy proxy(m_session);
66  proxy.load(tagName);
67  return proxy;
68  }
69 
70  IOVProxy Session::readIov(const std::string& tagName, const boost::posix_time::ptime& snapshottime) {
71  m_session->openIovDb();
72  IOVProxy proxy(m_session);
73  proxy.load(tagName, snapshottime);
74  return proxy;
75  }
76 
78  m_session->openIovDb();
79  return m_session->iovSchema().tagTable().select(tag);
80  }
81 
82  //bool Session::getIovRange(const std::string& tag,
83  // cond::Time_t begin,
84  // cond::Time_t end,
85  // std::vector<std::tuple<cond::Time_t, cond::Hash> >& range) {
86  // m_session->openIovDb();
87  // boost::posix_time::ptime snapshotTime;
88  // return m_session->iovSchema().iovTable().getRange(tag, begin, end, snapshotTime, range);
89  //}
90 
92  const std::string& tag,
93  cond::TimeType timeType,
94  cond::SynchronizationType synchronizationType) {
95  m_session->openDb();
96  if (m_session->iovSchema().tagTable().select(tag))
97  throwException("The specified tag \"" + tag + "\" already exist in the database.", "Session::createIov");
98  IOVEditor editor(m_session, tag, timeType, payloadType, synchronizationType);
99  return editor;
100  }
101 
103  const std::string& tag,
104  cond::TimeType timeType,
105  cond::SynchronizationType synchronizationType,
106  const boost::posix_time::ptime& creationTime) {
107  m_session->openDb();
108  if (m_session->iovSchema().tagTable().select(tag))
109  throwException("The specified tag \"" + tag + "\" already exist in the database.", "Session::createIov");
110  IOVEditor editor(m_session, tag, timeType, payloadType, synchronizationType, creationTime);
111  return editor;
112  }
113 
115  const std::string& tag,
116  cond::TimeType timeType,
117  cond::SynchronizationType synchronizationType) {
118  m_session->openDb();
119  if (m_session->iovSchema().tagTable().select(tag))
120  throwException("The specified tag \"" + tag + "\" already exist in the database.",
121  "Session::createIovForPayload");
123  if (!m_session->iovSchema().payloadTable().getType(payloadHash, payloadType))
124  throwException("The specified payloadId \"" + payloadHash + "\" does not exist in the database.",
125  "Session::createIovForPayload");
126  IOVEditor editor(m_session, tag, timeType, payloadType, synchronizationType);
127  return editor;
128  }
129 
131  m_session->openIovDb();
132  IOVEditor editor(m_session);
133  editor.load(tag);
134  return editor;
135  }
136 
138  m_session->openIovDb();
139  m_session->iovSchema().iovTable().erase(tag);
140  }
141 
143  m_session->openGTDb();
144  return m_session->gtSchema().gtTable().select(name);
145  }
146 
148  m_session->openGTDb();
149  if (m_session->gtSchema().gtTable().select(name))
150  throwException("The specified Global Tag \"" + name + "\" already exist in the database.",
151  "Session::createGlobalTag");
152  GTEditor editor(m_session, name);
153  return editor;
154  }
155 
157  m_session->openGTDb();
158  GTEditor editor(m_session);
159  editor.load(name);
160  return editor;
161  }
162 
164  m_session->openGTDb();
165  GTProxy proxy(m_session);
166  proxy.load(name);
167  return proxy;
168  }
169 
170  GTProxy Session::readGlobalTag(const std::string& name, const std::string& preFix, const std::string& postFix) {
171  m_session->openGTDb();
172  GTProxy proxy(m_session);
173  proxy.load(name, preFix, postFix);
174  return proxy;
175  }
176 
178  const std::pair<Binary, Binary>& payloadAndStreamerInfoData,
179  const boost::posix_time::ptime& creationTime) {
180  m_session->openDb();
181  return m_session->iovSchema().payloadTable().insertIfNew(
182  payloadObjectType, payloadAndStreamerInfoData.first, payloadAndStreamerInfoData.second, creationTime);
183  }
184 
185  bool Session::fetchPayloadData(const cond::Hash& payloadHash,
187  cond::Binary& payloadData,
188  cond::Binary& streamerInfoData) {
189  m_session->openIovDb();
190  return m_session->iovSchema().payloadTable().select(payloadHash, payloadType, payloadData, streamerInfoData);
191  }
192 
194  if (!m_session->transaction.get())
195  throwException("The transaction is not active.", "Session::getRunInfo");
196  RunInfoProxy proxy(m_session);
197  proxy.load(start, end);
198  return proxy;
199  }
200 
202  if (!m_session->transaction.get())
203  throwException("The transaction is not active.", "Session::getRunInfo");
204  m_session->openRunInfoDb();
206  ret.run = m_session->runInfoSchema().runInfoTable().getLastInserted(ret.start, ret.end);
207  return ret;
208  }
209 
211  RunInfoEditor editor(m_session);
212  editor.init();
213  return editor;
214  }
215 
216  std::string Session::connectionString() { return m_session->connectionString; }
217 
218  coral::ISessionProxy& Session::coralSession() {
219  if (!m_session->coralSession.get())
220  throwException("The session is not active.", "Session::coralSession");
221  return *m_session->coralSession;
222  }
223 
224  coral::ISchema& Session::nominalSchema() { return coralSession().nominalSchema(); }
225 
226  TransactionScope::TransactionScope(Transaction& transaction) : m_transaction(transaction), m_status(true) {
228  }
229 
231  if (!m_status && m_transaction.isActive()) {
233  }
234  }
235 
236  void TransactionScope::start(bool readOnly) {
237  m_transaction.start(readOnly);
238  m_status = false;
239  }
240 
243  m_status = true;
244  }
245 
247 
248  } // namespace persistency
249 } // namespace cond
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
start
Definition: start.py:1
cond::TimeType
TimeType
Definition: Time.h:19
cond::Hash
std::string Hash
Definition: Types.h:43
cond::persistency::RunInfoProxy::load
void load(Time_t low, Time_t up)
Definition: RunInfoProxy.cc:66
cond::persistency::Session::existsIov
bool existsIov(const std::string &tag)
Definition: Session.cc:77
cond::persistency::GTProxy
Definition: GTProxy.h:32
cond::persistency::Transaction
Definition: Session.h:44
cond::Binary
Definition: Binary.h:15
cond::persistency::RunInfoProxy
Definition: RunInfoProxy.h:26
cond::persistency::Session::clearIov
void clearIov(const std::string &tag)
Definition: Session.cc:137
cond::persistency::TransactionScope::m_status
bool m_status
Definition: Session.h:245
cond::persistency::IOVEditor
Definition: IOVEditor.h:28
cond::persistency::TransactionScope::start
void start(bool readOnly=true)
Definition: Session.cc:236
cond::persistency::Session::readGlobalTag
GTProxy readGlobalTag(const std::string &name)
Definition: Session.cc:163
cond::persistency::Session::close
void close()
Definition: Session.cc:50
cond::persistency::SessionImpl::rollbackTransaction
void rollbackTransaction()
Definition: SessionImpl.cc:78
cond::persistency::TransactionScope::close
void close()
Definition: Session.cc:246
end
#define end
Definition: vmac.h:39
cond::persistency::Session::createDatabase
void createDatabase()
Definition: Session.cc:61
cond::persistency::RunInfoEditor::init
void init()
Definition: RunInfoEditor.cc:32
cond::persistency::IOVProxy::load
void load(const std::string &tag)
Definition: IOVProxy.cc:131
cond::persistency::SessionImpl
Definition: SessionImpl.h:40
cond::persistency::GTEditor::load
void load(const std::string &gtName)
Definition: GTEditor.cc:43
cond::persistency::Session::getLastRun
cond::RunInfo_t getLastRun()
Definition: Session.cc:201
cond::SynchronizationType
SynchronizationType
Definition: Types.h:27
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
SessionImpl.h
cond::persistency::Session::m_transaction
Transaction m_transaction
Definition: Session.h:175
cond::persistency::TransactionScope::m_transaction
Transaction & m_transaction
Definition: Session.h:244
cond::persistency::Session::getRunInfo
RunInfoProxy getRunInfo(cond::Time_t start, cond::Time_t end)
Definition: Session.cc:193
cond::persistency::SessionImpl::DO_NOT_THROW
Definition: SessionImpl.h:42
cond::persistency::Session::readIov
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::persistency::IOVProxy
Definition: IOVProxy.h:92
cond
Definition: plugin.cc:23
cond::persistency::Session::storePayloadData
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:177
funct::true
true
Definition: Factorize.h:173
cond::persistency::Session::editIov
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:130
cond::persistency::GTEditor
Definition: GTEditor.h:28
cond::persistency::TransactionScope::commit
void commit()
Definition: Session.cc:241
cond::persistency::Transaction::Transaction
Transaction(SessionImpl &session)
Definition: Session.cc:9
cond::persistency::Session::nominalSchema
coral::ISchema & nominalSchema()
Definition: Session.cc:224
cond::persistency::Session
Definition: Session.h:63
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
cond::persistency::Session::connectionString
std::string connectionString()
Definition: Session.cc:216
cond::persistency::SessionImpl::startTransaction
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:47
cond::persistency::Session::editGlobalTag
GTEditor editGlobalTag(const std::string &name)
Definition: Session.cc:156
cond::persistency::Transaction::commit
void commit()
Definition: Session.cc:23
cond::persistency::Session::coralSession
coral::ISessionProxy & coralSession()
Definition: Session.cc:218
cond::persistency::Session::fetchPayloadData
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:185
HLT_2018_cff.payloadType
payloadType
Definition: HLT_2018_cff.py:8133
cond::persistency::RunInfoEditor
Definition: RunInfoEditor.h:28
cond::persistency::Session::createIovForPayload
IOVEditor createIovForPayload(const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.cc:114
cond::persistency::GTProxy::load
void load(const std::string &gtName, const std::string &preFix="", const std::string &postFix="")
Definition: GTProxy.cc:107
cond::persistency::Transaction::isActive
bool isActive()
Definition: Session.cc:33
cond::RunInfo_t
Definition: Types.h:139
cond::persistency::SessionImpl::isTransactionActive
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:90
cond::persistency::Session::transaction
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Transaction::start
void start(bool readOnly=true)
Definition: Session.cc:18
cond::persistency::Session::m_session
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
cond::persistency::Transaction::rollback
void rollback()
Definition: Session.cc:28
cond::persistency::Session::existsDatabase
bool existsDatabase()
Definition: Session.cc:55
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
cond::persistency::Session::createIov
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:179
cond::persistency::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
cond::persistency::TransactionScope::~TransactionScope
~TransactionScope()
Definition: Session.cc:230
cond::persistency::Transaction::m_session
SessionImpl * m_session
Definition: Session.h:59
cond::persistency::Session::existsGlobalTag
bool existsGlobalTag(const std::string &name)
Definition: Session.cc:142
cond::persistency::Session::createGlobalTag
GTEditor createGlobalTag(const std::string &name)
Definition: Session.cc:147
cond::persistency::Transaction::operator=
Transaction & operator=(const Transaction &rhs)
Definition: Session.cc:13
cond::persistency::Session::editRunInfo
RunInfoEditor editRunInfo()
Definition: Session.cc:210
cond::persistency::SessionImpl::commitTransaction
void commitTransaction()
Definition: SessionImpl.cc:63
Session.h
cond::persistency::TransactionScope::TransactionScope
TransactionScope(Transaction &transaction)
Definition: Session.cc:226
cond::persistency::Session::operator=
Session & operator=(const Session &rhs)
Definition: Session.cc:44
JetPartonCorrections_cff.tagName
tagName
Definition: JetPartonCorrections_cff.py:12
cond::persistency::Session::~Session
virtual ~Session()
Definition: Session.cc:42
cond::persistency::IOVEditor::load
void load(const std::string &tag)
Definition: IOVEditor.cc:68
cond::persistency::Session::Session
Session()
Definition: Session.cc:35