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)
 
template<typename T >
IOVEditor createIov (const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType, const boost::posix_time::ptime &creationTime)
 
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::shared_ptr< TfetchPayload (const cond::Hash &payloadHash)
 
bool fetchPayloadData (const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
 
bool getIovRange (const std::string &tag, cond::Time_t begin, cond::Time_t end, std::vector< std::tuple< cond::Time_t, cond::Hash > > &range)
 
RunInfoProxy getRunInfo (cond::Time_t start, cond::Time_t end)
 
IOVProxy iovProxy ()
 
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, bool full=false)
 
IOVProxy readIov (const std::string &tag, const boost::posix_time::ptime &snapshottime, bool full=false)
 
 Session ()
 
 Session (const std::shared_ptr< SessionImpl > &sessionImpl)
 
 Session (const Session &rhs)
 
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 62 of file Session.h.

Constructor & Destructor Documentation

Session::Session ( )

Definition at line 38 of file Session.cc.

38  :
39  m_session( new SessionImpl ),
41  }
Transaction m_transaction
Definition: Session.h:182
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
Session::Session ( const std::shared_ptr< SessionImpl > &  sessionImpl)
explicit

Definition at line 43 of file Session.cc.

43  :
44  m_session( sessionImpl ),
46  }
Transaction m_transaction
Definition: Session.h:182
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
Session::Session ( const Session rhs)

Definition at line 48 of file Session.cc.

48  :
49  m_session( rhs.m_session ),
50  m_transaction( rhs.m_transaction ){
51  }
Transaction m_transaction
Definition: Session.h:182
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
Session::~Session ( )
virtual

Definition at line 53 of file Session.cc.

53  {
54  }

Member Function Documentation

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

Definition at line 155 of file Session.cc.

References m_session.

