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)
 
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:177
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
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:177
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
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:177
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
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 148 of file Session.cc.

References m_session.

148  {
149  m_session->openIovDb();
150  m_session->iovSchema().iovTable().erase( tag );
151  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
void Session::close ( void  )
std::string Session::connectionString ( )

Definition at line 217 of file Session.cc.

References m_session.

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

217  {
218  return m_session->connectionString;
219  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
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:176
GTEditor Session::createGlobalTag ( const std::string &  name)

Definition at line 158 of file Session.cc.

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

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

Definition at line 180 of file Session.h.

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

180  {
181  return createIov( cond::demangledName( typeid(T) ), tag, timeType, synchronizationType );
182  }
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:180
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 108 of file Session.cc.

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

109  {
110  m_session->openDb();
111  if( m_session->iovSchema().tagTable().select( tag ) )
112  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
113  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
114  return editor;
115  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
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 117 of file Session.cc.

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

121  {
122  m_session->openDb();
123  if( m_session->iovSchema().tagTable().select( tag ) )
124  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
125  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType, creationTime );
126  return editor;
127  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
IOVEditor Session::createIovForPayload ( const Hash payloadHash,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 129 of file Session.cc.

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

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

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

Definition at line 166 of file Session.cc.

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

166  {
167  m_session->openGTDb();
169  editor.load( name );
170  return editor;
171  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
IOVEditor Session::editIov ( const std::string &  tag)
RunInfoEditor Session::editRunInfo ( )

Definition at line 211 of file Session.cc.

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

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

211  {
213  editor.init();
214  return editor;
215  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
bool Session::existsDatabase ( )
bool Session::existsGlobalTag ( const std::string &  name)

Definition at line 153 of file Session.cc.

References m_session.

153  {
154  m_session->openGTDb();
155  return m_session->gtSchema().gtTable().select( name );
156  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
bool Session::existsIov ( const std::string &  tag)
template<typename T >
std::shared_ptr< T > Session::fetchPayload ( const cond::Hash payloadHash)
inline

Definition at line 197 of file Session.h.

References MillePedeFileConverter_cfg::e, Phase2ITPixelClusterizer_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().

197  {
198  cond::Binary payloadData;
199  cond::Binary streamerInfoData;
201  if(! fetchPayloadData( payloadHash, payloadType, payloadData, streamerInfoData ) )
202  throwException( "Payload with id "+payloadHash+" has not been found in the database.",
203  "Session::fetchPayload" );
204  std::shared_ptr<T> ret;
205  try{
206  ret = deserialize<T>( payloadType, payloadData, streamerInfoData );
207  } catch ( const cond::persistency::Exception& e ){
208  std::string em(e.what());
209  throwException( "Payload of type "+payloadType+" with id "+payloadHash+" could not be loaded. "+em,"Session::fetchPayload");
210  }
211  return ret;
212  }
virtual char const * what() const
Definition: Exception.cc:141
Base exception class for the object to relational access.
Definition: Exception.h:11
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:195
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 195 of file Session.cc.

References m_session.

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

198  {
199  m_session->openIovDb();
200  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
201  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
RunInfoProxy Session::getRunInfo ( cond::Time_t  start,
cond::Time_t  end 
)

Definition at line 203 of file Session.cc.

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

203  {
204  if(!m_session->transaction.get())
205  throwException( "The transaction is not active.","Session::getRunInfo" );
206  RunInfoProxy proxy( m_session );
207  proxy.load( start, end );
208  return proxy;
209  }
Definition: start.py:1
#define end
Definition: vmac.h:37
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
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:176
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:177
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
GTProxy Session::readGlobalTag ( const std::string &  name)

Definition at line 173 of file Session.cc.

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

Referenced by CondDBESSource::fillTagCollectionFromGT().

173  {
174  m_session->openGTDb();
175  GTProxy proxy( m_session );
176  proxy.load( name );
177  return proxy;
178  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
GTProxy Session::readGlobalTag ( const std::string &  name,
const std::string &  preFix,
const std::string &  postFix 
)

Definition at line 180 of file Session.cc.

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

180  {
181  m_session->openGTDb();
182  GTProxy proxy( m_session );
183  proxy.load( name, preFix, postFix );
184  return proxy;
185  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
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:176
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 184 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().

184  {
185 
186  std::string payloadObjectType = cond::demangledName(typeid(payload));
187  cond::Hash ret;
188  try{
189  ret = storePayloadData( payloadObjectType, serialize( payload ), creationTime );
190  } catch ( const cond::persistency::Exception& e ){
191  std::string em(e.what());
192  throwException( "Payload of type "+payloadObjectType+" could not be stored. "+em,"Session::storePayload");
193  }
194  return ret;
195  }
virtual char const * what() const
Definition: Exception.cc:141
Base exception class for the object to relational access.
Definition: Exception.h:11
std::pair< Binary, Binary > serialize(const T &payload)
Definition: Serialization.h:54
payload
payload postfix for testing
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:187
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 187 of file Session.cc.

References m_session.

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

189  {
190  m_session->openDb();
191  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
192  payloadAndStreamerInfoData.second, creationTime );
193  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
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(), 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(), 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:177

Member Data Documentation

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

Definition at line 177 of file Session.h.

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