CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cond::persistency::Session Class Reference

#include <Session.h>

Public Member Functions

void clearIov (const std::string &tag)
 
void close ()
 
std::string connectionString ()
 
coral::ISessionProxy & coralSession ()
 
void createDatabase ()
 
GTEditor createGlobalTag (const std::string &name)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType, const boost::posix_time::ptime &creationTime)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
template<typename T >
IOVEditor createIov (const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
IOVEditor createIovForPayload (const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
GTEditor editGlobalTag (const std::string &name)
 
IOVEditor editIov (const std::string &tag)
 
RunInfoEditor editRunInfo ()
 
bool existsDatabase ()
 
bool existsGlobalTag (const std::string &name)
 
bool existsIov (const std::string &tag)
 
template<typename T >
std::unique_ptr< TfetchPayload (const cond::Hash &payloadHash)
 
bool fetchPayloadData (const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
 
cond::RunInfo_t getLastRun ()
 
RunInfoProxy getRunInfo (cond::Time_t start, cond::Time_t end)
 
coral::ISchema & nominalSchema ()
 
Sessionoperator= (const Session &rhs)
 
GTProxy readGlobalTag (const std::string &name)
 
GTProxy readGlobalTag (const std::string &name, const std::string &preFix, const std::string &postFix)
 
IOVProxy readIov (const std::string &tag)
 
IOVProxy readIov (const std::string &tag, const boost::posix_time::ptime &snapshottime)
 
 Session ()
 
 Session (const Session &rhs)
 
 Session (const std::shared_ptr< SessionImpl > &sessionImpl)
 
template<typename T >
cond::Hash storePayload (const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
 
cond::Hash storePayloadData (const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
 
Transactiontransaction ()
 
virtual ~Session ()
 

Private Attributes

std::shared_ptr< SessionImplm_session
 
Transaction m_transaction
 

Detailed Description

Definition at line 63 of file Session.h.

Constructor & Destructor Documentation

◆ Session() [1/3]

Session::Session ( )

Definition at line 35 of file Session.cc.

35 : m_session(new SessionImpl), m_transaction(*m_session) {}

◆ Session() [2/3]

Session::Session ( const std::shared_ptr< SessionImpl > &  sessionImpl)
explicit

Definition at line 37 of file Session.cc.

38  : m_session(sessionImpl), m_transaction(*m_session) {}

◆ Session() [3/3]

Session::Session ( const Session rhs)

Definition at line 40 of file Session.cc.

40 : m_session(rhs.m_session), m_transaction(rhs.m_transaction) {}

◆ ~Session()

Session::~Session ( )
virtual

Definition at line 42 of file Session.cc.

42 {}

Member Function Documentation

◆ clearIov()

void Session::clearIov ( const std::string &  tag)

Definition at line 137 of file Session.cc.

137  {
138  m_session->openIovDb();
139  m_session->iovSchema().iovTable().erase(tag);
140  }

References m_session, and GlobalPosition_Frontier_DevDB_cff::tag.

◆ close()

void Session::close ( void  )

◆ connectionString()

std::string Session::connectionString ( )

Definition at line 216 of file Session.cc.

216 { return m_session->connectionString; }

References m_session.

Referenced by PCLMetadataWriter::endRun(), cond::persistency::PayloadReader::fetch(), cond::persistency::importIovs(), and popcon::PopCon::initialize().

◆ coralSession()

coral::ISessionProxy & Session::coralSession ( )

◆ createDatabase()

void Session::createDatabase ( )

Definition at line 61 of file Session.cc.

61 { m_session->openDb(); }

References m_session.

Referenced by cond::persistency::importIovs().

◆ createGlobalTag()

GTEditor Session::createGlobalTag ( const std::string &  name)

Definition at line 147 of file Session.cc.

147  {
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  }

References m_session, Skims_PA_cff::name, and cond::persistency::throwException().

◆ createIov() [1/3]

IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType,
const boost::posix_time::ptime &  creationTime 
)

Definition at line 102 of file Session.cc.

106  {
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  }

References m_session, HLT_2018_cff::payloadType, GlobalPosition_Frontier_DevDB_cff::tag, and cond::persistency::throwException().

◆ createIov() [2/3]

IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 91 of file Session.cc.

94  {
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  }

References m_session, HLT_2018_cff::payloadType, GlobalPosition_Frontier_DevDB_cff::tag, and cond::persistency::throwException().

◆ createIov() [3/3]

template<typename T >
IOVEditor Session::createIov ( const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)
inline

◆ createIovForPayload()

IOVEditor Session::createIovForPayload ( const Hash payloadHash,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 114 of file Session.cc.

117  {
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  }

References m_session, HLT_2018_cff::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and cond::persistency::throwException().

◆ editGlobalTag()

GTEditor Session::editGlobalTag ( const std::string &  name)

Definition at line 156 of file Session.cc.

156  {
157  m_session->openGTDb();
158  GTEditor editor(m_session);
159  editor.load(name);
160  return editor;
161  }

References cond::persistency::GTEditor::load(), m_session, and Skims_PA_cff::name.

◆ editIov()

IOVEditor Session::editIov ( const std::string &  tag)

◆ editRunInfo()

RunInfoEditor Session::editRunInfo ( )

Definition at line 210 of file Session.cc.

210  {
211  RunInfoEditor editor(m_session);
212  editor.init();
213  return editor;
214  }

References cond::persistency::RunInfoEditor::init(), and m_session.

Referenced by RunInfoUpdate::appendNewRun(), and RunInfoUpdate::import().

◆ existsDatabase()

bool Session::existsDatabase ( )

Definition at line 55 of file Session.cc.

55  {
57  return m_session->transaction->iovDbExists;
58  }

References cond::persistency::SessionImpl::DO_NOT_THROW, and m_session.

Referenced by SiStripDetVOffHandler::analyze(), cond::persistency::importIovs(), and popcon::PopCon::initialize().

◆ existsGlobalTag()

bool Session::existsGlobalTag ( const std::string &  name)

Definition at line 142 of file Session.cc.

142  {
143  m_session->openGTDb();
144  return m_session->gtSchema().gtTable().select(name);
145  }

References m_session, and Skims_PA_cff::name.

◆ existsIov()

bool Session::existsIov ( const std::string &  tag)

◆ fetchPayload()

template<typename T >
std::unique_ptr< T > Session::fetchPayload ( const cond::Hash payloadHash)
inline

Definition at line 213 of file Session.h.

213  {
214  cond::Binary payloadData;
215  cond::Binary streamerInfoData;
217  if (!fetchPayloadData(payloadHash, payloadType, payloadData, streamerInfoData))
218  throwException("Payload with id " + payloadHash + " has not been found in the database.",
219  "Session::fetchPayload");
220  std::unique_ptr<T> ret;
221  try {
222  ret = deserialize<T>(payloadType, payloadData, streamerInfoData);
223  } catch (const cond::persistency::Exception& e) {
224  std::string em(e.what());
225  throwException("Payload of type " + payloadType + " with id " + payloadHash + " could not be loaded. " + em,
226  "Session::fetchPayload");
227  }
228  return ret;
229  }

References MillePedeFileConverter_cfg::e, fetchPayloadData(), HLT_2018_cff::payloadType, runTheMatrix::ret, AlCaHLTBitMon_QueryRunRegistry::string, and cond::persistency::throwException().

Referenced by SiStripDetVOffHandler::analyze(), SiStripDetVOffTkMapPlotter::analyze(), SiStripDetVOffPrinter::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), SiStripDetVOffTrendPlotter::analyze(), BeamSpotRcdPrinter::analyze(), popcon::PopConBTransitionSourceHandler< T >::checkBOn(), cond::persistency::PayloadReader::fetch(), cond::payloadInspector::PlotBase::fetchPayload(), LHCInfoPopConSourceHandler::getNewObjects(), RunInfoUpdate::import(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::loadPayload(), l1t::DataWriterExt::readObject(), l1t::DataWriter::readObject(), and popcon::PopConSourceHandler< T >::Ref::Ref().

◆ fetchPayloadData()

bool Session::fetchPayloadData ( const cond::Hash payloadHash,
std::string &  payloadType,
cond::Binary payloadData,
cond::Binary streamerInfoData 
)

Definition at line 185 of file Session.cc.

188  {
189  m_session->openIovDb();
190  return m_session->iovSchema().payloadTable().select(payloadHash, payloadType, payloadData, streamerInfoData);
191  }

References m_session, and HLT_2018_cff::payloadType.

Referenced by cond::persistency::fetch(), cond::persistency::fetchIfExists(), fetchPayload(), and cond::persistency::importPayload().

◆ getLastRun()

cond::RunInfo_t Session::getLastRun ( )

Definition at line 201 of file Session.cc.

201  {
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  }

References m_session, runTheMatrix::ret, and cond::persistency::throwException().

Referenced by cond::service::OnlineDBOutputService::OnlineDBOutputService().

◆ getRunInfo()

RunInfoProxy Session::getRunInfo ( cond::Time_t  start,
cond::Time_t  end 
)

Definition at line 193 of file Session.cc.

193  {
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  }

References end, cond::persistency::RunInfoProxy::load(), m_session, and cond::persistency::throwException().

Referenced by cond::payloadInspector::TimeHistoryPlot< PayloadType, Y >::fill().

◆ nominalSchema()

coral::ISchema & Session::nominalSchema ( )

◆ operator=()

Session & Session::operator= ( const Session rhs)

Definition at line 44 of file Session.cc.

44  {
45  m_session = rhs.m_session;
46  m_transaction = rhs.m_transaction;
47  return *this;
48  }

References m_session, and m_transaction.

◆ readGlobalTag() [1/2]

GTProxy Session::readGlobalTag ( const std::string &  name)

Definition at line 163 of file Session.cc.

163  {
164  m_session->openGTDb();
165  GTProxy proxy(m_session);
166  proxy.load(name);
167  return proxy;
168  }

References cond::persistency::GTProxy::load(), m_session, and Skims_PA_cff::name.

Referenced by CondDBESSource::fillTagCollectionFromGT().

◆ readGlobalTag() [2/2]

GTProxy Session::readGlobalTag ( const std::string &  name,
const std::string &  preFix,
const std::string &  postFix 
)

Definition at line 170 of file Session.cc.

170  {
171  m_session->openGTDb();
172  GTProxy proxy(m_session);
173  proxy.load(name, preFix, postFix);
174  return proxy;
175  }

References cond::persistency::GTProxy::load(), m_session, and Skims_PA_cff::name.

◆ readIov() [1/2]

IOVProxy Session::readIov ( const std::string &  tag)

◆ readIov() [2/2]

IOVProxy Session::readIov ( const std::string &  tag,
const boost::posix_time::ptime &  snapshottime 
)

Definition at line 70 of file Session.cc.

70  {
71  m_session->openIovDb();
72  IOVProxy proxy(m_session);
73  proxy.load(tagName, snapshottime);
74  return proxy;
75  }

References cond::persistency::IOVProxy::load(), m_session, and JetPartonCorrections_cff::tagName.

◆ storePayload()

template<typename T >
cond::Hash Session::storePayload ( const T payload,
const boost::posix_time::ptime &  creationTime = boost::posix_time::microsec_clock::universal_time() 
)
inline

◆ storePayloadData()

cond::Hash Session::storePayloadData ( const std::string &  payloadObjectType,
const std::pair< Binary, Binary > &  payloadAndStreamerInfoData,
const boost::posix_time::ptime &  creationTime 
)

Definition at line 177 of file Session.cc.

179  {
180  m_session->openDb();
181  return m_session->iovSchema().payloadTable().insertIfNew(
182  payloadObjectType, payloadAndStreamerInfoData.first, payloadAndStreamerInfoData.second, creationTime);
183  }

References m_session.

Referenced by cond::persistency::importPayload(), and storePayload().

◆ transaction()

Transaction & Session::transaction ( )

Definition at line 52 of file Session.cc.

52 { return m_transaction; }

References m_transaction.

Referenced by SiStripDetVOffHandler::analyze(), SiStripDetVOffTkMapPlotter::analyze(), SiStripDetVOffPrinter::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), SiStripDetVOffTrendPlotter::analyze(), BeamSpotRcdPrinter::analyze(), cond::service::PoolDBOutputService::appendSinceTime(), popcon::PopConBTransitionSourceHandler< T >::checkBOn(), popcon::PopConESTransitionSourceHandler< T >::checkLowGain(), l1t::OMDSReader::connect(), cond::persistency::copyIov(), cond::service::PoolDBOutputService::createNewIOV(), cond::payloadInspector::PlotBase::exec_process(), cond::persistency::PayloadReader::fetch(), CondDBESSource::fillTagCollectionFromGT(), popcon::PopCon::finalize(), FillInfoPopConSourceHandler::getNewObjects(), LHCInfoPopConSourceHandler::getNewObjects(), DTLVStatusHandler::getNewObjects(), DTHVStatusHandler::getNewObjects(), popcon::PopConBTransitionSourceHandler< T >::getObjectsForBTransition(), popcon::PopConESTransitionSourceHandler< T >::getObjectsForESTransition(), cond::persistency::importIovs(), SiStripCoralIface::initialize(), popcon::PopCon::initialize(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::make(), l1t::OMDSReader::OMDSReader(), l1t::DataWriterExt::payloadToken(), l1t::DataWriter::payloadToken(), cond::service::OnlineDBOutputService::preLoadIov(), L1RCTOmdsFedVectorProducer::produce(), l1t::DataWriter::readObject(), l1t::WriterProxyT< Record, Type >::save(), l1t::DataWriter::writeKeyList(), l1t::DataWriterExt::writeKeyList(), cond::service::PoolDBOutputService::writeOne(), l1t::DataWriter::writePayload(), and popcon::PopCon::~PopCon().

Member Data Documentation

◆ m_session

std::shared_ptr<SessionImpl> cond::persistency::Session::m_session
private

◆ m_transaction

Transaction cond::persistency::Session::m_transaction
private

Definition at line 175 of file Session.h.

Referenced by operator=(), and transaction().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
start
Definition: start.py:1
GTProxy
cond::Hash
std::string Hash
Definition: Types.h:43
cond::Binary
Definition: Binary.h:15
IOVEditor
end
#define end
Definition: vmac.h:39
GTEditor
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
cond::persistency::Session::m_transaction
Transaction m_transaction
Definition: Session.h:175
jets_cff.payload
payload
Definition: jets_cff.py:34
cond::persistency::SessionImpl::DO_NOT_THROW
Definition: SessionImpl.h:42
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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
cond::persistency::Session::coralSession
coral::ISessionProxy & coralSession()
Definition: Session.cc:218
cond::persistency::Exception
Base exception class for the object to relational access.
Definition: Exception.h:11
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
RunInfoEditor
cond::RunInfo_t
Definition: Types.h:139
T
long double T
Definition: Basic3DVectorLD.h:48
cond::persistency::Session::m_session
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
cond::serialize
std::pair< Binary, Binary > serialize(const T &payload)
Definition: Serialization.h:66
IOVProxy
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
JetPartonCorrections_cff.tagName
tagName
Definition: JetPartonCorrections_cff.py:12
RunInfoProxy
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37