155  {
156  m_session->openIovDb();
157  m_session->iovSchema().iovTable().erase( tag );
158  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
void Session::close ( void  )
std::string Session::connectionString ( )

Definition at line 224 of file Session.cc.

References m_session.

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

224  {
225  return m_session->connectionString;
226  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
coral::ISessionProxy & Session::coralSession ( )
void Session::createDatabase ( )

Definition at line 77 of file Session.cc.

References m_session.

Referenced by cond::persistency::importIovs(), and cond::service::PoolDBOutputService::initDB().

77  {
78  m_session->openDb();
79  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
GTEditor Session::createGlobalTag ( const std::string &  name)

Definition at line 165 of file Session.cc.

References idDealer::editor, m_session, and cond::persistency::throwException().

165  {
166  m_session->openGTDb();
167  if( m_session->gtSchema().gtTable().select( name ) )
168  throwException( "The specified Global Tag \""+name+"\" already exist in the database.","Session::createGlobalTag");
170  return editor;
171  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
template<typename T >
IOVEditor Session::createIov ( const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)
inline

Definition at line 185 of file Session.h.

Referenced by SiStripDetVOffHandler::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), cond::persistency::copyIov(), cond::service::PoolDBOutputService::createNewIOV(), popcon::PopConBTransitionSourceHandler< T >::getObjectsForBTransition(), and cond::persistency::importIovs().

185  {
186  return createIov( cond::demangledName( typeid(T) ), tag, timeType, synchronizationType );
187  }
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:185
long double T
IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 115 of file Session.cc.

References idDealer::editor, m_session, and cond::persistency::throwException().

116  {
117  m_session->openDb();
118  if( m_session->iovSchema().tagTable().select( tag ) )
119  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
120  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
121  return editor;
122  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
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 124 of file Session.cc.

References idDealer::editor, m_session, and cond::persistency::throwException().

128  {
129  m_session->openDb();
130  if( m_session->iovSchema().tagTable().select( tag ) )
131  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
132  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType, creationTime );
133  return editor;
134  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
IOVEditor Session::createIovForPayload ( const Hash payloadHash,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 136 of file Session.cc.

References idDealer::editor, m_session, SiPixelClusterizer_cfi::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, and cond::persistency::throwException().

Referenced by cond::service::PoolDBOutputService::createNewIOV().

137  {
138  m_session->openDb();
139  if( m_session->iovSchema().tagTable().select( tag ) )
140  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIovForPayload");
142  if( !m_session->iovSchema().payloadTable().getType( payloadHash, payloadType ) )
143  throwException( "The specified payloadId \""+payloadHash+"\" does not exist in the database.","Session::createIovForPayload");
144  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
145  return editor;
146  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
GTEditor Session::editGlobalTag ( const std::string &  name)

Definition at line 173 of file Session.cc.

References idDealer::editor, cond::persistency::GTEditor::load(), and m_session.

173  {
174  m_session->openGTDb();
176  editor.load( name );
177  return editor;
178  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
IOVEditor Session::editIov ( const std::string &  tag)
RunInfoEditor Session::editRunInfo ( )

Definition at line 218 of file Session.cc.

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

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

218  {
220  editor.init();
221  return editor;
222  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
bool Session::existsDatabase ( )
bool Session::existsGlobalTag ( const std::string &  name)

Definition at line 160 of file Session.cc.

References m_session.

160  {
161  m_session->openGTDb();
162  return m_session->gtSchema().gtTable().select( name );
163  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
bool Session::existsIov ( const std::string &  tag)
template<typename T >
std::shared_ptr< T > Session::fetchPayload ( const cond::Hash payloadHash)
inline

Definition at line 215 of file Session.h.

References MillePedeFileConverter_cfg::e, SiPixelClusterizer_cfi::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), and cms::Exception::what().

Referenced by SiStripDetVOffHandler::analyze(), SiStripDetVOffTkMapPlotter::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), SiStripDetVOffTrendPlotter::analyze(), popcon::PopConBTransitionSourceHandler< T >::checkBOn(), cond::persistency::PayloadReader::fetch(), RunInfoUpdate::import(), L1ConfigOnlineProdBaseExt< TRcd, TData >::produce(), L1ConfigOnlineProdBase< TRcd, TData >::produce(), l1t::DataWriter::readObject(), and l1t::DataWriterExt::readObject().

215  {
216  cond::Binary payloadData;
217  cond::Binary streamerInfoData;
219  if(! fetchPayloadData( payloadHash, payloadType, payloadData, streamerInfoData ) )
220  throwException( "Payload with id "+payloadHash+" has not been found in the database.",
221  "Session::fetchPayload" );
222  std::shared_ptr<T> ret;
223  try{
224  ret = deserialize<T>( payloadType, payloadData, streamerInfoData );
225  } catch ( const cond::persistency::Exception& e ){
226  std::string em(e.what());
227  throwException( "Payload of type "+payloadType+" with id "+payloadHash+" could not be loaded. "+em,"Session::fetchPayload");
228  }
229  return ret;
230  }
Base exception class for the object to relational access.
Definition: Exception.h:11
char const * what() const override
Definition: Exception.cc:141
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:202
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
bool Session::fetchPayloadData ( const cond::Hash payloadHash,
std::string &  payloadType,
cond::Binary payloadData,
cond::Binary streamerInfoData 
)

Definition at line 202 of file Session.cc.

References m_session.

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

205  {
206  m_session->openIovDb();
207  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
208  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
bool Session::getIovRange ( const std::string &  tag,
cond::Time_t  begin,
cond::Time_t  end,
std::vector< std::tuple< cond::Time_t, cond::Hash > > &  range 
)

Definition at line 108 of file Session.cc.

References m_session, and loadRecoTauTagMVAsFromPrepDB_cfi::snapshotTime.

Referenced by cond::payloadInspector::PlotBase::process().

109  {
110  m_session->openIovDb();
111  boost::posix_time::ptime snapshotTime;
112  return m_session->iovSchema().iovTable().getRange( tag, begin, end, snapshotTime, range );
113  }
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
RunInfoProxy Session::getRunInfo ( cond::Time_t  start,
cond::Time_t  end 
)

Definition at line 210 of file Session.cc.

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

210  {
211  if(!m_session->transaction.get())
212  throwException( "The transaction is not active.","Session::getRunInfo" );
213  RunInfoProxy proxy( m_session );
214  proxy.load( start, end );
215  return proxy;
216  }
Definition: start.py:1
#define end
Definition: vmac.h:39
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
IOVProxy Session::iovProxy ( )

Definition at line 102 of file Session.cc.

References m_session.

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

102  {
103  m_session->openIovDb();
104  IOVProxy proxy( m_session );
105  return proxy;
106  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
coral::ISchema & Session::nominalSchema ( )
Session & Session::operator= ( const Session rhs)

Definition at line 56 of file Session.cc.

References m_session, and m_transaction.

56  {
57  m_session = rhs.m_session;
58  m_transaction = rhs.m_transaction;
59  return *this;
60  }
Transaction m_transaction
Definition: Session.h:182
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
GTProxy Session::readGlobalTag ( const std::string &  name)

Definition at line 180 of file Session.cc.

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

Referenced by CondDBESSource::fillTagCollectionFromGT().

180  {
181  m_session->openGTDb();
182  GTProxy proxy( m_session );
183  proxy.load( name );
184  return proxy;
185  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
GTProxy Session::readGlobalTag ( const std::string &  name,
const std::string &  preFix,
const std::string &  postFix 
)

Definition at line 187 of file Session.cc.

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

187  {
188  m_session->openGTDb();
189  GTProxy proxy( m_session );
190  proxy.load( name, preFix, postFix );
191  return proxy;
192  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
IOVProxy Session::readIov ( const std::string &  tag,
bool  full = false 
)
IOVProxy Session::readIov ( const std::string &  tag,
const boost::posix_time::ptime &  snapshottime,
bool  full = false 
)

Definition at line 88 of file Session.cc.

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

90  {
91  m_session->openIovDb();
92  IOVProxy proxy( m_session );
93  proxy.load( tag, snapshottime, full );
94  return proxy;
95  }
Definition: GenABIO.cc:180
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
template<typename T >
cond::Hash Session::storePayload ( const T payload,
const boost::posix_time::ptime &  creationTime = boost::posix_time::microsec_clock::universal_time() 
)
inline

Definition at line 189 of file Session.h.

References MillePedeFileConverter_cfg::e, cond::serialize(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), and cms::Exception::what().

Referenced by SiStripDetVOffHandler::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), l1t::WriterProxyT< Record, Type >::save(), l1t::DataWriter::writeKeyList(), and l1t::DataWriterExt::writeKeyList().

189  {
190 
191  std::string payloadObjectType = cond::demangledName(typeid(payload));
192  cond::Hash ret;
193  try{
194  ret = storePayloadData( payloadObjectType, serialize( payload ), creationTime );
195  } catch ( const cond::persistency::Exception& e ){
196  std::string em(e.what());
197  throwException( "Payload of type "+payloadObjectType+" could not be stored. "+em,"Session::storePayload");
198  }
199  return ret;
200  }
Base exception class for the object to relational access.
Definition: Exception.h:11
std::pair< Binary, Binary > serialize(const T &payload)
Definition: Serialization.h:62
char const * what() const override
Definition: Exception.cc:141
std::string Hash
Definition: Types.h:45
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:194
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
cond::Hash Session::storePayloadData ( const std::string &  payloadObjectType,
const std::pair< Binary, Binary > &  payloadAndStreamerInfoData,
const boost::posix_time::ptime &  creationTime 
)

Definition at line 194 of file Session.cc.

References m_session.

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

196  {
197  m_session->openDb();
198  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
199  payloadAndStreamerInfoData.second, creationTime );
200  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
Transaction & Session::transaction ( )

Definition at line 66 of file Session.cc.

References m_transaction.

Referenced by SiStripDetVOffHandler::analyze(), SiStripDetVOffTkMapPlotter::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), SiStripDetVOffTrendPlotter::analyze(), cond::service::PoolDBOutputService::appendSinceTime(), popcon::PopConBTransitionSourceHandler< T >::checkBOn(), cond::service::PoolDBOutputService::closeIOV(), l1t::OMDSReader::connect(), cond::persistency::copyIov(), cond::service::PoolDBOutputService::createNewIOV(), cond::persistency::PayloadReader::fetch(), CondDBESSource::fillTagCollectionFromGT(), popcon::PopCon::finalize(), FillInfoPopConSourceHandler::getNewObjects(), LHCInfoPopConSourceHandler::getNewObjects(), DTLVStatusHandler::getNewObjects(), DTHVStatusHandler::getNewObjects(), popcon::PopConBTransitionSourceHandler< T >::getObjectsForBTransition(), cond::persistency::importIovs(), cond::service::PoolDBOutputService::initDB(), SiStripCoralIface::initialize(), popcon::PopCon::initialize(), cond::persistency::KeyList::load(), cond::persistency::BasePayloadProxy::loadTag(), cond::service::PoolDBOutputService::lookUpRecord(), l1t::OMDSReader::OMDSReader(), l1t::DataWriterExt::payloadToken(), l1t::DataWriter::payloadToken(), cond::service::PoolDBOutputService::postEndJob(), cond::payloadInspector::PlotBase::process(), L1ConfigOnlineProdBaseExt< TRcd, TData >::produce(), L1ConfigOnlineProdBase< TRcd, TData >::produce(), L1RCTOmdsFedVectorProducer::produce(), popcon::RPCEMapSourceHandler::readEMap1(), popcon::L1RPCHwConfigSourceHandler::readHwConfig1(), l1t::DataWriter::readObject(), l1t::WriterProxyT< Record, Type >::save(), cond::persistency::BasePayloadProxy::setIntervalFor(), l1t::DataWriter::writeKeyList(), l1t::DataWriterExt::writeKeyList(), l1t::DataWriter::writePayload(), cond::service::PoolDBOutputService::~PoolDBOutputService(), and popcon::PopCon::~PopCon().

66  {
67  return m_transaction;
68  }
Transaction m_transaction
Definition: Session.h:182

Member Data Documentation

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

Definition at line 182 of file Session.h.

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